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