"Fossies" - the Fresh Open Source Software Archive

Member "citadel/chkpwd.c" (5 Jun 2021, 965 Bytes) of package /linux/www/citadel.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "chkpwd.c" see the Fossies "Dox" file reference documentation.

    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.  Use, duplication, or disclosure
    8 // is subject to the terms of the GNU General Public License, version 3.
    9 // The program is distributed without any warranty, expressed or implied.
   10 
   11 #include <pwd.h>
   12 #include <stdio.h>
   13 #include <limits.h>
   14 #include <stdlib.h>
   15 #include <string.h>
   16 #include <syslog.h>
   17 #include <unistd.h>
   18 #include <sys/types.h>
   19 
   20 #include <libcitadel.h>
   21 
   22 #include "auth.h"
   23 #include "config.h"
   24 #include "citadel_dirs.h"
   25 #include "citadel.h"
   26 
   27 int main(void)
   28 {
   29     uid_t uid;
   30     char buf[SIZ];
   31 
   32     while (1) {
   33         buf[0] = '\0';
   34         read(0, &uid, sizeof(uid_t));   /* uid */
   35         read(0, buf, 256);  /* password */
   36 
   37         if (buf[0] == '\0') 
   38             return (0);
   39         if (validate_password(uid, buf)) {
   40             write(1, "PASS", 4);
   41         }
   42         else {
   43             write(1, "FAIL", 4);
   44         }
   45     }
   46 
   47     return(0);
   48 }