Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: Paul Szabo <psz@maths.usyd.edu.au>
To: "Jeff A. Fitzgerald" <jeff@fitzlong.com>
Subject: Re: C2 security -- help needed
Date: 1999/11/24	[thread overview]
Message-ID: <383B1E6D.41C6@maths.usyd.edu.au> (raw)
In-Reply-To: 81esej$a6e$1@news-2.csn.net

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



      reply	other threads:[~1999-11-24  5:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-23  5:00 C2 security -- help needed Jeff A. Fitzgerald
1999-11-24  5:00 ` Paul Szabo [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox