diff options
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/Makefile.in | 4 | ||||
-rw-r--r-- | openbsd-compat/openbsd-compat.h | 3 | ||||
-rw-r--r-- | openbsd-compat/port-uw.c | 115 | ||||
-rw-r--r-- | openbsd-compat/port-uw.h | 30 | ||||
-rw-r--r-- | openbsd-compat/xcrypt.c | 4 |
5 files changed, 153 insertions, 3 deletions
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in index c6e08867c..6f5ee2845 100644 --- a/openbsd-compat/Makefile.in +++ b/openbsd-compat/Makefile.in | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: Makefile.in,v 1.34 2005/06/09 11:45:11 dtucker Exp $ | 1 | # $Id: Makefile.in,v 1.35 2005/08/26 20:15:20 tim Exp $ |
2 | 2 | ||
3 | sysconfdir=@sysconfdir@ | 3 | sysconfdir=@sysconfdir@ |
4 | piddir=@piddir@ | 4 | piddir=@piddir@ |
@@ -20,7 +20,7 @@ OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgroupl | |||
20 | 20 | ||
21 | COMPAT=bsd-arc4random.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o | 21 | COMPAT=bsd-arc4random.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-snprintf.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o |
22 | 22 | ||
23 | PORTS=port-irix.o port-aix.o | 23 | PORTS=port-irix.o port-aix.o port-uw.o |
24 | 24 | ||
25 | .c.o: | 25 | .c.o: |
26 | $(CC) $(CFLAGS) $(CPPFLAGS) -c $< | 26 | $(CC) $(CFLAGS) $(CPPFLAGS) -c $< |
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index e66f5ec55..ba68bc27e 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: openbsd-compat.h,v 1.29 2005/06/17 11:15:21 dtucker Exp $ */ | 1 | /* $Id: openbsd-compat.h,v 1.30 2005/08/26 20:15:20 tim Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. | 4 | * Copyright (c) 1999-2003 Damien Miller. All rights reserved. |
@@ -173,5 +173,6 @@ char *shadow_pw(struct passwd *pw); | |||
173 | #include "bsd-cygwin_util.h" | 173 | #include "bsd-cygwin_util.h" |
174 | #include "port-irix.h" | 174 | #include "port-irix.h" |
175 | #include "port-aix.h" | 175 | #include "port-aix.h" |
176 | #include "port-uw.h" | ||
176 | 177 | ||
177 | #endif /* _OPENBSD_COMPAT_H */ | 178 | #endif /* _OPENBSD_COMPAT_H */ |
diff --git a/openbsd-compat/port-uw.c b/openbsd-compat/port-uw.c new file mode 100644 index 000000000..cbc3f686b --- /dev/null +++ b/openbsd-compat/port-uw.c | |||
@@ -0,0 +1,115 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2005 The SCO Group. All rights reserved. | ||
3 | * Copyright (c) 2005 Tim Rice. All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | */ | ||
25 | |||
26 | #include "includes.h" | ||
27 | |||
28 | #ifdef UNIXWARE_LONG_PASSWORDS | ||
29 | #ifdef HAVE_CRYPT_H | ||
30 | #include <crypt.h> | ||
31 | #endif | ||
32 | #include "packet.h" | ||
33 | #include "buffer.h" | ||
34 | #include "log.h" | ||
35 | #include "servconf.h" | ||
36 | #include "auth.h" | ||
37 | #include "auth-options.h" | ||
38 | |||
39 | int nischeck(char *); | ||
40 | |||
41 | int | ||
42 | sys_auth_passwd(Authctxt *authctxt, const char *password) | ||
43 | { | ||
44 | struct passwd *pw = authctxt->pw; | ||
45 | char *encrypted_password; | ||
46 | char *salt; | ||
47 | |||
48 | /* Just use the supplied fake password if authctxt is invalid */ | ||
49 | char *pw_password = authctxt->valid ? shadow_pw(pw) : pw->pw_passwd; | ||
50 | |||
51 | /* Check for users with no password. */ | ||
52 | if (strcmp(pw_password, "") == 0 && strcmp(password, "") == 0) | ||
53 | return (1); | ||
54 | |||
55 | salt = (pw_password[0] && pw_password[1]) ? pw_password : "xx"; | ||
56 | if (nischeck(pw->pw_name)) | ||
57 | return(strcmp(crypt(password, salt), pw_password) == 0); | ||
58 | else | ||
59 | return(strcmp(bigcrypt(password, salt), pw_password) == 0); | ||
60 | } | ||
61 | |||
62 | int | ||
63 | nischeck(char *namep) | ||
64 | { | ||
65 | char password_file[] = "/etc/passwd"; | ||
66 | FILE *fd; | ||
67 | struct passwd *ent = NULL; | ||
68 | |||
69 | if ((fd = fopen (password_file, "r")) == NULL) { | ||
70 | /* | ||
71 | * If the passwd file has dissapeared we are in a bad state. | ||
72 | * However, returning 0 will send us back through the | ||
73 | * authentication scheme that has checked the ia database for | ||
74 | * passwords earlier. | ||
75 | */ | ||
76 | return(0); | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | * fgetpwent() only reads from password file, so we know for certain | ||
81 | * that the user is local. | ||
82 | */ | ||
83 | while (ent = fgetpwent(fd)) { | ||
84 | if (strcmp (ent->pw_name, namep) == 0) { | ||
85 | /* Local user */ | ||
86 | fclose (fd); | ||
87 | return(0); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | fclose (fd); | ||
92 | return (1); | ||
93 | } | ||
94 | |||
95 | #endif /* UNIXWARE_LONG_PASSWORDS */ | ||
96 | |||
97 | #ifdef HAVE_LIBIAF | ||
98 | char * | ||
99 | get_iaf_password(struct passwd *pw) | ||
100 | { | ||
101 | char *pw_password = NULL; | ||
102 | |||
103 | uinfo_t uinfo; | ||
104 | if (!ia_openinfo(pw->pw_name,&uinfo)) { | ||
105 | ia_get_logpwd(uinfo, &pw_password); | ||
106 | if (pw_password == NULL) | ||
107 | fatal("Unable to get the shadow passwd"); | ||
108 | ia_closeinfo(uinfo); | ||
109 | return pw_password; | ||
110 | } | ||
111 | else | ||
112 | fatal("Unable to open the shadow passwd file"); | ||
113 | } | ||
114 | #endif /* HAVE_LIBIAF */ | ||
115 | |||
diff --git a/openbsd-compat/port-uw.h b/openbsd-compat/port-uw.h new file mode 100644 index 000000000..f16bb5e5c --- /dev/null +++ b/openbsd-compat/port-uw.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2005 Tim Rice. All rights reserved. | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * 1. Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * 2. Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * | ||
13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
14 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
15 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
16 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
17 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
18 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
19 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
20 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | |||
25 | #include "includes.h" | ||
26 | |||
27 | #ifdef HAVE_LIBIAF | ||
28 | char * get_iaf_password(struct passwd *pw); | ||
29 | #endif /* HAVE_LIBIAF */ | ||
30 | |||
diff --git a/openbsd-compat/xcrypt.c b/openbsd-compat/xcrypt.c index c3cea3c86..453203270 100644 --- a/openbsd-compat/xcrypt.c +++ b/openbsd-compat/xcrypt.c | |||
@@ -91,7 +91,11 @@ shadow_pw(struct passwd *pw) | |||
91 | struct spwd *spw = getspnam(pw->pw_name); | 91 | struct spwd *spw = getspnam(pw->pw_name); |
92 | 92 | ||
93 | if (spw != NULL) | 93 | if (spw != NULL) |
94 | #ifdef HAVE_LIBIAF | ||
95 | pw_password = get_iaf_password(pw); | ||
96 | #else | ||
94 | pw_password = spw->sp_pwdp; | 97 | pw_password = spw->sp_pwdp; |
98 | #endif /* HAVE_LIBIAF */ | ||
95 | # endif | 99 | # endif |
96 | # if defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW) | 100 | # if defined(HAVE_GETPWANAM) && !defined(DISABLE_SHADOW) |
97 | struct passwd_adjunct *spw; | 101 | struct passwd_adjunct *spw; |