2 Copyright (c) 1995-1998 by Cisco systems, Inc.
4 Permission to use, copy, modify, and distribute this software for
5 any purpose and without fee is hereby granted, provided that this
6 copyright and permission notice appear on all copies of the
7 software and supporting documentation, the name of Cisco Systems,
8 Inc. not be used in advertising or publicity pertaining to
9 distribution of the program without specific prior permission, and
10 notice be given in supporting documentation that modification,
11 copying and distribution is by permission of Cisco Systems, Inc.
13 Cisco Systems, Inc. makes no representations about the suitability
14 of this software for any purpose. THIS SOFTWARE IS PROVIDED ``AS
15 IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
16 WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 FITNESS FOR A PARTICULAR PURPOSE.
20 /* Tacacs+ password lookup routine for those systems which don't have
21 setpwfile. Not for use on /etc/passwd files */
27 static struct passwd pw_passwd;
30 tac_passwd_lookup(name, file)
33 FILE *passwd_fp = NULL;
35 static char uname[512];
36 static char password[1024];
37 static char gecos[1024];
38 static char homedir[1024];
39 static char shell[1024];
43 passwd_fp = fopen(file, "r");
46 if (debug & DEBUG_PASSWD_FLAG)
47 report(LOG_DEBUG, "tac_passwd_lookup: open %s %d",
48 file, fileno(passwd_fp));
50 report(LOG_ERR, "tac_passwd_lookup: cannot open file %s for reading",
55 while (fgets(buf, sizeof(buf), passwd_fp)) {
57 /* uname, password, uid, gid, gecos, homedir, shell */
64 strncpy(uname, s, e - s);
68 if (strcmp(uname, name))
76 strncpy(password, s, e - s);
77 password[e - s] = '\0';
84 pw_passwd.pw_uid = atoi(s);
88 pw_passwd.pw_gid = atoi(s);
95 strncpy(gecos, s, e - s);
103 strncpy(homedir, s, e - s);
104 homedir[e - s] = '\0';
111 strncpy(shell, s, e - s);
114 pw_passwd.pw_name = uname;
115 pw_passwd.pw_passwd = password;
117 pw_passwd.pw_age = NULL;
118 pw_passwd.pw_comment = NULL;
119 #endif /* NO_PWAGE */
120 pw_passwd.pw_gecos = gecos;
121 pw_passwd.pw_dir = homedir;
122 pw_passwd.pw_shell = shell;
124 if (debug & DEBUG_PASSWD_FLAG)
125 report(LOG_DEBUG, "tac_passwd_lookup: close %s %d",
126 file, fileno(passwd_fp));
132 if (debug & DEBUG_PASSWD_FLAG)
133 report(LOG_DEBUG, "tac_passwd_lookup: close %s %d",
134 file, fileno(passwd_fp));