http://se.aminet.net/pub/X11/ftp.x.org/contrib/vms/xscreensaver-124.zip
[xscreensaver] / driver / validate.c
1 \ 2\0/*!\0 *        validate a password for a user\0\ 3\0 */\0\0\0\ 2\0/*\v\0 * Includes\0\ 3\0 */\0\12\0#include <stdio.h>\12\0#include <ctype.h>\10\0#include "pwd.h"\0\0\0\0\ 2\0/*\ 2\0 *)\0 *       Validate a VMS UserName/Password pair.\0\ 2\0 *\ 3\0 */\0\0\0 \0int validate_user(name,password)\v\0char *name;\0\ f\0char *password;\0\ 1\0{\0\17\0     char password_buf[64];\0\17\0       char username_buf[31];\0\15\0       char encrypt_buf[8];\0\10\0 register int i;\18\0       register char *cp,*cp1;\e\0       struct passwd *user_entry;\0\0\0\ 3\0 /*\0\e\0    *      Get the users UAF entry\0\ 4\0       */\1d\0   user_entry = getpwnam(name);\0\0\0\ 3\0       /*\01\0    *      If user_entry == NULL then we got a bad error\0%\0         *      return -1 to indicate a bad error\0\ 4\0     */%\0   if (user_entry == NULL) return (-1);\0\0\0\ 3\0       /*\0\1a\0    *      Uppercase the password\ 4\0         */\ f\0   cp = password;\0\14\0       cp1 = password_buf;\f\0   while (*cp)\15\0      if (islower(*cp))\0\1a\0         *cp1++ = toupper(*cp++);\b\0         else\11\0               *cp1++ = *cp++;\0\ 3\0      /*\0"\0    *      Get the length of the password\ 4\0         */\16\0   i = strlen(password);\ 3\0 /*\0\18\0    *      Encrypt the password\ 4\0   */B\0   hash_vms_password(encrypt_buf,password_buf,i,user_entry->pw_name,2\0                       user_entry->pw_encrypt, user_entry->pw_salt);4\0       if (bcmp(encrypt_buf,user_entry->pw_passwd,8) == 0)\f\0           return(1);\10\0    else    return(0);\ 1\0}\0\0\0