* Re: C2 security -- help needed
1999-11-23 5:00 C2 security -- help needed Jeff A. Fitzgerald
@ 1999-11-24 5:00 ` Paul Szabo
0 siblings, 0 replies; 2+ messages in thread
From: Paul Szabo @ 1999-11-24 5:00 UTC (permalink / raw)
To: Jeff A. Fitzgerald
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 <psz@maths.usyd.edu.au>
* 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 <sia.h>
#include <siad.h>
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
^ permalink raw reply [flat|nested] 2+ messages in thread