citadel.h is now citadel_defs.h
[citadel.git] / citadel / utils / chkpwd.c
1 // a setuid helper program for machines which use shadow passwords
2 //
3 // Copyright (c) 1987-2022 by Nathan Bryant and the citadel.org team
4 //
5 // This program is open source software.  Use, duplication, or disclosure
6 // is subject to the terms of the GNU General Public License, version 3.
7
8 #include <pwd.h>
9 #include <stdio.h>
10 #include <limits.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <syslog.h>
14 #include <unistd.h>
15 #include <sys/types.h>
16 #include <libcitadel.h>
17 #include "auth.h"
18 #include "../server/config.h"
19 #include "../server/citadel_dirs.h"
20 #include "../server/citadel_defs.h"
21
22
23 int main(void) {
24         uid_t uid;
25         char buf[SIZ];
26
27         while (1) {
28                 buf[0] = '\0';
29                 read(0, &uid, sizeof(uid_t));   // uid
30                 read(0, buf, 256);              // password
31
32                 if (buf[0] == '\0') {
33                         return (0);
34                 }
35                 if (validate_password(uid, buf)) {
36                         write(1, "PASS", 4);
37                 }
38                 else {
39                         write(1, "FAIL", 4);
40                 }
41         }
42
43         return(0);
44 }