Newer
Older
validate-upg / validate-upg.c
/* Validate A User Name, Password, And Group
   Copyright (c) 2005, TundraWare Inc., Des Plaines IL
   All Rights Reserved

   usage:    validate name password group
   returns:  Empty string if tuple OK, Error string otherwise.
*/


static const char copyright[] = "Copyright (c) 2005, TundraWare Inc.\nAll Rights Reserved";
static const char rcsid[]     = "$Id: validate-upg.c,v 1.101 2005/03/03 09:30:23 tundra Exp $";

#include <sys/types.h>
#include <pwd.h>


#define GOOD  ""
#define BAD   "Invalid Name, Password, Or Group"

int
main(int argc, char *argv[])
{
    char *name, *pw, *name2ck, *pw2ck, *group2ck, *retval;
    gid_t group;
    struct passwd *pwrecord;

    name2ck  = argv[1];
    pw2ck    = argv[2];
    group2ck = argv[3];

    retval = BAD;

    pwrecord = getpwnam(name2ck);
  

    if (pwrecord)
      {
	name  = pwrecord->pw_name;
	pw    = pwrecord->pw_passwd;
	group = pwrecord->pw_gid;
	printf("%s %s %d\n", name, pw, group);
	retval = GOOD;
      }

    printf("%s\n", retval);

}