TDAP: add facility to protect usetable entries from being deleted while still needed.
[citadel.git] / citadel / utils / chkpwd.c
1 /*
2  * a setuid helper program for machines which use shadow passwords
3  * by Nathan Bryant, March 1999
4  *
5  * Copyright (c) 1987-2012 by the citadel.org team
6  *
7  *  This program is open source software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 3.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  */
15
16 #include <pwd.h>
17 #include <stdio.h>
18 #include <limits.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <syslog.h>
22 #include <unistd.h>
23 #include <sys/types.h>
24
25 #include <libcitadel.h>
26
27 #include "auth.h"
28 #include "config.h"
29 #include "citadel_dirs.h"
30 #include "citadel.h"
31
32 int main(void)
33 {
34         uid_t uid;
35         char buf[SIZ];
36
37         while (1) {
38                 buf[0] = '\0';
39                 read(0, &uid, sizeof(uid_t));   /* uid */
40                 read(0, buf, 256);      /* password */
41
42                 if (buf[0] == '\0') 
43                         return (0);
44                 if (validate_password(uid, buf)) {
45                         write(1, "PASS", 4);
46                 }
47                 else {
48                         write(1, "FAIL", 4);
49                 }
50         }
51
52         return(0);
53 }