* Removed references to strucmp() and struncmp(), replaced them with
authorArt Cancro <ajc@citadel.org>
Mon, 24 Apr 2000 03:36:44 +0000 (03:36 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 24 Apr 2000 03:36:44 +0000 (03:36 +0000)
  strcasecmp() and strncasecmp() as we did in the server a while ago, and
  set up the config script to figure out whether they need to be compiled
  in.  Also moved them to tools.h
* Wrote a password manager for the client

22 files changed:
citadel/ChangeLog
citadel/Makefile.in
citadel/citadel.c
citadel/citadel.h
citadel/citadel.rc
citadel/client_chat.c
citadel/client_passwords.c [new file with mode: 0644]
citadel/client_passwords.h [new file with mode: 0644]
citadel/commands.c
citadel/commands.h
citadel/configure.in
citadel/ipc.h
citadel/ipc_c_tcp.c
citadel/messages.c
citadel/rooms.c
citadel/routines.c
citadel/sendcommand.c
citadel/stats.c
citadel/tools.c
citadel/tools.h
citadel/userlist.c
citadel/whobbs.c

index 37517d1503b8332fccb3bbe7ea3668397ca9218a..501a373cd28e2272557c1361531ab7d90f66fe7a 100644 (file)
@@ -1,4 +1,11 @@
  $Log$
+ Revision 571.4  2000/04/24 03:36:43  ajc
+ * Removed references to strucmp() and struncmp(), replaced them with
+   strcasecmp() and strncasecmp() as we did in the server a while ago, and
+   set up the config script to figure out whether they need to be compiled
+   in.  Also moved them to tools.h
+ * Wrote a password manager for the client
+
  Revision 571.3  2000/04/19 03:17:10  ajc
  * Don't ever expire the Local System Configuration> room
 
@@ -1861,4 +1868,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
-
index 558ba1cb16954fb05f65c865bb0afd56e3b757bf..22f59ade51e468ffe74bee48dda6ca4fd5dff15d 100644 (file)
@@ -82,7 +82,8 @@ SOURCES=aidepost.c citadel.c citmail.c citserver.c client_chat.c commands.c \
        whobbs.c sendcommand.c mime_parser.c base64.c qpdecode.c getutline.c \
        auth.c chkpwd.c client_icq.c html.c vcard.c serv_upgrade.c \
        serv_smtp.c serv_pop3.c internet_addressing.c parsedate.c genstamp.c \
-       domain.c clientsocket.c serv_inetcfg.c serv_rwho.c serv_bio.c
+       domain.c clientsocket.c serv_inetcfg.c serv_rwho.c serv_bio.c \
+       client_passwords.c
 
 DEP_FILES=$(SOURCES:.c=.d)
 
@@ -99,10 +100,12 @@ serv_modules: $(SERV_MODULES)
 
 citadel$(EXEEXT): ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \
        routines2$(CX) messages$(CX) client_icq$(CX) \
+       client_passwords$(CX) \
        commands$(CX) client_chat$(CX) serv_info$(CX) tools$(CX) $(LIBOBJS)
        $(CC) ipc_c_tcp$(CX) citadel$(CX) rooms$(CX) routines$(CX) \
        routines2$(CX) messages$(CX) client_icq$(CX) \
        commands$(CX) client_chat$(CX) serv_info$(CX) tools$(CX) \
+       client_passwords$(CX) \
        $(LIBOBJS) $(LDFLAGS) -o citadel $(NETLIBS) $(CLIENT_PTLIBS)
 
 netpoll: netpoll.o config.o ipc_c_tcp.o tools.o $(LIBOBJS)
index 1f2347eff1a44e0689aa450646a639ba985a49c9..f9b0fc70d6e7e063bb8735fe12f6249b9fc23e7e 100644 (file)
@@ -33,6 +33,7 @@
 #include "commands.h"
 #include "ipc.h"
 #include "client_chat.h"
+#include "client_passwords.h"
 #include "client_icq.h"
 #include "citadel_decls.h"
 #include "tools.h"
@@ -84,6 +85,8 @@ char sigcaught = 0;
 char have_xterm = 0;           /* are we running on an xterm? */
 char rc_username[32];
 char rc_password[32];
+char hostbuf[256];
+char portbuf[256];
 char rc_floor_mode;
 char floor_mode;
 char curr_floor = 0;           /* number of current floor */
@@ -245,8 +248,8 @@ void remove_march(char *roomname, int floornum)
        if (march == NULL)
                return;
 
-       if ((!strucmp(march->march_name, roomname))
-           || ((!strucmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
+       if ((!strcasecmp(march->march_name, roomname))
+           || ((!strcasecmp(roomname, "_FLOOR_")) && (march->march_floor == floornum))) {
                mptr = march->next;
                free(march);
                march = mptr;
@@ -255,8 +258,8 @@ void remove_march(char *roomname, int floornum)
        mptr2 = march;
        for (mptr = march; mptr != NULL; mptr = mptr->next) {
 
-               if ((!strucmp(mptr->march_name, roomname))
-                   || ((!strucmp(roomname, "_FLOOR_"))
+               if ((!strcasecmp(mptr->march_name, roomname))
+                   || ((!strcasecmp(roomname, "_FLOOR_"))
                        && (mptr->march_floor == floornum))) {
 
                        mptr2->next = mptr->next;
@@ -359,7 +362,7 @@ void dotgoto(char *towhere, int display_name)
                                if (pattern(psearch, towhere) >= 0) {
                                        partial_match = 1;
                                }
-                               if (!struncmp(towhere, psearch, strlen(towhere))) {
+                               if (!strncasecmp(towhere, psearch, strlen(towhere))) {
                                        partial_match = 2;
                                }
                                if (partial_match > best_match) {
@@ -387,7 +390,7 @@ void dotgoto(char *towhere, int display_name)
        curr_floor = extract_int(&aaa[4], 10);
 
        remove_march(room_name, 0);
-       if (!strucmp(towhere, "_BASEROOM_"))
+       if (!strcasecmp(towhere, "_BASEROOM_"))
                remove_march(towhere, 0);
        if ((from_floor != curr_floor) && (display_name > 0) && (floor_mode == 1)) {
                if (floorlist[(int) curr_floor][0] == 0)
@@ -572,12 +575,12 @@ void gotofloor(char *towhere, int mode)
                load_floorlist();
        tofloor = (-1);
        for (a = 0; a < 128; ++a)
-               if (!strucmp(&floorlist[a][0], towhere))
+               if (!strcasecmp(&floorlist[a][0], towhere))
                        tofloor = a;
 
        if (tofloor < 0) {
                for (a = 0; a < 128; ++a) {
-                       if (!struncmp(&floorlist[a][0], towhere, strlen(towhere))) {
+                       if (!strncasecmp(&floorlist[a][0], towhere, strlen(towhere))) {
                                tofloor = a;
                        }
                }
@@ -701,11 +704,12 @@ int set_password(void)
        }
        strproc(pass1);
        strproc(pass2);
-       if (!strucmp(pass1, pass2)) {
+       if (!strcasecmp(pass1, pass2)) {
                snprintf(buf, sizeof buf, "SETP %s", pass1);
                serv_puts(buf);
                serv_gets(buf);
                printf("%s\n", &buf[4]);
+               offer_to_remember_password(hostbuf, portbuf, fullname, pass1);
                return (0);
        } else {
                printf("*** They don't match... try again.\n");
@@ -820,10 +824,11 @@ void enternew(char *desc, char *buf, int maxlen)
 int main(int argc, char **argv)
 {
        int a, b, mcmd;
-       char aaa[100], bbb[100], eee[100];      /* general purpose variables */
+       char aaa[100], bbb[100];/* general purpose variables */
        char argbuf[32];        /* command line buf */
        volatile int termn8 = 0;
-
+       int stored_password = 0;
+       char password[256];
 
        sttybbs(SB_SAVE);       /* Store the old terminal parameters */
        load_command_set();     /* parse the citadel.rc file */
@@ -836,9 +841,7 @@ int main(int argc, char **argv)
 
        printf("Attaching to server... \r");
        fflush(stdout);
-       attach_to_server(argc, argv);
-       printf("Establishing session...\r");
-       fflush(stdout);
+       attach_to_server(argc, argv, hostbuf, portbuf);
 
        send_ansi_detect();
 
@@ -863,7 +866,28 @@ int main(int argc, char **argv)
        formout("hello");       /* print the opening greeting */
        printf("\n");
 
-GSTA:  termn8 = 0;
+GSTA:  /* See if we have a username and password on disk */
+       if (rc_remember_passwords) {
+               get_stored_password(hostbuf, portbuf, fullname, password);
+               if (strlen(fullname) > 0) {
+                       sprintf(aaa, "USER %s", fullname);
+                       serv_puts(aaa);
+                       serv_gets(aaa);
+                       sprintf(aaa, "PASS %s", password);
+                       serv_puts(aaa);
+                       serv_gets(aaa);
+                       if (aaa[0] == '2') {
+                               load_user_info(&aaa[4]);
+                               stored_password = 1;
+                               goto PWOK;
+                       }
+                       else {
+                               set_stored_password(hostbuf, portbuf, "", "");
+                       }
+               }
+       }
+
+       termn8 = 0;
        newnow = 0;
        do {
                if (strlen(rc_username) > 0) {
@@ -872,15 +896,15 @@ GSTA:     termn8 = 0;
                        newprompt("Enter your name: ", fullname, 29);
                }
                strproc(fullname);
-               if (!strucmp(fullname, "new")) {        /* just in case */
+               if (!strcasecmp(fullname, "new")) {     /* just in case */
                        printf("Please enter the name you wish to log in with.\n");
                }
        } while (
-                       (!strucmp(fullname, "bbs"))
-                       || (!strucmp(fullname, "new"))
+                       (!strcasecmp(fullname, "bbs"))
+                       || (!strcasecmp(fullname, "new"))
                        || (strlen(fullname) == 0));
 
-       if (!strucmp(fullname, "off")) {
+       if (!strcasecmp(fullname, "off")) {
                mcmd = 29;
                goto TERMN8;
        }
@@ -893,16 +917,18 @@ GSTA:     termn8 = 0;
 
        /* password authentication */
        if (strlen(rc_password) > 0) {
-               strcpy(eee, rc_password);
+               strcpy(password, rc_password);
        } else {
-               newprompt("\rPlease enter your password: ", eee, -19);
+               newprompt("\rPlease enter your password: ", password, -19);
        }
-       strproc(eee);
-       snprintf(aaa, sizeof aaa, "PASS %s", eee);
+       strproc(password);
+       snprintf(aaa, sizeof aaa, "PASS %s", password);
        serv_puts(aaa);
        serv_gets(aaa);
        if (aaa[0] == '2') {
                load_user_info(&aaa[4]);
+               offer_to_remember_password(hostbuf, portbuf,
+                                       fullname, password);
                goto PWOK;
        }
        printf("<< wrong password >>\n");
@@ -910,7 +936,7 @@ GSTA:       termn8 = 0;
                logoff(0);
        goto GSTA;
 
-      NEWUSR:if (strlen(rc_password) == 0) {
+NEWUSR:        if (strlen(rc_password) == 0) {
                printf("No record. Enter as new user? ");
                if (yesno() == 0)
                        goto GSTA;
@@ -930,7 +956,7 @@ GSTA:       termn8 = 0;
        enter_config(1);
 
 
-      PWOK:printf("%s\nAccess level: %d (%s)\nUser #%ld / Call #%d\n",
+PWOK:  printf("%s\nAccess level: %d (%s)\nUser #%ld / Call #%d\n",
               fullname, axlevel, axdefs[(int) axlevel],
               usernum, timescalled);
 
index 79148db0a4853a1ccd08f1320b03f472c84f115c..a3b723dcb694ea02c5f61dabd3a2134a264ea656 100644 (file)
@@ -28,8 +28,6 @@
 #define tolower(x)     ( ((x>='A')&&(x<='Z')) ? (x+'a'-'A') : x )
 #define NEW_CONFIG
 
-#define strucmp(lstr,rstr) struncmp(lstr,rstr,32767)
-
 /* 
  * The only typedef we do is an 8-bit unsigned, for screen dimensions.
  * All other defs are done using standard C types.  The code assumes that
index 5172df6449781d56e5a454273772543c54ba3840..a7f8febee00af9b10677283f526103ad4524a920 100644 (file)
@@ -67,15 +67,18 @@ beep=1
 #
 allow_attachments=0
 
-# If you set the USERNAME variable, the value you set here will automatically
-# be passed to the "Enter your name:" prompt.
+
+# If you set REMEMBER_PASSWORDS to 1, the Citadel client will offer to
+# remember your user name and password for every Citadel server you access,
+# automatically logging in with them on subsequent visits. 
+# (DANGER: do NOT enable this for "safe" public clients!)
 #
-#username=My User Name
+remember_passwords=0
 
-# If you set the PASSWORD variable, the value you set here will automatically
-# be passed to all prompts which request a password ... including the prompt
-# which asks for a password when creating a new user.
+# Optionally, you can force the same username and password everywhere.  This
+# obviously isn't as robust as the password manager.
 #
+#username=My User Name
 #password=mypassword
 
 # If URLCMD is defined, users can hit 'U' after reading a message which
index a5a2f45898531e91b27f4d8d1f1601789d2b88c7..3aad45f43a42a2fd0c632ef52a70c7e1a05cd661 100644 (file)
@@ -173,7 +173,7 @@ RCL:            if (send_complete_line) {
                           printf("Got room %s\n", c_room);
                        }
                           
-                       if (strucmp(c_text,"NOOP")) {
+                       if (strcasecmp(c_text,"NOOP")) {
                                if (!strcmp(c_user, fullname)) {
                                        color(BRIGHT_YELLOW);
                                        }
diff --git a/citadel/client_passwords.c b/citadel/client_passwords.c
new file mode 100644 (file)
index 0000000..3d78f9b
--- /dev/null
@@ -0,0 +1,134 @@
+#include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <limits.h>
+#include <stdio.h>
+#include "tools.h"
+#include "commands.h"
+
+#define PWFILENAME "%s/.citadel.passwords"
+
+void determine_pwfilename(char *pwfile) {
+       struct passwd *p;
+
+       p = getpwuid(getuid());
+       if (p == NULL) strcpy(pwfile, "");
+       sprintf(pwfile, PWFILENAME, p->pw_dir);
+}
+
+
+/*
+ * Check the password file for a host/port match; if found, stuff the user
+ * name and password into the user/pass buffers
+ */
+void get_stored_password(
+               char *host,
+               char *port,
+               char *username,
+               char *password) {
+
+       char pwfile[PATH_MAX];
+       FILE *fp;
+       char buf[256];
+       char buf64[256];
+       char hostbuf[256], portbuf[256], ubuf[256], pbuf[256];
+
+       strcpy(username, "");
+       strcpy(password, "");
+
+       determine_pwfilename(pwfile);
+       if (strlen(pwfile)==0) return;
+
+       fp = fopen(pwfile, "r");
+       if (fp == NULL) return;
+       while (fgets(buf64, sizeof buf64, fp) != NULL) {
+               decode_base64(buf, buf64);
+               extract(hostbuf, buf, 0);
+               extract(portbuf, buf, 1);
+               extract(ubuf, buf, 2);
+               extract(pbuf, buf, 3);
+
+               if (!strcasecmp(hostbuf, host)) {
+                       if (!strcasecmp(portbuf, port)) {
+                               strcpy(username, ubuf);
+                               strcpy(password, pbuf);
+                       }
+               }
+       }
+       fclose(fp);
+}
+
+
+/*
+ * Set (or clear) stored passwords.
+ */
+void set_stored_password(
+               char *host,
+               char *port,
+               char *username,
+               char *password) {
+
+       char pwfile[PATH_MAX];
+       FILE *fp, *oldfp;
+       char buf[256];
+       char buf64[256];
+       char hostbuf[256], portbuf[256], ubuf[256], pbuf[256];
+
+       determine_pwfilename(pwfile);
+       if (strlen(pwfile)==0) return;
+
+       oldfp = fopen(pwfile, "r");
+       if (oldfp == NULL) oldfp = fopen("/dev/null", "r");
+       unlink(pwfile);
+       fp = fopen(pwfile, "w");
+       if (fp == NULL) fp = fopen("/dev/null", "w");
+       while (fgets(buf64, sizeof buf64, oldfp) != NULL) {
+               decode_base64(buf, buf64);
+               extract(hostbuf, buf, 0);
+               extract(portbuf, buf, 1);
+               extract(ubuf, buf, 2);
+               extract(pbuf, buf, 3);
+
+               if ( (strcasecmp(hostbuf, host)) 
+                  || (strcasecmp(portbuf, port)) ) {
+                       sprintf(buf, "%s|%s|%s|%s|",
+                               hostbuf, portbuf, ubuf, pbuf);
+                       encode_base64(buf64, buf);
+                       fprintf(fp, "%s\n", buf64);
+               }
+       }
+       if (strlen(username) > 0) {
+               sprintf(buf, "%s|%s|%s|%s|",
+                       host, port, username, password);
+               encode_base64(buf64, buf);
+               fprintf(fp, "%s\n", buf64);
+       }
+       fclose(oldfp);
+       fclose(fp);
+       chmod(pwfile, 0600);
+}
+
+
+/*
+ * Set the password if the user wants to, clear it otherwise 
+ */
+void offer_to_remember_password(
+               char *host,
+               char *port,
+               char *username,
+               char *password) {
+
+       if (rc_remember_passwords) {
+               if (boolprompt("Remember username/password for this site", 0)) {
+                       set_stored_password(host, port, username, password);
+               }
+               else {
+                       set_stored_password(host, port, "", "");
+               }
+       }
+}
diff --git a/citadel/client_passwords.h b/citadel/client_passwords.h
new file mode 100644 (file)
index 0000000..1945ff0
--- /dev/null
@@ -0,0 +1,16 @@
+void determine_pwfilename(char *);
+void get_stored_password(
+               char *host,
+               char *port,
+               char *username,
+               char *password);
+void set_stored_password(
+               char *host,
+               char *port,
+               char *username,
+               char *password);
+void offer_to_remember_password(
+               char *host,
+               char *port,
+               char *username,
+               char *password);
index 844a2e9b2404f3bf4cdb9852f0d5b16e8400c75e..da810085c8d351a6ec501f911e80d3c4641ccbdd 100644 (file)
@@ -59,6 +59,7 @@ char rc_exp_cmd[256];
 int rc_allow_attachments;
 int rc_display_message_numbers;
 int rc_force_mail_prompts;
+int rc_remember_passwords;
 int rc_ansi_color;
 int num_urls = 0;
 char urls[MAXURLS][256];
@@ -539,6 +540,7 @@ void load_command_set(void)
        rc_floor_mode = 0;
        rc_exp_beep = 1;
        rc_allow_attachments = 0;
+       rc_remember_passwords = 0;
        strcpy(rc_exp_cmd, "");
        rc_display_message_numbers = 0;
        rc_force_mail_prompts = 0;
@@ -570,56 +572,59 @@ void load_command_set(void)
                while ((strlen(buf) > 0) ? (isspace(buf[strlen(buf) - 1])) : 0)
                        buf[strlen(buf) - 1] = 0;
 
-               if (!struncmp(buf, "editor=", 7))
+               if (!strncasecmp(buf, "editor=", 7))
                        strcpy(editor_path, &buf[7]);
 
-               if (!struncmp(buf, "printcmd=", 9))
+               if (!strncasecmp(buf, "printcmd=", 9))
                        strcpy(printcmd, &buf[9]);
 
-               if (!struncmp(buf, "expcmd=", 7))
+               if (!strncasecmp(buf, "expcmd=", 7))
                        strcpy(rc_exp_cmd, &buf[7]);
 
-               if (!struncmp(buf, "local_screen_dimensions=", 24))
+               if (!strncasecmp(buf, "local_screen_dimensions=", 24))
                        have_xterm = (char) atoi(&buf[24]);
 
-               if (!struncmp(buf, "use_floors=", 11)) {
-                       if (!strucmp(&buf[11], "yes"))
+               if (!strncasecmp(buf, "use_floors=", 11)) {
+                       if (!strcasecmp(&buf[11], "yes"))
                                rc_floor_mode = RC_YES;
-                       if (!strucmp(&buf[11], "no"))
+                       if (!strcasecmp(&buf[11], "no"))
                                rc_floor_mode = RC_NO;
-                       if (!strucmp(&buf[11], "default"))
+                       if (!strcasecmp(&buf[11], "default"))
                                rc_floor_mode = RC_DEFAULT;
                }
-               if (!struncmp(buf, "beep=", 5)) {
+               if (!strncasecmp(buf, "beep=", 5)) {
                        rc_exp_beep = atoi(&buf[5]);
                }
-               if (!struncmp(buf, "allow_attachments=", 18)) {
+               if (!strncasecmp(buf, "allow_attachments=", 18)) {
                        rc_allow_attachments = atoi(&buf[18]);
                }
-               if (!struncmp(buf, "display_message_numbers=", 24)) {
+               if (!strncasecmp(buf, "remember_passwords=", 19)) {
+                       rc_remember_passwords = atoi(&buf[19]);
+               }
+               if (!strncasecmp(buf, "display_message_numbers=", 24)) {
                        rc_display_message_numbers = atoi(&buf[24]);
                }
-               if (!struncmp(buf, "force_mail_prompts=", 19)) {
+               if (!strncasecmp(buf, "force_mail_prompts=", 19)) {
                        rc_force_mail_prompts = atoi(&buf[19]);
                }
-               if (!struncmp(buf, "ansi_color=", 11)) {
-                       if (!struncmp(&buf[11], "on", 2))
+               if (!strncasecmp(buf, "ansi_color=", 11)) {
+                       if (!strncasecmp(&buf[11], "on", 2))
                                rc_ansi_color = 1;
-                       if (!struncmp(&buf[11], "auto", 4))
+                       if (!strncasecmp(&buf[11], "auto", 4))
                                rc_ansi_color = 2;      /* autodetect */
-                       if (!struncmp(&buf[11], "user", 4))
+                       if (!strncasecmp(&buf[11], "user", 4))
                                rc_ansi_color = 3;      /* user config */
                }
-               if (!struncmp(buf, "username=", 9))
+               if (!strncasecmp(buf, "username=", 9))
                        strcpy(rc_username, &buf[9]);
 
-               if (!struncmp(buf, "password=", 9))
+               if (!strncasecmp(buf, "password=", 9))
                        strcpy(rc_password, &buf[9]);
 
-               if (!struncmp(buf, "urlcmd=", 7))
+               if (!strncasecmp(buf, "urlcmd=", 7))
                        strcpy(rc_url_cmd, &buf[7]);
 
-               if (!struncmp(buf, "cmd=", 4)) {
+               if (!strncasecmp(buf, "cmd=", 4)) {
                        strcpy(buf, &buf[4]);
 
                        cptr = (struct citcmd *) malloc(sizeof(struct citcmd));
@@ -1059,8 +1064,8 @@ FMTA:     while ((eof_flag == 0) && (strlen(buffer) < 126)) {
                }
        }
 
-       if ( (!struncmp(buffer, "http://", 7))
-          || (!struncmp(buffer, "ftp://", 6)) ) {
+       if ( (!strncasecmp(buffer, "http://", 7))
+          || (!strncasecmp(buffer, "ftp://", 6)) ) {
                safestrncpy(urls[num_urls], buffer, 255);
                for (a=0; a<strlen(urls[num_urls]); ++a) {
                        b = urls[num_urls][a];
index 968e1980b7ce0044d1f53776918a872ec110c3fe..b6464bc96b22e51bf0815373d7b15a8ee599b83c 100644 (file)
@@ -59,3 +59,4 @@ extern int num_urls;
 extern char urls[MAXURLS][256];
 extern char rc_url_cmd[256];
 extern int lines_printed;
+extern int rc_remember_passwords;
index 8cb72a05a321f67f66fc49d3547608998294707e..c3dfbba49557a14a85d2d26920081a01bb39ff03 100644 (file)
@@ -229,7 +229,7 @@ AC_FUNC_GETPGRP
 AC_PROG_GCC_TRADITIONAL
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror)
+AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
 
 dnl Now check for pthreads -- set up variables so that the compiler will be run
 dnl with proper flags for pthread programs
index 92b8138338b624857fe19baaef9b409e0cfc0b66..d19144042eec14bfd0da9fdc201af36328122b84 100644 (file)
@@ -1,5 +1,5 @@
 /* $Id$ */
-void attach_to_server(int argc, char **argv);
+void attach_to_server(int argc, char **argv, char *hostbuf, char *portbuf);
 extern int server_is_local;
 int getsockfd(void);
 char serv_getc(void);
index a56adb2b4a3af962f878d09f353b0cd3c2d37b45..844b21f655478ec7df0f51cb253e33f049e2676e 100644 (file)
@@ -7,7 +7,7 @@
  *
  */
 
-#define        UDS                     "citadel unix domain socket type of thing"
+#define        UDS                     "_UDS_"
 
 #define DEFAULT_HOST           UDS
 #define DEFAULT_PORT           "citadel"
@@ -270,7 +270,7 @@ void serv_puts(char *buf)
 /*
  * attach to server
  */
-void attach_to_server(int argc, char **argv)
+void attach_to_server(int argc, char **argv, char *hostbuf, char *portbuf)
 {
        int a;
        char cithost[256];
@@ -316,12 +316,16 @@ void attach_to_server(int argc, char **argv)
        if (!strcmp(cithost, UDS)) {
                sprintf(sockpath, "%s/citadel.socket", BBSDIR);
                serv_sock = uds_connectsock(sockpath);
+               strcpy(hostbuf, cithost);
+               strcpy(portbuf, sockpath);
                return;
        }
 
        /* if not using a SOCKS proxy server, make the connection directly */
        if (strlen(socks4) == 0) {
                serv_sock = connectsock(cithost, citport, "tcp");
+               strcpy(hostbuf, cithost);
+               strcpy(portbuf, citport);
                return;
        }
        /* if using SOCKS, connect first to the proxy... */
index f8a67bd7dc0699cc5e8b771b6032c2a288585249..611b2b458cf02e80b54e90053e9250db0ee2b246 100644 (file)
@@ -37,7 +37,6 @@ struct cittext {
        };
 
 void sttybbs(int cmd);
-int struncmp(char *lstr, char *rstr, int len);
 int fmout(int width, FILE *fp, char pagin, int height, int starting_lp, char subst);
 int haschar(char *st, int ch);
 int checkpagin(int lp, int pagin, int height);
@@ -375,15 +374,15 @@ int read_message(long int num, char pagin) /* Read a message from the server */
                return(0);
                }
 
-       while(serv_gets(buf), struncmp(buf,"text",4)) {
-               if (!struncmp(buf,"nhdr=yes",8)) nhdr=1;
-               if (!struncmp(buf,"from=",5)) {
+       while(serv_gets(buf), strncasecmp(buf,"text",4)) {
+               if (!strncasecmp(buf,"nhdr=yes",8)) nhdr=1;
+               if (!strncasecmp(buf,"from=",5)) {
                        strcpy(from,&buf[5]);
                        }
                if (nhdr==1) buf[0]='_';
-               if (!struncmp(buf,"type=",5))
+               if (!strncasecmp(buf,"type=",5))
                        format_type=atoi(&buf[5]);
-               if ((!struncmp(buf,"msgn=",5))&&(rc_display_message_numbers)) {
+               if ((!strncasecmp(buf,"msgn=",5))&&(rc_display_message_numbers)) {
                        color(DIM_WHITE);
                        printf("[");
                        color(BRIGHT_WHITE);
@@ -391,16 +390,16 @@ int read_message(long int num, char pagin) /* Read a message from the server */
                        color(DIM_WHITE);
                        printf("] ");
                        }
-               if (!struncmp(buf,"from=",5)) {
+               if (!strncasecmp(buf,"from=",5)) {
                        color(DIM_WHITE);
                        printf("from ");
                        color(BRIGHT_CYAN);
                        printf("%s ",&buf[5]);
                        }
-               if (!struncmp(buf,"subj=",5))
+               if (!strncasecmp(buf,"subj=",5))
                        strcpy(m_subject,&buf[5]);
 
-               if (!struncmp(buf,"rfca=",5)) {
+               if (!strncasecmp(buf,"rfca=",5)) {
                        safestrncpy(rfca, &buf[5], sizeof(rfca) - 5);
                        color(DIM_WHITE);
                        printf("<");
@@ -409,8 +408,8 @@ int read_message(long int num, char pagin) /* Read a message from the server */
                        color(DIM_WHITE);
                        printf("> ");
                        }
-               if ((!struncmp(buf,"hnod=",5)) 
-                  && (strucmp(&buf[5],serv_info.serv_humannode))
+               if ((!strncasecmp(buf,"hnod=",5)) 
+                  && (strcasecmp(&buf[5],serv_info.serv_humannode))
                   && (strlen(rfca) == 0) ) {
                        color(DIM_WHITE);
                        printf("(");
@@ -419,8 +418,8 @@ int read_message(long int num, char pagin) /* Read a message from the server */
                        color(DIM_WHITE);
                        printf(") ");
                        }
-               if ((!struncmp(buf,"room=",5))
-                  && (strucmp(&buf[5],room_name)) 
+               if ((!strncasecmp(buf,"room=",5))
+                  && (strcasecmp(&buf[5],room_name)) 
                   && (strlen(rfca) == 0)) {
                        color(DIM_WHITE);
                        printf("in ");
@@ -428,11 +427,11 @@ int read_message(long int num, char pagin) /* Read a message from the server */
                        printf("%s> ",&buf[5]);
                        }
 
-               if (!struncmp(buf,"node=",5)) {
+               if (!strncasecmp(buf,"node=",5)) {
                        safestrncpy(node, &buf[5], sizeof(buf) - 5);
                        if ( (room_flags&QR_NETWORK)
-                          || ((strucmp(&buf[5],serv_info.serv_nodename)
-                          &&(strucmp(&buf[5],serv_info.serv_fqdn)))) ) 
+                          || ((strcasecmp(&buf[5],serv_info.serv_nodename)
+                          &&(strcasecmp(&buf[5],serv_info.serv_fqdn)))) ) 
                                {
                                if (strlen(rfca) == 0) {
                                        color(DIM_WHITE);
@@ -443,13 +442,13 @@ int read_message(long int num, char pagin) /* Read a message from the server */
                        }
                }
 
-               if (!struncmp(buf,"rcpt=",5)) {
+               if (!strncasecmp(buf,"rcpt=",5)) {
                        color(DIM_WHITE);
                        printf("to ");
                        color(BRIGHT_CYAN);
                        printf("%s ",&buf[5]);
                        }
-               if (!struncmp(buf,"time=",5)) {
+               if (!strncasecmp(buf,"time=",5)) {
                        fmt_date(now, atol(&buf[5]));
                        printf("%s ", now);
                        }
@@ -542,7 +541,7 @@ void replace_string(char *filename, long int startpos)
                buf[strlen(buf)] = a;
                if ( strlen(buf) >= strlen(srch_str) ) {
                        ptr=&buf[strlen(buf)-strlen(srch_str)];
-                       if (!struncmp(ptr,srch_str,strlen(srch_str))) {
+                       if (!strncasecmp(ptr,srch_str,strlen(srch_str))) {
                                strcpy(ptr,rplc_str);
                                ++substitutions;
                                }
index fcc65c3ef6310281f3bf965166111bed102bf4a8..68135fe491a6fab275b92d4bf5fdb407264c8e5f 100644 (file)
@@ -31,7 +31,6 @@ void hit_any_key(void);
 int yesno(void);
 void strprompt(char *prompt, char *str, int len);
 void newprompt(char *prompt, char *str, int len);
-int struncmp(char *lstr, char *rstr, int len);
 void dotgoto(char *towhere, int display_name);
 void serv_read(char *buf, int bytes);
 void formout(char *name);
@@ -314,9 +313,9 @@ int select_floor(int rfloor)
                        safestrncpy(floorstr,floorlist[rfloor],sizeof floorstr);
                        strprompt("Which floor",floorstr,256);
                        for (a=0; a<128; ++a) {
-                               if (!strucmp(floorstr,&floorlist[a][0]))
+                               if (!strcasecmp(floorstr,&floorlist[a][0]))
                                        newfloor = a;
-                               if ((newfloor<0)&&(!struncmp(floorstr,
+                               if ((newfloor<0)&&(!strncasecmp(floorstr,
                                        &floorlist[a][0],strlen(floorstr))))
                                                newfloor = a;
                                if ((newfloor<0)&&(pattern(&floorlist[a][0],
@@ -441,7 +440,7 @@ void editthisroom(void) {
        /* Ask about the room aide */
        do {
                strprompt("Room aide (or 'none')",raide,29);
-               if (!strucmp(raide,"none")) {
+               if (!strcasecmp(raide,"none")) {
                        strcpy(raide,"");
                        strcpy(buf,"200");
                        }
@@ -453,7 +452,7 @@ void editthisroom(void) {
                        }
                } while(buf[0]!='2');
 
-       if (!strucmp(raide,"none")) strcpy(raide,"");
+       if (!strcasecmp(raide,"none")) strcpy(raide,"");
 
 
        /* Angels and demons dancing in my head... */
@@ -1109,7 +1108,7 @@ void kill_floor(void) {
                newprompt("Delete which floor? ",buf,255);
                if (strlen(buf)==0) return;
                for (a=0; a<128; ++a)
-                       if (!strucmp(&floorlist[a][0],buf))
+                       if (!strcasecmp(&floorlist[a][0],buf))
                                floornum_to_delete = a;
                if (floornum_to_delete < 0) {
                        printf("No such floor.  Select one of:\n");
index e7c08a9a0edf13aaf6c9c87ac7724febb39571e3..8d47314ae1a2653bb9092f9cca38d01d00f9dfe6 100644 (file)
@@ -54,26 +54,9 @@ extern struct CtdlServInfo serv_info;
 extern char rc_floor_mode;
 extern int rc_ansi_color;
 
-int struncmp(char *lstr, char *rstr, int len)
-{
-       int pos = 0;
-       char lc,rc;
-       while (pos<len) {
-               lc=tolower(lstr[pos]);
-               rc=tolower(rstr[pos]);
-               if ((lc==0)&&(rc==0)) return(0);
-               if (lc<rc) return(-1);
-               if (lc>rc) return(1);
-               pos=pos+1;
-               }
-       return(0);
-       }
-
-
-
 void back(int spaces) /* Destructive backspace */
             {
-int a;
+       int a;
        for (a=1; a<=spaces; ++a) {
                putc(8,stdout); putc(32,stdout); putc(8,stdout);
                }
@@ -279,7 +262,7 @@ int pattern(char *search, char *patn)       /* Searches for patn in search string */
 {
        int a,b;
        for (a=0; a<strlen(search); ++a)
-       {       b=struncmp(&search[a],patn,strlen(patn));
+       {       b=strncasecmp(&search[a],patn,strlen(patn));
                if (b==0) return(b);
                }
        return(-1);
index 87e56037f14edb8a2c0824bfa97f101f1b35ca27..2de7706d5d509fe09587f976c702bac1ad297736 100644 (file)
@@ -86,14 +86,15 @@ void logoff(int e)
  * Connect sendcommand to the Citadel server running on this computer.
  */
 void np_attach_to_server(void) {
+       char hostbuf[256], portbuf[256];
        char buf[256];
        char portname[8];
-       char *args[] = { "sendcommand", "localhost", NULL, NULL } ;
+       char *args[] = { "sendcommand", NULL, NULL, NULL } ;
 
        fprintf(stderr, "Attaching to server...\n");
        sprintf(portname, "%d", config.c_port_number);
        args[2] = portname;
-       attach_to_server(3, args);
+       attach_to_server(3, args, hostbuf, portbuf);
        serv_gets(buf);
        fprintf(stderr, "%s\n",&buf[4]);
        sprintf(buf,"IPGM %d", config.c_ipgm_secret);
index aaf4af14193a6a851fe9456be17584d1b994191f..a5cff63402445552a2f176f51ce0167d3b6dac7a 100644 (file)
@@ -86,6 +86,7 @@ void progress(long int curr, long int max)
 
 int main(int argc, char **argv)
 {
+       char hostbuf[256], portbuf[256];
        time_t LogTime, now;
        unsigned int LogType;
        char LogName[256];
@@ -330,7 +331,7 @@ int main(int argc, char **argv)
                fakeargs[2] = malloc(64);
                sprintf(fakeargs[2], "%d", config.c_port_number);
                fakeargs[3] = NULL;
-               attach_to_server(3, fakeargs);
+               attach_to_server(3, fakeargs, hostbuf, portbuf);
                free(fakeargs[2]);
                serv_gets(buf);
                if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
index 46c895a15c97711934334d664876be6b44a84e52..5cb896c6f16da59bf3b87904e55f75324a94959b 100644 (file)
@@ -3,6 +3,7 @@
  * $Id$
  */
 
+#include "sysdep.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -19,17 +20,36 @@ static byte dtable[256];          /* base64 encode / decode table */
 
 char *safestrncpy(char *dest, const char *src, size_t n)
 {
-  if (dest == NULL || src == NULL)
-    {
-      fprintf(stderr, "safestrncpy: NULL argument\n");
-      abort();
-    }
-  strncpy(dest, src, n);
-  dest[n - 1] = 0;
-  return dest;
+       if (dest == NULL || src == NULL) {
+               fprintf(stderr, "safestrncpy: NULL argument\n");
+               abort();
+       }
+       strncpy(dest, src, n);
+       dest[n - 1] = 0;
+       return dest;
 }
 
 
+
+#ifndef HAVE_STRNCASECMP
+int strncasecmp(char *lstr, char *rstr, int len)
+{
+       int pos = 0;
+       char lc,rc;
+       while (pos<len) {
+               lc=tolower(lstr[pos]);
+               rc=tolower(rstr[pos]);
+               if ((lc==0)&&(rc==0)) return(0);
+               if (lc<rc) return(-1);
+               if (lc>rc) return(1);
+               pos=pos+1;
+       }
+       return(0);
+}
+#endif
+
+
+
 /*
  * num_tokens()  -  discover number of parameters/tokens in a string
  */
index 9def9852d1f9840e82d7ea5419f2d1a70fbbc607..6b8ea443027ae571c2d3c3bfe85f255c556307d9 100644 (file)
@@ -12,5 +12,12 @@ int collapsed_strcmp(char *s1, char *s2);
 void remove_token(char *source, int parmnum, char separator);
 void fmt_date(char *buf, time_t thetime);
 
+#ifndef HAVE_STRNCASECMP
+int strncasecmp(char *, char *, int)
+#endif
+#ifndef HAVE_STRCASECMP
+#define strcasecmp(x,y) strncasecmp(x,y,INT_MAX);
+#endif
+
 #define extract(dest,source,parmnum)   extract_token(dest,source,parmnum,'|')
 #define num_parms(source)              num_tokens(source, '|')
index 41d313b59ee92aad4e6d6eae15784954b78ecddd..91d99f1dcb8ea2c062f0cf8f14e0fc14be441dad 100644 (file)
@@ -49,8 +49,9 @@ void userlist(void) {
 int main(int argc, char **argv)
 {
        char buf[256];
+       char hostbuf[256], portbuf[256];
 
-       attach_to_server(argc,argv);
+       attach_to_server(argc, argv, hostbuf, portbuf);
        serv_gets(buf);
        if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
                fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);
index 7c9f46238c20b8dea8db84036407d1a2bda2a802..a9106eba3088df4cb8ae3a295e55c22435f7f29d 100644 (file)
@@ -42,6 +42,8 @@ int main(int argc, char **argv)
        int www = 0;
        int s_pid = 0;
        int my_pid = 0;
+       char hostbuf[256];
+       char portbuf[256];
        char s_user[256];
        char s_room[256];
        char s_host[256];
@@ -53,7 +55,7 @@ int main(int argc, char **argv)
         */     
        if (getenv("REQUEST_METHOD") != NULL) www = 1;
 
-       attach_to_server(argc,argv);
+       attach_to_server(argc,argv, hostbuf, portbuf);
        serv_gets(buf);
        if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
                fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);