* Allow connect on unix domain sockets to Citadels in other directories
authorArt Cancro <ajc@citadel.org>
Sun, 13 Jul 2003 04:58:35 +0000 (04:58 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 13 Jul 2003 04:58:35 +0000 (04:58 +0000)
* sendcommand now uses unix domain sockets instead of the network
* Do not allow IPGM command to run on the network -- unix domain sockets only

citadel/ChangeLog
citadel/citadel_ipc.c
citadel/citadel_ipc.h
citadel/citserver.c
citadel/sendcommand.c

index 41cdfc957a06d6e9b5cebdfd6078d4b640ca071c..f46dbf7a29ab20bc4292662cd7ce728c1931426e 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 607.20  2003/07/13 04:58:35  ajc
+ * Allow connect on unix domain sockets to Citadels in other directories
+ * sendcommand now uses unix domain sockets instead of the network
+ * Do not allow IPGM command to run on the network -- unix domain sockets only
+
  Revision 607.19  2003/07/11 22:33:02  ajc
  * Ignore comments in public_clients file
 
@@ -4848,4 +4853,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index f69d4be05f751864ab304068265daa89f0a86f2a..ebc6e1936ab233b55d32eaca1da448893861a0af 100644 (file)
@@ -1,13 +1,5 @@
 /* $Id$ */
 
-#define        UDS                     "_UDS_"
-#ifdef __CYGWIN__
-#define DEFAULT_HOST           "localhost"
-#else
-#define DEFAULT_HOST           UDS
-#endif
-#define DEFAULT_PORT           "citadel"
-
 #include "sysdep.h"
 #if TIME_WITH_SYS_TIME
 # include <sys/time.h>
@@ -2854,7 +2846,14 @@ CtdlIPC* CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf)
 
        /* If we're using a unix domain socket we can do a bunch of stuff */
        if (!strcmp(cithost, UDS)) {
-               snprintf(sockpath, sizeof sockpath, BBSDIR "/citadel.socket");
+               if (!strcasecmp(citport, DEFAULT_PORT)) {
+                       snprintf(sockpath, sizeof sockpath, "%s%s",
+                               BBSDIR, "/citadel.socket");
+               }
+               else {
+                       snprintf(sockpath, sizeof sockpath, "%s%s",
+                               citport, "/citadel.socket");
+               }
                ipc->sock = uds_connectsock(&(ipc->isLocal), sockpath);
                if (ipc->sock == -1) {
                        ifree(ipc);
index df0f90e9817c50bfdfa078bfbdd457fc9c2821c3..bbda4ff8742da15ef4ee1c0970dbb57b5b2b9054 100644 (file)
@@ -1,5 +1,13 @@
 /* $Id$ */
 
+#define        UDS                     "_UDS_"
+#ifdef __CYGWIN__
+#define DEFAULT_HOST           "localhost"
+#else
+#define DEFAULT_HOST           UDS
+#endif
+#define DEFAULT_PORT           "citadel"
+
 #include "sysdep.h"
 #ifdef HAVE_PTHREAD_H
 #include <pthread.h>
index 876c2d5c8fc58205b9639b5e514f9fd656130590..04c37ef63165bcc0bf3965e2659156a4a70d03b5 100644 (file)
@@ -761,6 +761,15 @@ void cmd_ipgm(char *argbuf)
 {
        int secret;
 
+       /* For security reasons, we do NOT allow this command to run
+        * over the network.  Local sockets only.
+        */
+       if (!CC->is_local_socket) {
+               sleep(5);
+               cprintf("%d Authentication failed.\n",ERROR);
+               return;
+       }
+
        secret = extract_int(argbuf, 0);
        if (secret == config.c_ipgm_secret) {
                CC->internal_pgm = 1;
index 599655dd7a81c9d9b7585dba9a9cb9c99719be82..8bbed185d4d128b9f9e3e86ee1f2574d5275950c 100644 (file)
@@ -110,8 +110,8 @@ void np_attach_to_server(void)
        {"sendcommand", NULL};
        int r;
 
-       strcpy(hostbuf, "localhost");
-       strcpy(portbuf, "citadel");
+       strcpy(hostbuf, UDS);   /* Only run on a unix domain socket */
+       strcpy(portbuf, ".");   /* IPGM will refuse to run on the network */
        fprintf(stderr, "Attaching to server...\n");
        ipc = CtdlIPC_new(1, args, hostbuf, portbuf);
        CtdlIPC_getline(ipc, buf);