]> code.citadel.org Git - citadel.git/commitdiff
* Bugfix for above
authorArt Cancro <ajc@citadel.org>
Thu, 8 Aug 2002 03:25:57 +0000 (03:25 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 8 Aug 2002 03:25:57 +0000 (03:25 +0000)
* Started writing some infrastructure for sub/unsub

citadel/ChangeLog
citadel/serv_listsub.c
citadel/serv_network.c
citadel/server.h

index c67074031a24a4ba7a7cad3496ab58dcd8db23d0..8637c396d08dbd6f19d12b1d6fb505ebf393f25c 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 591.84  2002/08/08 03:25:56  ajc
+ * Bugfix for above
+ * Started writing some infrastructure for sub/unsub
+
  Revision 591.83  2002/08/08 02:49:12  ajc
  * serv_network.c: retain unknown commands in netconfigs and write them back
  * techdoc/netconfigs.txt: specify commands for subscribe/unsubscribe pending
@@ -3873,4 +3877,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 45ee2cf7d3de6f7f72b731169f967f3373f18792..38bb7c834c47f282d6ca393010b27092f0747425 100644 (file)
 #endif
 
 
+/*
+ * Generate a randomizationalisticized token to use for authentication of
+ * a subscribe or unsubscribe request.
+ */
+void listsub_generate_token(char *buf) {
+       char sourcebuf[SIZ];
+
+       /* Theo, please sit down and shut up.  This key doesn't have to be
+        * tinfoil-hat secure, it just needs to be reasonably unguessable.
+        */
+       sprintf(sourcebuf, "%d%d%ld",
+               rand,
+               getpid(),
+               time(NULL)
+       );
+
+       /* Convert it to base64 so it looks cool */     
+       encode_base64(buf, sourcebuf);
+}
+
+
+
 void cmd_subs(char *cmdbuf) {
        cprintf("%d not yet implemented, dumbass...\n", ERROR);
 }
index fa1c7d1e7897f00f669708369eeed2bd7cad65df..114eed6f1f12f361b4dd56bcb02f8566f643dfb9 100644 (file)
@@ -7,6 +7,13 @@
  * Copyright (C) 2000-2002 by Art Cancro and others.
  * This code is released under the terms of the GNU General Public License.
  *
+ * ** NOTE **   A word on the S_NETCONFIGS semaphore:
+ * This is a fairly high-level type of critical section.  It ensures that no
+ * two threads work on the netconfigs files at the same time.  Since we do
+ * so many things inside these, here are the rules:
+ *  1. begin_critical_section(S_NETCONFIGS) *before* begin_ any others.
+ *  2. Do *not* perform any I/O with the client during these sections.
+ *
  */
 
 /*
@@ -372,7 +379,9 @@ void cmd_snet(char *argbuf) {
         */
        unlink(filename);
        snprintf(buf, sizeof buf, "/bin/mv %s %s", tempfilename, filename);
+       begin_critical_section(S_NETCONFIGS);
        system(buf);
+       end_critical_section(S_NETCONFIGS);
 }
 
 
@@ -688,10 +697,14 @@ void network_spoolout_room(char *room_to_spool) {
        memset(&sc, 0, sizeof(struct SpoolControl));
        assoc_file_name(filename, sizeof filename, &CC->quickroom, "netconfigs");
 
+       begin_critical_section(S_NETCONFIGS);
+       end_critical_section(S_NETCONFIGS);
+
        fp = fopen(filename, "r");
        if (fp == NULL) {
                lprintf(7, "Outbound batch processing skipped for <%s>\n",
                        CC->quickroom.QRname);
+               end_critical_section(S_NETCONFIGS);
                return;
        }
 
@@ -792,11 +805,14 @@ void network_spoolout_room(char *room_to_spool) {
                        phree(sc.ignet_push_shares);
                        sc.ignet_push_shares = nptr;
                }
-               fwrite(sc.misc, strlen(sc.misc), 1, fp);
+               if (sc.misc != NULL) {
+                       fwrite(sc.misc, strlen(sc.misc), 1, fp);
+               }
                phree(sc.misc);
 
                fclose(fp);
        }
+       end_critical_section(S_NETCONFIGS);
 
        lprintf(5, "Outbound batch processing finished for <%s>\n",
                CC->quickroom.QRname);
index 451fa64304298869bcc1613344af1e7011fc1b16..ab8d07e7bb18bb72358e4e113286b6abf9595619 100644 (file)
@@ -214,6 +214,7 @@ enum {
        S_HOUSEKEEPING,
        S_NTTLIST,
        S_DIRECTORY,
+       S_NETCONFIGS,
        MAX_SEMAPHORES
 };