2 * Copyright (c) 1996, 1998-2005, 2010
3 * Todd C. Miller <Todd.Miller@courtesan.com>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 * Sponsored in part by the Defense Advanced Research Projects
18 * Agency (DARPA) and Air Force Research Laboratory, Air Force
19 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
24 #include <sys/types.h>
26 #include <sys/param.h>
35 #endif /* STDC_HEADERS */
38 #endif /* HAVE_STRING_H */
41 #endif /* HAVE_STRINGS_H */
44 #endif /* HAVE_UNISTD_H */
49 #endif /* HAVE_GETSPNAM */
50 #ifdef HAVE_GETPRPWNAM
53 # include <hpsecurity.h>
55 # include <sys/security.h>
58 #endif /* HAVE_GETPRPWNAM */
60 # include <sys/label.h>
61 # include <sys/audit.h>
63 #endif /* HAVE_GETPWANAM */
64 #ifdef HAVE_GETAUTHUID
66 #endif /* HAVE_GETAUTHUID */
71 * Exported for auth/secureware.c
73 #if defined(HAVE_GETPRPWNAM) && defined(__alpha)
74 int crypt_type = INT_MAX;
75 #endif /* HAVE_GETPRPWNAM && __alpha */
78 * Return a copy of the encrypted password for the user described by pw.
79 * If shadow passwords are in use, look in the shadow file.
83 const struct passwd *pw;
87 /* If there is a function to check for shadow enabled, use it... */
90 return(estrdup(pw->pw_passwd));
91 #endif /* HAVE_ISCOMSEC */
94 return(estrdup(pw->pw_passwd));
95 #endif /* HAVE_ISSECURE */
98 #ifdef HAVE_GETPRPWNAM
100 struct pr_passwd *spw;
102 if ((spw = getprpwnam(pw->pw_name)) && spw->ufld.fd_encrypt) {
104 crypt_type = spw->ufld.fd_oldcrypt;
105 # endif /* __alpha */
106 epw = estrdup(spw->ufld.fd_encrypt);
111 #endif /* HAVE_GETPRPWNAM */
116 if ((spw = getspnam(pw->pw_name)) && spw->sp_pwdp)
117 epw = estrdup(spw->sp_pwdp);
121 #endif /* HAVE_GETSPNAM */
122 #ifdef HAVE_GETSPWUID
124 struct s_passwd *spw;
126 if ((spw = getspwuid(pw->pw_uid)) && spw->pw_passwd)
127 epw = estrdup(spw->pw_passwd);
131 #endif /* HAVE_GETSPWUID */
132 #ifdef HAVE_GETPWANAM
134 struct passwd_adjunct *spw;
136 if ((spw = getpwanam(pw->pw_name)) && spw->pwa_passwd)
137 epw = estrdup(spw->pwa_passwd);
141 #endif /* HAVE_GETPWANAM */
142 #ifdef HAVE_GETAUTHUID
146 if ((spw = getauthuid(pw->pw_uid)) && spw->a_password)
147 epw = estrdup(spw->a_password);
151 #endif /* HAVE_GETAUTHUID */
153 /* Fall back on normal password. */
154 return(estrdup(pw->pw_passwd));
160 #ifdef HAVE_GETPRPWNAM
166 #ifdef HAVE_GETSPWUID
169 #ifdef HAVE_GETPWANAM
172 #ifdef HAVE_GETAUTHUID
180 #ifdef HAVE_GETPRPWNAM
186 #ifdef HAVE_GETSPWUID
189 #ifdef HAVE_GETPWANAM
192 #ifdef HAVE_GETAUTHUID