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