~ubuntu-branches/ubuntu/breezy/pam/breezy

« back to all changes in this revision

Viewing changes to Linux-PAM/modules/pam_pwdb/pam_unix_sess.-c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2004-06-28 14:28:08 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040628142808-adikk7vtfg3pzcjw
Tags: 0.76-22
* Add uploaders
* Document location of repository
* Fix options containing arguments in pam_unix, Closes: #254904

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: pam_unix_sess.-c,v 1.1 2001/04/29 04:17:29 hartmans Exp $
 
3
 *
 
4
 * See end for Copyright information
 
5
 */
 
6
 
 
7
static const char rcsid_sess[] =
 
8
"$Id: pam_unix_sess.-c,v 1.1 2001/04/29 04:17:29 hartmans Exp $\n"
 
9
" - PAM_PWDB session management. morgan@parc.power.net";
 
10
 
 
11
/* Define internal functions */
 
12
 
 
13
static int _unix_open_session(pam_handle_t *pamh, unsigned int ctrl)
 
14
{
 
15
     int retval;
 
16
     char *user_name, *service;
 
17
 
 
18
     D(("called."));
 
19
 
 
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;
 
24
     }
 
25
        
 
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;
 
30
     }
 
31
 
 
32
     _log_err(LOG_INFO, "(%s) session opened for user %s by %s(uid=%d)"
 
33
              , service, user_name
 
34
              , getlogin() == NULL ? "":getlogin(), getuid() );
 
35
 
 
36
     return PAM_SUCCESS;
 
37
}
 
38
 
 
39
static int _unix_close_session(pam_handle_t *pamh, unsigned int ctrl)
 
40
{
 
41
     int retval;
 
42
     char *user_name, *service;
 
43
 
 
44
     D(("called."));
 
45
 
 
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;
 
50
     }
 
51
 
 
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;
 
56
     }
 
57
 
 
58
     _log_err(LOG_INFO, "(%s) session closed for user %s"
 
59
              , service, user_name );
 
60
                
 
61
     return PAM_SUCCESS;
 
62
}
 
63
 
 
64
/*
 
65
 * Copyright (c) Alexander O. Yuriev, 1996.  All rights reserved.
 
66
 * Copyright (c) Andrew G. Morgan, 1996, <morgan@parc.power.net>
 
67
 *
 
68
 * Redistribution and use in source and binary forms, with or without
 
69
 * modification, are permitted provided that the following conditions
 
70
 * are met:
 
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
 
79
 *    written permission.
 
80
 * 
 
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.)
 
86
 * 
 
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.
 
98
 */