$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
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
#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);
}
* 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.
+ *
*/
/*
*/
unlink(filename);
snprintf(buf, sizeof buf, "/bin/mv %s %s", tempfilename, filename);
+ begin_critical_section(S_NETCONFIGS);
system(buf);
+ end_critical_section(S_NETCONFIGS);
}
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;
}
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);