]> granicus.if.org Git - linux-pam/blob - modules/pam_pwdb/pam_unix_auth.-c
Initial revision
[linux-pam] / modules / pam_pwdb / pam_unix_auth.-c
1 /*
2  * $Id$
3  * 
4  * See end of file for Copyright information.
5  */
6
7 static const char rcsid_auth[] =
8 "$Id$: pam_unix_auth.-c,v 1.2 1996/09/05 06:46:53 morgan Exp morgan $\n"
9 " - PAM_PWDB authentication functions. <morgan@parc.power.net>";
10
11 /*
12  * _unix_auth() is a front-end for UNIX/shadow authentication
13  *
14  *      First, obtain the password from the user. Then use a
15  *      routine in 'support.-c' to authenticate the user.
16  */
17
18 #define _UNIX_AUTHTOK  "-UN*X-PASS"
19
20 static int _unix_auth(pam_handle_t *pamh, unsigned int ctrl)
21 {
22     int retval;
23     const char *name, *p;
24
25     D(("called."));
26
27     /* get the user'name' */
28
29     retval = _unix_get_user(pamh, ctrl, NULL, &name);
30     if (retval != PAM_SUCCESS ) {
31         if (retval != PAM_CONV_AGAIN) {
32             if ( on(UNIX_DEBUG,ctrl) ) {
33                 _log_err(LOG_DEBUG, "auth could not identify user");
34             }
35         } else {
36             D(("pam_get_user/conv() function is not ready yet"));
37             /* it is safe to resume this function so we translate this
38                retval to the value that indicates we're happy to resume. */
39             retval = PAM_INCOMPLETE;
40         }
41         return retval;
42     }
43
44     /* if this user does not have a password... */
45
46     if ( _unix_blankpasswd(ctrl, name) ) {
47         D(("user '%s' has blank passwd", name));
48         name = NULL;
49         return PAM_SUCCESS;
50     }
51
52     /* get this user's authentication token */
53
54     retval = _unix_read_password(pamh, ctrl, NULL, "Password: ", NULL
55                                  , _UNIX_AUTHTOK, &p);
56     if (retval != PAM_SUCCESS) {
57         if (retval != PAM_CONV_AGAIN) {
58             _log_err(LOG_CRIT, "auth could not identify password for [%s]"
59                      , name);
60         } else {
61             D(("conversation function is not ready yet"));
62             /* it is safe to resume this function so we translate this
63                retval to the value that indicates we're happy to resume. */
64             retval = PAM_INCOMPLETE;
65         }
66         name = NULL;
67         return retval;
68     }
69     D(("user=%s, password=[%s]", name, p));
70
71     /* verify the password of this user */
72     retval = _unix_verify_password(pamh, name, p, ctrl);
73     name = p = NULL;
74
75     D(("done [%d]", retval));
76
77     return retval;
78 }
79
80 /*
81  * This function is for setting unix credentials. Sun has indicated
82  * that there are *NO* authentication credentials for unix. The
83  * obvious credentials would be the group membership of the user as
84  * listed in the /etc/group file. However, Sun indicates that it is
85  * the responsibility of the application to set these.
86  */
87
88 static int _unix_set_credentials(pam_handle_t *pamh, unsigned int ctrl)
89 {
90     D(("called <empty function> returning."));
91
92     return PAM_SUCCESS;
93 }
94
95 /********************************************************************
96  * Copyright (c) Alexander O. Yuriev, 1996.
97  * Copyright (c) Andrew G. Morgan <morgan@parc.power.net> 1996
98  * Copyright (c) Cristian Gafton <gafton@redhat.com> 1996, 1997
99  *
100  * Redistribution and use in source and binary forms, with or without
101  * modification, are permitted provided that the following conditions
102  * are met:
103  * 1. Redistributions of source code must retain the above copyright
104  *    notice, and the entire permission notice in its entirety,
105  *    including the disclaimer of warranties.
106  * 2. Redistributions in binary form must reproduce the above copyright
107  *    notice, this list of conditions and the following disclaimer in the
108  *    documentation and/or other materials provided with the distribution.
109  * 3. The name of the author may not be used to endorse or promote
110  *    products derived from this software without specific prior
111  *    written permission.
112  * 
113  * ALTERNATIVELY, this product may be distributed under the terms of
114  * the GNU Public License, in which case the provisions of the GPL are
115  * required INSTEAD OF the above restrictions.  (This clause is
116  * necessary due to a potential bad interaction between the GPL and
117  * the restrictions contained in a BSD-style copyright.)
118  * 
119  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
120  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
121  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
122  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
123  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
124  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
125  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
126  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
127  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
128  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
129  * OF THE POSSIBILITY OF SUCH DAMAGE.
130  */
131