diff --git a/validate-upg.c b/validate-upg.c new file mode 100644 index 0000000..f9bacf0 --- /dev/null +++ b/validate-upg.c @@ -0,0 +1,47 @@ +/* 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.100 2005/03/03 09:28:43 tundra Exp $" + +#include +#include + + +#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); + +}