]> andersk Git - openssh.git/blame - openbsd-compat/port-uw.c
- (dtucker) [README] Update release note URL to 4.2
[openssh.git] / openbsd-compat / port-uw.c
CommitLineData
4c653d8e 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
39int nischeck(char *);
40
41int
42sys_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
62int
63nischeck(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
98char *
99get_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
This page took 0.064206 seconds and 5 git commands to generate.