]> granicus.if.org Git - linux-pam/blob - modules/pam_permit/pam_permit.c
Relevant BUGIDs: 132880
[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  */
9
10 #define DEFAULT_USER "nobody"
11
12 #include <stdio.h>
13
14 /*
15  * here, we make definitions for the externally accessible functions
16  * in this file (these definitions are required for static modules
17  * but strongly encouraged generally) they are used to instruct the
18  * modules include file to define their prototypes.
19  */
20
21 #define PAM_SM_AUTH
22 #define PAM_SM_ACCOUNT
23 #define PAM_SM_SESSION
24 #define PAM_SM_PASSWORD
25
26 #include <security/pam_modules.h>
27 #include <security/_pam_macros.h>
28
29 /* --- authentication management functions --- */
30
31 PAM_EXTERN
32 int pam_sm_authenticate(pam_handle_t *pamh,int flags,int argc
33                         ,const char **argv)
34 {
35     int retval;
36     const char *user=NULL;
37
38     /*
39      * authentication requires we know who the user wants to be
40      */
41     retval = pam_get_user(pamh, &user, NULL);
42     if (retval != PAM_SUCCESS) {
43         D(("get user returned error: %s", pam_strerror(pamh,retval)));
44         return retval;
45     }
46     if (user == NULL || *user == '\0') {
47         D(("username not known"));
48         pam_set_item(pamh, PAM_USER, (const void *) DEFAULT_USER);
49     }
50     user = NULL;                                            /* clean up */
51
52     return PAM_SUCCESS;
53 }
54
55 PAM_EXTERN
56 int pam_sm_setcred(pam_handle_t *pamh,int flags,int argc
57                    ,const char **argv)
58 {
59      return PAM_SUCCESS;
60 }
61
62 /* --- account management functions --- */
63
64 PAM_EXTERN
65 int pam_sm_acct_mgmt(pam_handle_t *pamh,int flags,int argc
66                      ,const char **argv)
67 {
68      return PAM_SUCCESS;
69 }
70
71 /* --- password management --- */
72
73 PAM_EXTERN
74 int pam_sm_chauthtok(pam_handle_t *pamh,int flags,int argc
75                      ,const char **argv)
76 {
77      return PAM_SUCCESS;
78 }
79
80 /* --- session management --- */
81
82 PAM_EXTERN
83 int pam_sm_open_session(pam_handle_t *pamh,int flags,int argc
84                         ,const char **argv)
85 {
86     return PAM_SUCCESS;
87 }
88
89 PAM_EXTERN
90 int pam_sm_close_session(pam_handle_t *pamh,int flags,int argc
91                          ,const char **argv)
92 {
93      return PAM_SUCCESS;
94 }
95
96 /* end of module definition */
97
98 #ifdef PAM_STATIC
99
100 /* static module data */
101
102 struct pam_module _pam_permit_modstruct = {
103     "pam_permit",
104     pam_sm_authenticate,
105     pam_sm_setcred,
106     pam_sm_acct_mgmt,
107     pam_sm_open_session,
108     pam_sm_close_session,
109     pam_sm_chauthtok
110 };
111
112 #endif