summaryrefslogtreecommitdiffstats
path: root/driver/vms-validate.c
diff options
context:
space:
mode:
authorSimon Rettberg2018-10-16 10:08:48 +0200
committerSimon Rettberg2018-10-16 10:08:48 +0200
commitd3a98cf6cbc3bd0b9efc570f58e8812c03931c18 (patch)
treecbddf8e50f35a9c6e878a5bfe3c6d625d99e12ba /driver/vms-validate.c
downloadxscreensaver-d3a98cf6cbc3bd0b9efc570f58e8812c03931c18.tar.gz
xscreensaver-d3a98cf6cbc3bd0b9efc570f58e8812c03931c18.tar.xz
xscreensaver-d3a98cf6cbc3bd0b9efc570f58e8812c03931c18.zip
Original 5.40
Diffstat (limited to 'driver/vms-validate.c')
-rw-r--r--driver/vms-validate.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/driver/vms-validate.c b/driver/vms-validate.c
new file mode 100644
index 0000000..8f7141d
--- /dev/null
+++ b/driver/vms-validate.c
@@ -0,0 +1,75 @@
+/*
+ * validate a password for a user
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. No representations are made about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+/*
+ * Includes
+ */
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+#include "vms-pwd.h"
+int hash_vms_password(char *output_buf,char *input_buf,int input_length,
+ char *username,int encryption_type,unsigned short salt);
+
+/*
+ *
+ * Validate a VMS UserName/Password pair.
+ *
+ */
+
+int validate_user(name,password)
+char *name;
+char *password;
+{
+ char password_buf[64];
+ char username_buf[31];
+ char encrypt_buf[8];
+ register int i;
+ register char *cp,*cp1;
+ struct passwd *user_entry;
+
+ /*
+ * Get the users UAF entry
+ */
+ user_entry = getpwnam(name);
+
+ /*
+ * If user_entry == NULL then we got a bad error
+ * return -1 to indicate a bad error
+ */
+ if (user_entry == NULL) return (-1);
+
+ /*
+ * Uppercase the password
+ */
+ cp = password;
+ cp1 = password_buf;
+ while (*cp)
+ if (islower(*cp))
+ *cp1++ = toupper(*cp++);
+ else
+ *cp1++ = *cp++;
+ /*
+ * Get the length of the password
+ */
+ i = strlen(password);
+ /*
+ * Encrypt the password
+ */
+ hash_vms_password(encrypt_buf,password_buf,i,user_entry->pw_name,
+ user_entry->pw_encrypt, user_entry->pw_salt);
+ if (memcmp(encrypt_buf,user_entry->pw_passwd,8) == 0)
+ return(1);
+ else return(0);
+}
+