From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,1124c52e8d92e07e X-Google-Attributes: gid1164f8,public From: Paul Szabo Subject: Re: C2 security -- help needed Date: 1999/11/24 Message-ID: <383B1E6D.41C6@maths.usyd.edu.au>#1/1 X-Deja-AN: 552265008 Content-Transfer-Encoding: 7bit References: <81esej$a6e$1@news-2.csn.net> To: "Jeff A. Fitzgerald" Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.usyd.edu.au X-Trace: metro.ucc.usyd.edu.au 943398479 562 129.78.68.1 (23 Nov 1999 23:07:59 GMT) Organization: School of Mathematics and Statistics, University of Sydney Mime-Version: 1.0 NNTP-Posting-Date: 23 Nov 1999 23:07:59 GMT Newsgroups: comp.sys.dec Jeff A. Fitzgerald wrote: > ... C2 security ... validation of an entered user id and password. > ... But getpwnam returns the "*" and not the encrypted password ... In some software, I use more-or-less the following. Hope this helps. /* * Changed by: Paul Szabo * Reason: With C2 security, getpwnam() does NOT return the encrypted * password (even though the man page suggests it does, and not * even for root). Use sia_validate_user() instead, as this * SHOULD work for both BSD (base) and C2 security setups. This * is also the 'right' routine: no crypt() needed. - Note that * with C2 security sia_validate_user() can only ever succeed * for root, normal users cannot see even their own passwords. * Be paranoid. * * Password check * Accepts: user name string * password string * argument count * argument vector * Returns: 1 if password validated, 0 otherwise */ #include #include long pwchk (char *user, char *pass, int argc, char *argv[]) { long ret = 0; struct passwd *pw = getpwnam (user); if (pw && pw->pw_uid && /* validate user and password */ pw->pw_uid > 100 && /* sanity checks (paranoia?) */ pw->pw_gid > 100 && !strcmp (pw->pw_name, user) && /* * Any good way of checking pw_dir and pw->pw_shell ?? * strlen(pw->pw_dir) > 2 && strcmp (pw->pw_dir, "/") && * !strcmp (pw->pw_shell, "/bin/csh") && */ sia_validate_user ( NULL, /* collect */ argc, argv, NULL, /* hostname */ user, NULL, /* tty */ 0, /* colinput */ NULL, /* gssapi */ pass ) ) { ret = 1; } return ret; } -- Paul Szabo - System Manager // School of Mathematics and Statistics psz@maths.usyd.edu.au // University of Sydney, NSW 2006, Australia