From: Art Cancro Date: Fri, 10 Apr 2015 18:57:19 +0000 (-0400) Subject: Removed the whole configlen thing. Seriously, WTF? X-Git-Tag: Release_902~167^2~41 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=b44a77a2aa913db5f48f01a8d58149c0df564684 Removed the whole configlen thing. Seriously, WTF? --- diff --git a/citadel/config.c b/citadel/config.c index 3a4e088f8..e30f098a2 100644 --- a/citadel/config.c +++ b/citadel/config.c @@ -20,7 +20,6 @@ #include "ctdl_module.h" struct config config; -struct configlen configlen; #define STR_NOT_EMPTY(CFG_FIELDNAME) if (IsEmptyStr(config.CFG_FIELDNAME)) \ syslog(LOG_EMERG, "configuration setting "#CFG_FIELDNAME" is empty, but must not - check your config!"); @@ -76,25 +75,25 @@ void brand_new_installation_set_defaults(void) { /* Determine our host name, in case we need to use it as a default */ uname(&my_utsname); - memset(&configlen, 0, sizeof(struct configlen)); + /* set some sample/default values in place of blanks... */ - configlen.c_nodename = extract_token(config.c_nodename, my_utsname.nodename, 0, '.', sizeof config.c_nodename); + extract_token(config.c_nodename, my_utsname.nodename, 0, '.', sizeof config.c_nodename); if (IsEmptyStr(config.c_fqdn) ) { if ((he = gethostbyname(my_utsname.nodename)) != NULL) { - configlen.c_fqdn = safestrncpy(config.c_fqdn, he->h_name, sizeof config.c_fqdn); + safestrncpy(config.c_fqdn, he->h_name, sizeof config.c_fqdn); } else { - configlen.c_fqdn = safestrncpy(config.c_fqdn, my_utsname.nodename, sizeof config.c_fqdn); + safestrncpy(config.c_fqdn, my_utsname.nodename, sizeof config.c_fqdn); } } - configlen.c_humannode = safestrncpy(config.c_humannode, "Citadel Server", sizeof config.c_humannode); - configlen.c_phonenum = safestrncpy(config.c_phonenum, "US 800 555 1212", sizeof config.c_phonenum); + safestrncpy(config.c_humannode, "Citadel Server", sizeof config.c_humannode); + safestrncpy(config.c_phonenum, "US 800 555 1212", sizeof config.c_phonenum); config.c_initax = 4; - configlen.c_moreprompt = safestrncpy(config.c_moreprompt, "", sizeof config.c_moreprompt); - configlen.c_twitroom = safestrncpy(config.c_twitroom, "Trashcan", sizeof config.c_twitroom); - configlen.c_baseroom = safestrncpy(config.c_baseroom, BASEROOM, sizeof config.c_baseroom); - configlen.c_aideroom = safestrncpy(config.c_aideroom, "Aide", sizeof config.c_aideroom); + safestrncpy(config.c_moreprompt, "", sizeof config.c_moreprompt); + safestrncpy(config.c_twitroom, "Trashcan", sizeof config.c_twitroom); + safestrncpy(config.c_baseroom, BASEROOM, sizeof config.c_baseroom); + safestrncpy(config.c_aideroom, "Aide", sizeof config.c_aideroom); config.c_port_number = 504; config.c_sleeping = 900; @@ -138,35 +137,6 @@ void brand_new_installation_set_defaults(void) { config.c_nntps_port = 563; } -void setcfglen(void) -{ - configlen.c_nodename = strlen(config.c_nodename); - configlen.c_fqdn = strlen(config.c_fqdn); - configlen.c_humannode = strlen(config.c_humannode); - configlen.c_phonenum = strlen(config.c_phonenum); - configlen.c_twitroom = strlen(config.c_twitroom); - configlen.c_moreprompt = strlen(config.c_moreprompt); - configlen.c_site_location = strlen(config.c_site_location); - configlen.c_sysadm = strlen(config.c_sysadm); - configlen.c_niu_2 = strlen(config.c_niu_2); - configlen.c_ip_addr = strlen(config.c_ip_addr); - configlen.c_logpages = strlen(config.c_logpages); - configlen.c_baseroom = strlen(config.c_baseroom); - configlen.c_aideroom = strlen(config.c_aideroom); - configlen.c_ldap_host = strlen(config.c_ldap_host); - configlen.c_ldap_base_dn = strlen(config.c_ldap_base_dn); - configlen.c_ldap_bind_dn = strlen(config.c_ldap_bind_dn); - configlen.c_ldap_bind_pw = strlen(config.c_ldap_bind_pw); - configlen.c_journal_dest = strlen(config.c_journal_dest); - configlen.c_default_cal_zone = strlen(config.c_default_cal_zone); - configlen.c_funambol_host = strlen(config.c_funambol_host); - configlen.c_funambol_source = strlen(config.c_funambol_source); - configlen.c_funambol_auth = strlen(config.c_funambol_auth); - configlen.c_master_user = strlen(config.c_master_user); - configlen.c_master_pass = strlen(config.c_master_pass); - configlen.c_pager_program = strlen(config.c_pager_program); -} - /* @@ -198,7 +168,6 @@ void get_config(void) { ); } fclose(cfp); - setcfglen(); } else { brand_new_installation_set_defaults(); diff --git a/citadel/control.c b/citadel/control.c index a541cbeb0..fd4b650f7 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -399,20 +399,16 @@ void cmd_conf(char *argbuf) while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) { switch (a) { case 0: - configlen.c_nodename = safestrncpy(config.c_nodename, buf, - sizeof config.c_nodename); + safestrncpy(config.c_nodename, buf, sizeof config.c_nodename); break; case 1: - configlen.c_fqdn = safestrncpy(config.c_fqdn, buf, - sizeof config.c_fqdn); + safestrncpy(config.c_fqdn, buf, sizeof config.c_fqdn); break; case 2: - configlen.c_humannode = safestrncpy(config.c_humannode, buf, - sizeof config.c_humannode); + safestrncpy(config.c_humannode, buf, sizeof config.c_humannode); break; case 3: - configlen.c_phonenum = safestrncpy(config.c_phonenum, buf, - sizeof config.c_phonenum); + safestrncpy(config.c_phonenum, buf, sizeof config.c_phonenum); break; case 4: config.c_creataide = atoi(buf); @@ -438,12 +434,10 @@ void cmd_conf(char *argbuf) config.c_twitdetect = 1; break; case 9: - configlen.c_twitroom = safestrncpy(config.c_twitroom, buf, - sizeof config.c_twitroom); + safestrncpy(config.c_twitroom, buf, sizeof config.c_twitroom); break; case 10: - configlen.c_moreprompt = safestrncpy(config.c_moreprompt, buf, - sizeof config.c_moreprompt); + safestrncpy(config.c_moreprompt, buf, sizeof config.c_moreprompt); break; case 11: config.c_restrict = atoi(buf); @@ -451,13 +445,10 @@ void cmd_conf(char *argbuf) config.c_restrict = 1; break; case 12: - configlen.c_site_location = safestrncpy( - config.c_site_location, buf, - sizeof config.c_site_location); + safestrncpy(config.c_site_location, buf, sizeof config.c_site_location); break; case 13: - configlen.c_sysadm = safestrncpy(config.c_sysadm, buf, - sizeof config.c_sysadm); + safestrncpy(config.c_sysadm, buf, sizeof config.c_sysadm); break; case 14: config.c_maxsessions = atoi(buf); @@ -474,8 +465,7 @@ void cmd_conf(char *argbuf) config.c_roompurge = atoi(buf); break; case 18: - configlen.c_logpages = safestrncpy(config.c_logpages, buf, - sizeof config.c_logpages); + safestrncpy(config.c_logpages, buf, sizeof config.c_logpages); break; case 19: config.c_createax = atoi(buf); @@ -530,28 +520,23 @@ void cmd_conf(char *argbuf) break; #ifdef HAVE_LDAP case 32: - configlen.c_ldap_host = safestrncpy(config.c_ldap_host, buf, - sizeof config.c_ldap_host); + safestrncpy(config.c_ldap_host, buf, sizeof config.c_ldap_host); break; case 33: config.c_ldap_port = atoi(buf); break; case 34: - configlen.c_ldap_base_dn = safestrncpy(config.c_ldap_base_dn, buf, - sizeof config.c_ldap_base_dn); + safestrncpy(config.c_ldap_base_dn, buf, sizeof config.c_ldap_base_dn); break; case 35: - configlen.c_ldap_bind_dn = safestrncpy(config.c_ldap_bind_dn, buf, - sizeof config.c_ldap_bind_dn); + safestrncpy(config.c_ldap_bind_dn, buf, sizeof config.c_ldap_bind_dn); break; case 36: - configlen.c_ldap_bind_pw = safestrncpy(config.c_ldap_bind_pw, buf, - sizeof config.c_ldap_bind_pw); + safestrncpy(config.c_ldap_bind_pw, buf, sizeof config.c_ldap_bind_pw); break; #endif case 37: - configlen.c_ip_addr = safestrncpy(config.c_ip_addr, buf, - sizeof config.c_ip_addr); + safestrncpy(config.c_ip_addr, buf, sizeof config.c_ip_addr); case 38: config.c_msa_port = atoi(buf); break; @@ -583,12 +568,9 @@ void cmd_conf(char *argbuf) config.c_journal_pubmsgs = atoi(buf); break; case 48: - configlen.c_journal_dest = safestrncpy(config.c_journal_dest, buf, - sizeof config.c_journal_dest); + safestrncpy(config.c_journal_dest, buf, sizeof config.c_journal_dest); case 49: - configlen.c_default_cal_zone = safestrncpy( - config.c_default_cal_zone, buf, - sizeof config.c_default_cal_zone); + safestrncpy(config.c_default_cal_zone, buf, sizeof config.c_default_cal_zone); break; case 50: config.c_pftcpdict_port = atoi(buf); @@ -599,38 +581,28 @@ void cmd_conf(char *argbuf) case 52: config.c_auth_mode = atoi(buf); case 53: - configlen.c_funambol_host = safestrncpy( - config.c_funambol_host, buf, - sizeof config.c_funambol_host); + safestrncpy(config.c_funambol_host, buf, sizeof config.c_funambol_host); break; case 54: config.c_funambol_port = atoi(buf); break; case 55: - configlen.c_funambol_source = safestrncpy( - config.c_funambol_source, buf, - sizeof config.c_funambol_source); + safestrncpy(config.c_funambol_source, buf, sizeof config.c_funambol_source); break; case 56: - configlen.c_funambol_auth = safestrncpy( - config.c_funambol_auth, buf, - sizeof config.c_funambol_auth); + safestrncpy(config.c_funambol_auth, buf, sizeof config.c_funambol_auth); break; case 57: config.c_rbl_at_greeting = atoi(buf); break; case 58: - configlen.c_master_user = safestrncpy( - config.c_master_user, - buf, sizeof config.c_master_user); + safestrncpy(config.c_master_user, buf, sizeof config.c_master_user); break; case 59: - configlen.c_master_pass = safestrncpy( - config.c_master_pass, buf, sizeof config.c_master_pass); + safestrncpy(config.c_master_pass, buf, sizeof config.c_master_pass); break; case 60: - configlen.c_pager_program = safestrncpy( - config.c_pager_program, buf, sizeof config.c_pager_program); + safestrncpy(config.c_pager_program, buf, sizeof config.c_pager_program); break; case 61: config.c_imap_keep_from = atoi(buf); diff --git a/citadel/include/ctdl_module.h b/citadel/include/ctdl_module.h index 86255e2f3..5ea37bfe5 100644 --- a/citadel/include/ctdl_module.h +++ b/citadel/include/ctdl_module.h @@ -376,39 +376,11 @@ struct config { int c_nntp_port; int c_nntps_port; }; -struct configlen { - long c_nodename; - long c_fqdn; - long c_humannode; - long c_phonenum; - long c_twitroom; - long c_moreprompt; - long c_site_location; - long c_sysadm; - long c_niu_2; - long c_ip_addr; - long c_logpages; - long c_baseroom; - long c_aideroom; - long c_ldap_host; - long c_ldap_base_dn; - long c_ldap_bind_dn; - long c_ldap_bind_pw; - long c_journal_dest; - long c_default_cal_zone; - long c_funambol_host; - long c_funambol_source; - long c_funambol_auth; - long c_master_user; - long c_master_pass; - long c_pager_program; -}; -#define SET_CFGSTRBUF(which, buffer) configlen.which = safestrncpy(config.which, ChrPtr(buffer), sizeof(config.which)) -#define SET_CFGSTR(which, buffer) configlen.which = safestrncpy(config.which, buffer, sizeof(config.which)) +#define SET_CFGSTRBUF(which, buffer) safestrncpy(config.which, ChrPtr(buffer), sizeof(config.which)) +#define SET_CFGSTR(which, buffer) safestrncpy(config.which, buffer, sizeof(config.which)) extern struct config config; -extern struct configlen configlen; #define NODENAME config.c_nodename @@ -420,7 +392,7 @@ extern struct configlen configlen; #define TWITROOM config.c_twitroom #define RESTRICT_INTERNET config.c_restrict -#define CFG_KEY(which) config.which, configlen.which +#define CFG_KEY(which) config.which, strlen(config.which) typedef void (*CfgLineParser)(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *rncfg); typedef void (*CfgLineSerializer)(const CfgLineType *ThisOne, StrBuf *OuptputBuffer, OneRoomNetCfg *rncfg, RoomNetCfgLine *data); diff --git a/citadel/modules/network/serv_netspool.c b/citadel/modules/network/serv_netspool.c index 0edb1f11e..86cffbdef 100644 --- a/citadel/modules/network/serv_netspool.c +++ b/citadel/modules/network/serv_netspool.c @@ -168,7 +168,7 @@ void Netmap_AddMe(struct CtdlMessage *msg, const char *defl, long defllen) if (CM_IsEmpty(msg, eMessagePath)) { CM_SetField(msg, eMessagePath, defl, defllen); } - node_len = configlen.c_nodename; + node_len = strlen(config.c_nodename); if (node_len >= SIZ) node_len = SIZ - 1; memcpy(buf, config.c_nodename, node_len); diff --git a/citadel/server.h b/citadel/server.h index d9bcb207e..a34e1e423 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -224,7 +224,6 @@ enum { CDB_EUIDINDEX, /* locate msgs by EUID */ CDB_USERSBYNUMBER, /* index of users by number */ CDB_OPENID, /* associates OpenIDs with users */ - CDB_CONFIG, /* global system configuration */ MAXCDB /* total number of CDB's defined */ }; diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 6cce2a15b..a8004ed0f 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -528,10 +528,10 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname) /* If a "master user" is defined, handle its authentication if specified */ CC->is_master = 0; - if ((configlen.c_master_user > 0) && - (configlen.c_master_pass > 0) && - (authname != NULL) && - (!strcasecmp(authname, config.c_master_user))) + if ( (strlen(config.c_master_user) > 0) && + (strlen(config.c_master_pass) > 0) && + (authname != NULL) && + (!strcasecmp(authname, config.c_master_user)) ) { CC->is_master = 1; }