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