]> code.citadel.org Git - citadel.git/blobdiff - citadel/chkpwd.c
chkpwd is now a daemon that is started by citserver
[citadel.git] / citadel / chkpwd.c
index b96ac7392a54845d964fbd9572ffdde486864d24..a07ad18ac74d857eead2d50ed75393ce3db05f95 100644 (file)
 
 #include "auth.h"
 #include "config.h"
+#include "citadel_dirs.h"
 #include "citadel.h"
 
 int main(void)
 {
-  uid_t uid;
-  struct passwd *pw;
-  char buf[256];
-
-  get_config();
-  uid = getuid();
-
-  if (uid != BBSUID && uid)
-    {
-      pw = getpwuid(uid);
-      openlog("chkpwd", LOG_CONS, LOG_AUTH);
-      syslog(LOG_WARNING, "invoked by %s (uid %u); possible breakin/probe "
-            "attempt", pw != NULL ? pw->pw_name : "?", uid);
-      return 1;
-    }
-
-  if (fgets(buf, sizeof buf, stdin) == NULL)
-    return 1;
-
-  strtok(buf, "\n");
-  uid = atoi(buf);
-
-  if (fgets(buf, sizeof buf, stdin) == NULL)
-    return 1;
-
-  strtok(buf, "\n");
-
-  if (validpw(uid, buf))
-    return 0;
-
-  return 1;
+       uid_t uid;
+       char buf[SIZ];
+
+       while (1) {
+               read(0, buf, 16);       /* uid */
+               uid = atoi(buf);
+               read(0, buf, 256);      /* password */
+
+               if (validate_password(uid, buf)) {
+                       write(1, "PASS", 4);
+               }
+               else {
+                       write(1, "FAIL", 4);
+               }
+       }
+
+       return(0);
 }