Back to index

citadel  8.12
chkpwd.c
Go to the documentation of this file.
00001 /*
00002  * a setuid helper program for machines which use shadow passwords
00003  * by Nathan Bryant, March 1999
00004  *
00005  * Copyright (c) 1987-2012 by the citadel.org team
00006  *
00007  *  This program is open source software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License version 3.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  */
00015 
00016 #include <pwd.h>
00017 #include <stdio.h>
00018 #include <limits.h>
00019 #include <stdlib.h>
00020 #include <string.h>
00021 #include <syslog.h>
00022 #include <unistd.h>
00023 #include <sys/types.h>
00024 
00025 #include "auth.h"
00026 #include "config.h"
00027 #include "citadel_dirs.h"
00028 #include "citadel.h"
00029 
00030 int main(void)
00031 {
00032        uid_t uid;
00033        char buf[SIZ];
00034 
00035        while (1) {
00036               buf[0] = '\0';
00037               read(0, &uid, sizeof(uid_t));      /* uid */
00038               read(0, buf, 256);   /* password */
00039 
00040               if (buf[0] == '\0') 
00041                      return (0);
00042               if (validate_password(uid, buf)) {
00043                      write(1, "PASS", 4);
00044               }
00045               else {
00046                      write(1, "FAIL", 4);
00047               }
00048        }
00049 
00050        return(0);
00051 }