4 * See end for Copyright information
7 static const char rcsid_sess[] =
9 " - PAM_PWDB session management. morgan@parc.power.net";
11 /* Define internal functions */
13 static int _unix_open_session(pam_handle_t *pamh, unsigned int ctrl)
16 char *user_name, *service;
20 retval = pam_get_item( pamh, PAM_USER, (void *) &user_name );
21 if ( user_name == NULL || retval != PAM_SUCCESS ) {
22 _log_err(LOG_CRIT, "open_session - error recovering username");
23 return PAM_SESSION_ERR;
26 retval = pam_get_item( pamh, PAM_SERVICE, (void*) &service );
27 if ( service == NULL || retval != PAM_SUCCESS ) {
28 _log_err(LOG_CRIT, "open_session - error recovering service");
29 return PAM_SESSION_ERR;
32 _log_err(LOG_INFO, "(%s) session opened for user %s by %s(uid=%d)"
34 , getlogin() == NULL ? "":getlogin(), getuid() );
39 static int _unix_close_session(pam_handle_t *pamh, unsigned int ctrl)
42 char *user_name, *service;
46 retval = pam_get_item( pamh, PAM_USER, (void*) &user_name );
47 if ( user_name == NULL || retval != PAM_SUCCESS ) {
48 _log_err(LOG_CRIT, "close_session - error recovering username");
49 return PAM_SESSION_ERR;
52 retval = pam_get_item( pamh, PAM_SERVICE, (void*) &service );
53 if ( service == NULL || retval != PAM_SUCCESS ) {
54 _log_err(LOG_CRIT, "close_session - error recovering service");
55 return PAM_SESSION_ERR;
58 _log_err(LOG_INFO, "(%s) session closed for user %s"
59 , service, user_name );
65 * Copyright (c) Alexander O. Yuriev, 1996. All rights reserved.
66 * Copyright (c) Andrew G. Morgan, 1996, <morgan@parc.power.net>
68 * Redistribution and use in source and binary forms, with or without
69 * modification, are permitted provided that the following conditions
71 * 1. Redistributions of source code must retain the above copyright
72 * notice, and the entire permission notice in its entirety,
73 * including the disclaimer of warranties.
74 * 2. Redistributions in binary form must reproduce the above copyright
75 * notice, this list of conditions and the following disclaimer in the
76 * documentation and/or other materials provided with the distribution.
77 * 3. The name of the author may not be used to endorse or promote
78 * products derived from this software without specific prior
81 * ALTERNATIVELY, this product may be distributed under the terms of
82 * the GNU Public License, in which case the provisions of the GPL are
83 * required INSTEAD OF the above restrictions. (This clause is
84 * necessary due to a potential bad interaction between the GPL and
85 * the restrictions contained in a BSD-style copyright.)
87 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
88 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
89 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
90 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
91 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
92 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
93 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
94 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
95 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
96 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
97 * OF THE POSSIBILITY OF SUCH DAMAGE.