chkpwd is now a daemon that is started by citserver
[citadel.git] / citadel / chkpwd.c
1 /*
2  * $Id$
3  *
4  * a setuid helper program for machines which use shadow passwords
5  * by Nathan Bryant, March 1999
6  *
7  */
8
9 #include <pwd.h>
10 #include <stdio.h>
11 #include <limits.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <syslog.h>
15 #include <unistd.h>
16 #include <sys/types.h>
17
18 #include "auth.h"
19 #include "config.h"
20 #include "citadel_dirs.h"
21 #include "citadel.h"
22
23 int main(void)
24 {
25         uid_t uid;
26         char buf[SIZ];
27
28         while (1) {
29                 read(0, buf, 16);       /* uid */
30                 uid = atoi(buf);
31                 read(0, buf, 256);      /* password */
32
33                 if (validate_password(uid, buf)) {
34                         write(1, "PASS", 4);
35                 }
36                 else {
37                         write(1, "FAIL", 4);
38                 }
39         }
40
41         return(0);
42 }