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 $
7 * Written by Andrew Morgan <morgan@linux.kernel.org> 1996/3/11
18 * here, we make a definition for the externally accessible function
19 * in this file (this definition is required for static a module
20 * but strongly encouraged generally) it is used to instruct the
21 * modules include file to define the function prototypes.
25 #define PAM_SM_PASSWORD
27 #include <security/pam_modules.h>
31 static void _pam_log(int err, const char *format, ...)
35 va_start(args, format);
36 openlog("PAM-warn", LOG_CONS|LOG_PID, LOG_AUTH);
37 vsyslog(err, format, args);
42 /* --- authentication management functions (only) --- */
45 int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc
48 const char *service=NULL, *user=NULL, *terminal=NULL
49 , *rhost=NULL, *ruser=NULL;
51 (void) pam_get_item(pamh, PAM_SERVICE, (const void **)&service);
52 (void) pam_get_item(pamh, PAM_TTY, (const void **)&terminal);
53 _pam_log(LOG_NOTICE, "service: %s [on terminal: %s]"
54 , service ? service : "<unknown>"
55 , terminal ? terminal : "<unknown>"
57 (void) pam_get_user(pamh, &user, "Who are you? ");
58 (void) pam_get_item(pamh, PAM_RUSER, (const void **)&ruser);
59 (void) pam_get_item(pamh, PAM_RHOST, (const void **)&rhost);
60 _pam_log(LOG_NOTICE, "user: (uid=%d) -> %s [remote: %s@%s]"
62 , user ? user : "<unknown>"
63 , ruser ? ruser : "?nobody"
64 , rhost ? rhost : "?nowhere"
67 /* we are just a fly on the wall */
73 int pam_sm_setcred(pam_handle_t *pamh,int flags,int argc
79 /* password updating functions */
82 int pam_sm_chauthtok(pam_handle_t *pamh,int flags,int argc
85 /* map to the authentication function... */
87 return pam_sm_authenticate(pamh, flags, argc, argv);
91 pam_sm_acct_mgmt (pam_handle_t *pamh, int flags,
92 int argc, const char **argv)
94 /* map to the authentication function... */
96 return pam_sm_authenticate(pamh, flags, argc, argv);
100 pam_sm_open_session (pam_handle_t *pamh, int flags, int argc,
103 /* map to the authentication function... */
105 return pam_sm_authenticate(pamh, flags, argc, argv);
109 pam_sm_close_session (pam_handle_t *pamh, int flags, int argc,
112 /* map to the authentication function... */
114 return pam_sm_authenticate(pamh, flags, argc, argv);
119 /* static module data */
121 struct pam_module _pam_warn_modstruct = {
127 pam_sm_close_session,
133 /* end of module definition */