]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/libpam/modules/pam_permit/pam_permit.c
Initial import of virgin Linux-PAM 0.65, slightly stripped down.
[FreeBSD/FreeBSD.git] / contrib / libpam / modules / pam_permit / pam_permit.c
1 /* pam_permit module */
2
3 /*
4  * $Id: pam_permit.c,v 1.5 1997/02/15 19:03:15 morgan Exp $
5  *
6  * Written by Andrew Morgan <morgan@parc.power.net> 1996/3/11
7  *
8  * $Log: pam_permit.c,v $
9  * Revision 1.5  1997/02/15 19:03:15  morgan
10  * fixed email address
11  *
12  * Revision 1.4  1997/02/15 16:03:10  morgan
13  * force a name for user
14  *
15  * Revision 1.3  1996/06/02 08:10:14  morgan
16  * updated for new static protocol
17  *
18  */
19
20 #define DEFAULT_USER "nobody"
21
22 #include <stdio.h>
23
24 /*
25  * here, we make definitions for the externally accessible functions
26  * in this file (these definitions are required for static modules
27  * but strongly encouraged generally) they are used to instruct the
28  * modules include file to define their prototypes.
29  */
30
31 #define PAM_SM_AUTH
32 #define PAM_SM_ACCOUNT
33 #define PAM_SM_SESSION
34 #define PAM_SM_PASSWORD
35
36 #include <security/pam_modules.h>
37 #include <security/_pam_macros.h>
38
39 /* --- authentication management functions --- */
40
41 PAM_EXTERN
42 int pam_sm_authenticate(pam_handle_t *pamh,int flags,int argc
43                         ,const char **argv)
44 {
45     int retval;
46     const char *user=NULL;
47
48     /*
49      * authentication requires we know who the user wants to be
50      */
51     retval = pam_get_user(pamh, &user, NULL);
52     if (retval != PAM_SUCCESS) {
53         D(("get user returned error: %s", pam_strerror(pamh,retval)));
54         return retval;
55     }
56     if (user == NULL || *user == '\0') {
57         D(("username not known"));
58         pam_set_item(pamh, PAM_USER, (const void *) DEFAULT_USER);
59     }
60     user = NULL;                                            /* clean up */
61
62     return PAM_SUCCESS;
63 }
64
65 PAM_EXTERN
66 int pam_sm_setcred(pam_handle_t *pamh,int flags,int argc
67                    ,const char **argv)
68 {
69      return PAM_SUCCESS;
70 }
71
72 /* --- account management functions --- */
73
74 PAM_EXTERN
75 int pam_sm_acct_mgmt(pam_handle_t *pamh,int flags,int argc
76                      ,const char **argv)
77 {
78      return PAM_SUCCESS;
79 }
80
81 /* --- password management --- */
82
83 PAM_EXTERN
84 int pam_sm_chauthtok(pam_handle_t *pamh,int flags,int argc
85                      ,const char **argv)
86 {
87      return PAM_SUCCESS;
88 }
89
90 /* --- session management --- */
91
92 PAM_EXTERN
93 int pam_sm_open_session(pam_handle_t *pamh,int flags,int argc
94                         ,const char **argv)
95 {
96     return PAM_SUCCESS;
97 }
98
99 PAM_EXTERN
100 int pam_sm_close_session(pam_handle_t *pamh,int flags,int argc
101                          ,const char **argv)
102 {
103      return PAM_SUCCESS;
104 }
105
106 /* end of module definition */
107
108 #ifdef PAM_STATIC
109
110 /* static module data */
111
112 struct pam_module _pam_permit_modstruct = {
113     "pam_permit",
114     pam_sm_authenticate,
115     pam_sm_setcred,
116     pam_sm_acct_mgmt,
117     pam_sm_open_session,
118     pam_sm_close_session,
119     pam_sm_chauthtok
120 };
121
122 #endif