From: Wilfried Goesgens Date: Sat, 21 Jan 2012 22:14:43 +0000 (+0100) Subject: Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel X-Git-Tag: v8.11~229 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=1965fe005619a4a759f23253408cfc3ec9a3ebd2;hp=51df62c4732353701b6e7ef05ba586be054fa92d Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel --- diff --git a/citadel/modules/network/netspool.h b/citadel/modules/network/netspool.h index fd2b3c209..7e26e28af 100644 --- a/citadel/modules/network/netspool.h +++ b/citadel/modules/network/netspool.h @@ -27,7 +27,7 @@ struct SpoolControl { void network_spoolout_room(char *room_to_spool, char *working_ignetcfg, NetMap *the_netmap); -void network_do_spoolin(char *working_ignetcfg, NetMap *the_netmap, int *netmap_changed); +void network_do_spoolin(char *working_ignetcfg, NetMap **the_netmap, int *netmap_changed); void network_consolidate_spoolout(char *working_ignetcfg, NetMap *the_netmap); void free_spoolcontrol_struct(SpoolControl **scc); int writenfree_spoolcontrol_file(SpoolControl **scc, char *filename); diff --git a/citadel/modules/network/serv_netmail.c b/citadel/modules/network/serv_netmail.c index 6d8d435be..709877a64 100644 --- a/citadel/modules/network/serv_netmail.c +++ b/citadel/modules/network/serv_netmail.c @@ -447,7 +447,7 @@ void network_spool_msg(long msgnum, FreeStrBuf(&CC->redirect_buffer); sc->num_msgs_spooled += 1; - free(msg); + CtdlFreeMessage(msg); } } diff --git a/citadel/modules/network/serv_netspool.c b/citadel/modules/network/serv_netspool.c index 5dd1eafb2..fbd0eb0e5 100644 --- a/citadel/modules/network/serv_netspool.c +++ b/citadel/modules/network/serv_netspool.c @@ -95,14 +95,14 @@ /* * Learn topology from path fields */ -void network_learn_topology(char *node, char *path, NetMap *the_netmap, int *netmap_changed) { +void network_learn_topology(char *node, char *path, NetMap **the_netmap, int *netmap_changed) { char nexthop[256]; NetMap *nmptr; - strcpy(nexthop, ""); + *nexthop = '\0'; if (num_tokens(path, '!') < 3) return; - for (nmptr = the_netmap; nmptr != NULL; nmptr = nmptr->next) { + for (nmptr = *the_netmap; nmptr != NULL; nmptr = nmptr->next) { if (!strcasecmp(nmptr->nodename, node)) { extract_token(nmptr->nexthop, path, 0, '!', sizeof nmptr->nexthop); nmptr->lastcontact = time(NULL); @@ -116,8 +116,8 @@ void network_learn_topology(char *node, char *path, NetMap *the_netmap, int *net strcpy(nmptr->nodename, node); nmptr->lastcontact = time(NULL); extract_token(nmptr->nexthop, path, 0, '!', sizeof nmptr->nexthop); - nmptr->next = the_netmap; - the_netmap = nmptr; + nmptr->next = *the_netmap; + the_netmap = &nmptr; (*netmap_changed) ++; } @@ -451,7 +451,7 @@ void network_spoolout_room(char *room_to_spool, * Process a buffer containing a single message from a single file * from the inbound queue */ -void network_process_buffer(char *buffer, long size, char *working_ignetcfg, NetMap *the_netmap, int *netmap_changed) +void network_process_buffer(char *buffer, long size, char *working_ignetcfg, NetMap **the_netmap, int *netmap_changed) { struct CtdlMessage *msg = NULL; long pos; @@ -503,7 +503,7 @@ void network_process_buffer(char *buffer, long size, char *working_ignetcfg, Net NULL, msg->cm_fields['D'], working_ignetcfg, - the_netmap) == 0) + *the_netmap) == 0) { /* prepend our node to the path */ if (msg->cm_fields['P'] != NULL) { @@ -635,7 +635,7 @@ void network_process_message(FILE *fp, long msgstart, long msgend, char *working_ignetcfg, - NetMap *the_netmap, + NetMap **the_netmap, int *netmap_changed) { long hold_pos; @@ -666,7 +666,7 @@ void network_process_message(FILE *fp, */ void network_process_file(char *filename, char *working_ignetcfg, - NetMap *the_netmap, + NetMap **the_netmap, int *netmap_changed) { FILE *fp; @@ -723,7 +723,7 @@ void network_process_file(char *filename, /* * Process anything in the inbound queue */ -void network_do_spoolin(char *working_ignetcfg, NetMap *the_netmap, int *netmap_changed) +void network_do_spoolin(char *working_ignetcfg, NetMap **the_netmap, int *netmap_changed) { DIR *dp; struct dirent *d; diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index b3d19e31d..7062a15f5 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -481,7 +481,7 @@ void network_do_queue(void) { /* If there is anything in the inbound queue, process it */ if (!server_shutting_down) { network_do_spoolin(working_ignetcfg, - the_netmap, + &the_netmap, &netmap_changed); } diff --git a/citadel/utils/setup.c b/citadel/utils/setup.c index bf6ea9634..326564bcd 100644 --- a/citadel/utils/setup.c +++ b/citadel/utils/setup.c @@ -105,10 +105,6 @@ char admin_cmd[SIZ]; const char *setup_titles[eMaxQuestions]; const char *setup_text[eMaxQuestions]; -/* calculate all our path on a central place */ -/* where to keep our config */ - - void SetTitles(void) { @@ -161,7 +157,7 @@ void SetTitles(void) setup_text[eUID] = _( "Citadel needs to run under its own user ID. This would\n" "typically be called \"citadel\", but if you are running Citadel\n" -"as a public BBS, you might also call it \"bbs\" or \"guest\".\n" +"as a public site, you might also call it \"bbs\" or \"guest\".\n" "The server will run under this user ID. Please specify that\n" "user ID here. You may specify either a user name or a numeric\n" "UID.\n"); @@ -249,7 +245,7 @@ void SetTitles(void) } /* - * print the actual stack frame. + * Print the stack frame for a backtrace */ void cit_backtrace(void) { @@ -271,7 +267,6 @@ void cit_backtrace(void) } struct config config; - int direction; @@ -382,9 +377,7 @@ void display_error(char *error_message_format, ...) Msg = NewStrBuf(); va_start(arg_ptr, error_message_format); - StrBufVAppendPrintf(Msg, - error_message_format, - arg_ptr); + StrBufVAppendPrintf(Msg, error_message_format, arg_ptr); va_end(arg_ptr); important_message(_("Error"), ChrPtr(Msg)); @@ -499,11 +492,7 @@ void delete_inittab_entry(void) int rv; /* Determine the fully qualified path name of citserver */ - snprintf(looking_for, - sizeof looking_for, - "%s/citserver", - ctdl_sbin_dir - ); + snprintf(looking_for, sizeof looking_for, "%s/citserver", ctdl_sbin_dir); /* Now tweak /etc/inittab */ infp = fopen("/etc/inittab", "r"); @@ -546,9 +535,7 @@ void delete_inittab_entry(void) rv = fwrite(buf, strlen(buf), 1, outfp); if (rv == -1) { - display_error("%s %s\n", - _("failed to modify inittab"), - strerror(errno)); + display_error("%s %s\n", _("failed to modify inittab"), strerror(errno)); } } @@ -577,14 +564,17 @@ void install_init_scripts(void) char command[SIZ]; int rv; - if ((stat("/etc/init.d/", &etcinitd) == -1) && - (errno == ENOENT)) - { - if ((stat("/etc/rc.d/init.d/", &etcinitd) == -1) && - (errno == ENOENT)) + if ( (stat("/etc/init.d/", &etcinitd) == -1) + && (errno == ENOENT) + ) { + if ( (stat("/etc/rc.d/init.d/", &etcinitd) == -1) + && (errno == ENOENT) + ) { initfile = CTDLDIR"/citadel.init"; - else + } + else { initfile = "/etc/rc.d/init.d/citadel"; + } } fp = fopen(initfile, "r"); @@ -665,18 +655,21 @@ void install_init_scripts(void) /* Set up the run levels. */ rv = system("/bin/rm -f /etc/rc?.d/[SK]??citadel 2>/dev/null"); - if (rv != 0) - display_error(_("failed to remove system V init links \n")); + if (rv != 0) { + display_error(_("failed to remove system V init links\n")); + } snprintf(command, sizeof(command), "for x in 2 3 4 5 ; do [ -d /etc/rc$x.d ] && ln -s %s /etc/rc$x.d/S79citadel ; done 2>/dev/null", initfile); rv = system(command); - if (rv != 0) - display_error(_("failed to set system V init links \n")); + if (rv != 0) { + display_error(_("failed to set system V init links\n")); + } snprintf(command, sizeof(command),"for x in 0 6 S; do [ -d /etc/rc$x.d ] && ln -s %s /etc/rc$x.d/K30citadel ; done 2>/dev/null", initfile); rv = system(command); - if (rv != 0) - display_error(_("failed to set system V init links \n")); + if (rv != 0) { + display_error(_("failed to set system V init links\n")); + } } @@ -712,7 +705,8 @@ void check_xinetd_entry(void) { _("Setup can configure the \"xinetd\" service to automatically\n" "connect incoming telnet sessions to Citadel, bypassing the\n" "host system login: prompt. Would you like to do this?\n" - )); + ) + ); if (yesno(buf, 1) == 0) { return; } @@ -854,17 +848,21 @@ int test_server(char *relhomestr, int relhome) { * to the server and try to get it back. The cookie does not * have to be secret ... just unique. */ - sprintf(cookie, "--test--%d--", getpid()); + generate_uuid(cookie); - if (relhome) + if (relhome) { sprintf(cmd, "%s/sendcommand -h%s ECHO %s 2>&1", ctdl_sbin_dir, relhomestr, - cookie); - else + cookie + ); + } + else { sprintf(cmd, "%s/sendcommand ECHO %s 2>&1", ctdl_sbin_dir, - cookie); + cookie + ); + } fp = popen(cmd, "r"); if (fp == NULL) return(errno); @@ -914,8 +912,9 @@ void strprompt(const char *prompt_title, const char *prompt_text, char *Target, Target, dialog_result); rv = system(buf); - if (rv != 0) - fprintf(stderr, "failed to run Dialog.\n"); + if (rv != 0) { + fprintf(stderr, "failed to run whiptail or dialog\n"); + } fp = fopen(dialog_result, "r"); if (fp != NULL) { @@ -946,7 +945,8 @@ void set_str_val(int msgpos, char *Target, char *DefValue) strprompt(setup_titles[msgpos], setup_text[msgpos], Target, - DefValue); + DefValue + ); } void set_int_val(int msgpos, int *ip, char *DefValue) @@ -987,9 +987,9 @@ void edit_value(int curr) { Value = getenv(EnvNames[curr]); } - if (Value == NULL) + if (Value == NULL) { Value = ""; - + } switch (curr) { @@ -1011,7 +1011,7 @@ void edit_value(int curr) else { #ifdef __CYGWIN__ - config.c_ctdluid = 0; /* XXX Windows hack, prob. insecure */ + config.c_ctdluid = 0; /* work-around for Windows */ #else i = config.c_ctdluid; pw = getpwuid(i); @@ -1131,7 +1131,7 @@ void write_config_to_disk(void) int discover_ui(void) { - /* Use "dialog" if we have it */ + /* Use "whiptail" or "dialog" if we have it */ if (getenv("CTDL_DIALOG") != NULL) { return UI_DIALOG; } @@ -1564,8 +1564,7 @@ int main(int argc, char *argv[]) } - get_config (); - + get_config(); set_default_values(); /* Go through a series of dialogs prompting for config info */ @@ -1634,5 +1633,3 @@ NEW_INST: cleanup(0); return 0; } - -