summaryrefslogtreecommitdiff
path: root/usr.sbin/popa3d/auth_passwd.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-08-19 13:05:58 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-08-19 13:05:58 +0000
commita6a38350f779ddf3a6febf67dda7714fe368e492 (patch)
treeb8ffbc248c20776618b1d6aa93ec16abb19e78d1 /usr.sbin/popa3d/auth_passwd.c
parent580e400b41d341c2ad1bfe153d5ca6553351703a (diff)
libexec is the wrong place for popa3d, since it can be started WITHOUT inetd
Diffstat (limited to 'usr.sbin/popa3d/auth_passwd.c')
-rw-r--r--usr.sbin/popa3d/auth_passwd.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/usr.sbin/popa3d/auth_passwd.c b/usr.sbin/popa3d/auth_passwd.c
new file mode 100644
index 00000000000..924fc03981d
--- /dev/null
+++ b/usr.sbin/popa3d/auth_passwd.c
@@ -0,0 +1,41 @@
+/* $OpenBSD: auth_passwd.c,v 1.1 2001/08/19 13:05:57 deraadt Exp $ */
+
+/*
+ * The /etc/passwd authentication routine.
+ */
+
+#include "params.h"
+
+#if AUTH_PASSWD && !VIRTUAL_ONLY
+
+#define _XOPEN_SOURCE
+#define _XOPEN_SOURCE_EXTENDED
+#define _XOPEN_VERSION 4
+#define _XPG4_2
+#include <unistd.h>
+#include <string.h>
+#include <pwd.h>
+#include <sys/types.h>
+
+struct passwd *auth_userpass(char *user, char *pass, char **mailbox)
+{
+ struct passwd *pw, *result;
+
+ if ((pw = getpwnam(user))) *mailbox = user;
+ endpwent();
+ result = NULL;
+
+ if (!pw || !*pw->pw_passwd ||
+ *pw->pw_passwd == '*' || *pw->pw_passwd == '!')
+ crypt(pass, AUTH_DUMMY_SALT);
+ else
+ if (!strcmp(crypt(pass, pw->pw_passwd), pw->pw_passwd))
+ result = pw;
+
+ if (pw)
+ memset(pw->pw_passwd, 0, strlen(pw->pw_passwd));
+
+ return result;
+}
+
+#endif