/*****************************************************************************\ testuser.c David Rowe 4 Jan 2010 usage: testuser user passsword Returns to the shell a 0 if username/password pair are OK, non-zero otherwise. Based on login.c \*****************************************************************************/ #include #include #include #include #include #include #include #include #include #include #ifndef __UC_LIBC__ #include #endif #ifdef OLD_CONFIG_PASSWORDS #include #endif #include #include #include #ifdef SECURITY_COUNTS #include "logcnt.c" #endif int main(int argc, char *argv[]) { char *user; char *realpwd, *gotpwd, *cpwd; char *host = NULL; int flag; struct passwd *pwp; if (argc != 3) { fprintf(stderr, "testuser username password\n"); exit(0); } pwp = getpwnam(argv[1]); cpwd = crypt(argv[2], pwp->pw_passwd); return strcmp(cpwd, pwp->pw_passwd); }