4 * $Id: pam_warn.c,v 1.1.1.1 2000/06/20 22:12:10 agmorgan Exp $
5 * $FreeBSD: src/contrib/libpam/modules/pam_warn/pam_warn.c,v 1.3.2.2 2001/06/11 15:28:34 markm Exp $
6 * $DragonFly: src/contrib/libpam/modules/pam_warn/Attic/pam_warn.c,v 1.2 2003/06/17 04:24:03 dillon Exp $
8 * Written by Andrew Morgan <morgan@linux.kernel.org> 1996/3/11
19 * here, we make a definition for the externally accessible function
20 * in this file (this definition is required for static a module
21 * but strongly encouraged generally) it is used to instruct the
22 * modules include file to define the function prototypes.
26 #define PAM_SM_PASSWORD
28 #include <security/pam_modules.h>
32 static void _pam_log(int err, const char *format, ...)
36 va_start(args, format);
37 openlog("PAM-warn", LOG_CONS|LOG_PID, LOG_AUTH);
38 vsyslog(err, format, args);
43 /* --- authentication management functions (only) --- */
46 int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc
49 const char *service=NULL, *user=NULL, *terminal=NULL
50 , *rhost=NULL, *ruser=NULL;
52 (void) pam_get_item(pamh, PAM_SERVICE, (const void **)&service);
53 (void) pam_get_item(pamh, PAM_TTY, (const void **)&terminal);
54 _pam_log(LOG_NOTICE, "service: %s [on terminal: %s]"
55 , service ? service : "<unknown>"
56 , terminal ? terminal : "<unknown>"
58 (void) pam_get_user(pamh, &user, "Who are you? ");
59 (void) pam_get_item(pamh, PAM_RUSER, (const void **)&ruser);
60 (void) pam_get_item(pamh, PAM_RHOST, (const void **)&rhost);
61 _pam_log(LOG_NOTICE, "user: (uid=%d) -> %s [remote: %s@%s]"
63 , user ? user : "<unknown>"
64 , ruser ? ruser : "?nobody"
65 , rhost ? rhost : "?nowhere"
68 /* we are just a fly on the wall */
74 int pam_sm_setcred(pam_handle_t *pamh,int flags,int argc
80 /* password updating functions */
83 int pam_sm_chauthtok(pam_handle_t *pamh,int flags,int argc
86 /* map to the authentication function... */
88 return pam_sm_authenticate(pamh, flags, argc, argv);
92 pam_sm_acct_mgmt (pam_handle_t *pamh, int flags,
93 int argc, const char **argv)
95 /* map to the authentication function... */
97 return pam_sm_authenticate(pamh, flags, argc, argv);
101 pam_sm_open_session (pam_handle_t *pamh, int flags, int argc,
104 /* map to the authentication function... */
106 return pam_sm_authenticate(pamh, flags, argc, argv);
110 pam_sm_close_session (pam_handle_t *pamh, int flags, int argc,
113 /* map to the authentication function... */
115 return pam_sm_authenticate(pamh, flags, argc, argv);
120 /* static module data */
122 struct pam_module _pam_warn_modstruct = {
128 pam_sm_close_session,
134 /* end of module definition */