chkpw and chkpwd are now working
authorArt Cancro <ajc@citadel.org>
Wed, 8 Jun 2022 14:20:16 +0000 (10:20 -0400)
committerArt Cancro <ajc@citadel.org>
Wed, 8 Jun 2022 14:20:16 +0000 (10:20 -0400)
citadel/Makefile
citadel/configure
citadel/server/citserver.c
citadel/utils/auth.c
citadel/utils/chkpw.c
citadel/utils/chkpwd.c

index d6b2ba7056812753e6a36de0bac51a47c064cc92..60ee99b3044bd5a051b30eca8e07ec96f9610d9f 100644 (file)
@@ -17,7 +17,8 @@
 # config.mk is generated by ./configure
 include config.mk
 
-all: citserver setup ctdlmigrate sendcommand citmail
+all := citserver setup ctdlmigrate sendcommand citmail chkpw chkpwd
+all: $(all)
 
 citserver: server/*.c server/modules/*/*.c config.mk server/*.h
        cc ${CFLAGS} \
@@ -37,13 +38,18 @@ sendcommand: utils/sendcommand.c server/citadel_dirs.c utils/*.h server/*.h
 citmail: utils/citmail.c server/citadel_dirs.c utils/*.h server/*.h
        cc ${CFLAGS} utils/citmail.c -lcitadel -o citmail
 
+chkpw: utils/chkpw.c utils/*.h server/*.h
+       cc ${CFLAGS} utils/chkpw.c -o chkpw
+
+chkpwd: utils/chkpwd.c utils/auth.c utils/*.h server/*.h
+       cc ${CFLAGS} utils/chkpwd.c utils/auth.c -lcrypt -o chkpwd
+
 config.mk: configure
        ./configure
 
 clean:
-       rm -vf citserver
+       rm -vf $(all)
        find . -name *.o | xargs rm -vf
-       rm -vf config.mk
 
-# In conf-IG-ure, "distclean" is the same as "clean"
 distclean: clean
+       rm -vf config.mk
index bd354231fe6ce1f37190bf476dacb59e0fb4af78..86fd09822f58d6eb9b434d9ea011e1105ce68dce 100755 (executable)
@@ -30,19 +30,11 @@ do
                --ctdldir)
                        CTDLDIR=$v
                ;;
-               --with-ssl)
-                       SSL=yes
-               ;;
-               --without-ssl)
-                       SSL=no
-               ;;
                *)
                        echo $0 : unknown option $k
                        echo
                        echo Valid options are:
                        echo '  --ctdldir=DIR           Install Citadel server to DIR [/usr/local/citadel]'
-                       echo '  --with-ssl              Force build with OpenSSL support [normally autodetected]'
-                       echo '  --without-ssl           Force build without OpenSSL support [normally autodetected]'
                        exit 1
                ;;
        esac
@@ -61,27 +53,57 @@ done
 [ "$CFLAGS" = "" ]     && CFLAGS='-ggdb -Werror -Wfatal-errors -Wno-discarded-qualifiers'
 [ "$LDFLAGS" = "" ]    && LDFLAGS=''
 
+########################################################################
 # Test for OpenSSL
-[ "$SSL" != "yes" ] && [ "$SSL" != "no" ] && {
-       echo Testing for OpenSSL...
-       tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
-       tempcc=${tempfile}.c
-       cat >$tempcc <<!
+########################################################################
+echo Testing for OpenSSL...
+tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
+tempcc=${tempfile}.c
+cat >$tempcc <<!
 #include <openssl/ssl.h>
 int main(int argc, char **argv) {
        SSL_load_error_strings();
        exit(0);
 }
 !
-       SSL='no';
-       cc $tempcc -lssl -lcrypto -o $tempfile && $tempfile && SSL='yes'
-       rm -f $tempfile 2>/dev/null
-       rm -f $tempcc 2>/dev/null
-}
-echo SSL: $SSL
-[ "$SSL" = "yes" ] && {
+cc $tempcc -lssl -lcrypto -o $tempfile && $tempfile && {
        CFLAGS=${CFLAGS}' -DHAVE_OPENSSL'
        LDFLAGS=${LDFLAGS}' -lssl -lcrypto -lz'
+} || {
+       echo Citadel Server requires OpenSSL which is not present.
+       exit 2
+}
+
+
+########################################################################
+# Test for iconv
+########################################################################
+echo Testing for iconv...
+tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/configure.$$
+tempcc=${tempfile}.c
+cat >$tempcc <<!
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <iconv.h>
+int main(int argc, char **argv) {
+       size_t wow = iconv(NULL, NULL, NULL, NULL, NULL);
+       return(0);
+}
+!
+
+cc $tempcc -o $tempfile && {
+       ICONV='yes'
+       echo iconv.h is present and requires no additional libraries
+} || {
+       echo Trying again with -liconv...
+       cc $tempcc -liconv -o $tempfile && {
+               ICONV='yes'
+               LDFLAGS=${LDFLAGS}' -liconv'
+       } || {
+               echo Citadel Server requires iconv character set conversion.
+               exit 1
+       }
 }
 
 # FIXME do a real build id here
index 5c668a71c030b38183150d5ceae3f05c6974e825..ec2a1bb82333d47fc060f55670d10add358966e8 100644 (file)
@@ -73,6 +73,12 @@ void master_startup(void) {
                syslog(LOG_ERR, "citserver: failed to access and create directories");
                exit(1);
        }
+
+       syslog(LOG_DEBUG, "citserver: ctdl_message_dir is %s", ctdl_message_dir);
+       syslog(LOG_DEBUG, "citserver: ctdl_file_dir is %s", ctdl_file_dir);
+       syslog(LOG_DEBUG, "citserver: ctdl_key_dir is %s", ctdl_key_dir);
+       syslog(LOG_DEBUG, "citserver: ctdl_run_dir is %s", ctdl_run_dir);
+
        syslog(LOG_INFO, "Opening databases");
        open_databases();
 
index ead5f54b5a8f31904d8c835eaf4e077285a3d4bd..a474f1d0077c19e26e06742b402a4262737a7547 100644 (file)
@@ -1,8 +1,6 @@
 // system-level password checking for host auth mode
-// by Nathan Bryant, March 1999
-// updated by Trey van Riper, June 2005
 //
-// Copyright (c) 1999-2016 by the citadel.org team
+// Copyright (c) 1999-2022 by Nathan Bryant, Trey Van Riper, and the citadel.org team
 //
 // This program is open source software.  Use, duplication, or disclosure
 // is subject to the terms of the GNU General Public License, version 3.
 #include <string.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include <crypt.h>
 
 #include "auth.h"
-#include "sysdep.h"
+#include "../server/sysdep.h"
 
 #ifdef HAVE_GETSPNAM
 #include <shadow.h>
index 83e432fadb09a98e76af55939e924ba524b6c3e3..54289257e01188de03a528b059e4ac6d2c5026ba 100644 (file)
@@ -1,4 +1,3 @@
-// 
 // Copyright (c) 1987-2022 by the citadel.org team
 //
 // This program is open source software.  Use, duplication, or disclosure
 #include <string.h>
 #include <limits.h>
 #include <dirent.h>
+#include "../server/citadel.h"
+#include "../server/sysdep.h"
+#include "../server/citadel_dirs.h"
 
-
-#include "citadel.h"
-#include "sysdep.h"
-#include "citadel_dirs.h"
-/* These pipes are used to talk to the chkpwd daemon, which is forked during startup */
+// These pipes are used to talk to the chkpwd daemon, which is forked during startup
 int chkpwd_write_pipe[2];
 int chkpwd_read_pipe[2];
 
-/*
- * Validate a password on the host unix system by talking to the chkpwd daemon
- */
-static int validpw(uid_t uid, const char *pass)
-{
+// Validate a password on the host unix system by talking to the chkpwd daemon
+static int validpw(uid_t uid, const char *pass) {
        char buf[256];
        int rv;
 
@@ -62,9 +57,8 @@ static int validpw(uid_t uid, const char *pass)
        return 0;
 }
 
-/* 
- * Start up the chkpwd daemon so validpw() has something to talk to
- */
+
+// Start up the chkpwd daemon so validpw() has something to talk to
 void start_chkpwd_daemon(void) {
        pid_t chkpwd_pid;
        struct stat filestats;
@@ -72,8 +66,7 @@ void start_chkpwd_daemon(void) {
 
        printf("Starting chkpwd daemon for host authentication mode\n");
 
-       if ((stat(file_chkpwd, &filestats)==-1) ||
-           (filestats.st_size==0)){
+       if ((stat(file_chkpwd, &filestats)==-1) || (filestats.st_size==0)){
                printf("didn't find chkpwd daemon in %s: %s\n", file_chkpwd, strerror(errno));
                abort();
        }
@@ -103,7 +96,6 @@ void start_chkpwd_daemon(void) {
 }
 
 
-
 int main(int argc, char **argv) {
        char buf[256];
        struct passwd *p;
index 96fed66203bfa7fff7be592306d0dbd526c3cb0b..2a9c2395f45ce9ba2dd23d4430efb7ae7eee00b9 100644 (file)
@@ -1,8 +1,6 @@
-//
 // a setuid helper program for machines which use shadow passwords
-// by Nathan Bryant, March 1999
 //
-// Copyright (c) 1987-2012 by the citadel.org team
+// Copyright (c) 1987-2022 by Nathan Bryant and the citadel.org team
 //
 // This program is open source software.  Use, duplication, or disclosure
 // is subject to the terms of the GNU General Public License, version 3.
 #include <syslog.h>
 #include <unistd.h>
 #include <sys/types.h>
-
 #include <libcitadel.h>
-
 #include "auth.h"
-#include "config.h"
-#include "citadel_dirs.h"
-#include "citadel.h"
+#include "../server/config.h"
+#include "../server/citadel_dirs.h"
+#include "../server/citadel.h"
 
-int main(void)
-{
+
+int main(void) {
        uid_t uid;
        char buf[SIZ];
 
        while (1) {
                buf[0] = '\0';
-               read(0, &uid, sizeof(uid_t));   /* uid */
-               read(0, buf, 256);      /* password */
+               read(0, &uid, sizeof(uid_t));   // uid
+               read(0, buf, 256);              // password
 
-               if (buf[0] == '\0') 
+               if (buf[0] == '\0') {
                        return (0);
+               }
                if (validate_password(uid, buf)) {
                        write(1, "PASS", 4);
                }