config.c ported to new system BROKEN BUILD ALERT
authorArt Cancro <ajc@uncensored.citadel.org>
Wed, 29 Apr 2015 14:42:51 +0000 (10:42 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Wed, 29 Apr 2015 14:42:51 +0000 (10:42 -0400)
citadel/config.c
citadel/config.h
citadel/control.c
citadel/include/ctdl_module.h
citadel/modules/migrate/serv_migrate.c

index 93a9f10669382c09f4d7712c16852eb07086fb4c..fffdadc6e0a8adfcba8f6b11c862103cf9a0f5e5 100644 (file)
 #include "config.h"
 #include "ctdl_module.h"
 
-struct config config;          // legacy configuration
+long config_msgnum = 0;
 HashList *ctdlconfig = NULL;   // new configuration
 
-#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!");
 
-#define TEST_PORT(CFG_PORT, DEFAULTPORT)                       \
-       if ((config.CFG_PORT < -1) ||           \
-           (config.CFG_PORT == 0) ||           \
-           (config.CFG_PORT > UINT16_MAX))     \
-               syslog(LOG_EMERG, "configuration setting "#CFG_PORT" is not -1 (disabled) or a valid TCP-Port - check your config! Default setting is: "#DEFAULTPORT);
-                       
+void config_warn_if_port_unset(char *key, int default_port)                    \
+{
+       int p = CtdlGetConfigInt(key);
+       if ((p < -1) || (p == 0) || (p > UINT16_MAX))
+       {
+               syslog(LOG_EMERG,
+                       "configuration setting %s is not -1 (disabled) or a valid TCP-Port - check your config! Default setting is: %d",
+                       key, default_port
+               );
+       }
+}
+
+
+void config_warn_if_empty(char *key)
+{
+       if (IsEmptyStr(CtdlGetConfigStr(key)))
+       {
+               syslog(LOG_EMERG, "configuration setting %s is empty, but must not - check your config!", key);
+       }
+}
+
+
 
 void validate_config(void) {
-/* these shouldn't be empty: */
-       STR_NOT_EMPTY(c_fqdn);
-
-       STR_NOT_EMPTY(c_baseroom);
-       STR_NOT_EMPTY(c_aideroom);
-       STR_NOT_EMPTY(c_twitroom);
-       STR_NOT_EMPTY(c_nodename);
-       STR_NOT_EMPTY(c_default_cal_zone);
-
-/* we bind a lot of ports: */
-       TEST_PORT(c_smtp_port, 25);
-       TEST_PORT(c_pop3_port, 110);
-       TEST_PORT(c_imap_port, 143);
-       TEST_PORT(c_msa_port, 587);
-       TEST_PORT(c_port_number, 504);
-       TEST_PORT(c_smtps_port, 465);
-       TEST_PORT(c_pop3s_port, 995);
-       TEST_PORT(c_imaps_port, 993);
-       TEST_PORT(c_pftcpdict_port, -1);
-       TEST_PORT(c_managesieve_port, 2020);
-       TEST_PORT(c_xmpp_c2s_port, 5222);
-       TEST_PORT(c_xmpp_s2s_port, 5269);
-       TEST_PORT(c_nntp_port, 119);
-       TEST_PORT(c_nntps_port, 563);
+
+       /*
+        * these shouldn't be empty
+        */
+       config_warn_if_empty("c_fqdn");
+       config_warn_if_empty("c_baseroom");
+       config_warn_if_empty("c_aideroom");
+       config_warn_if_empty("c_twitroom");
+       config_warn_if_empty("c_nodename");
+       config_warn_if_empty("c_default_cal_zone");
+
+       /*
+        * Sanity check for port bindings
+        */
+       config_warn_if_port_unset("c_smtp_port", 25);
+       config_warn_if_port_unset("c_pop3_port", 110);
+       config_warn_if_port_unset("c_imap_port", 143);
+       config_warn_if_port_unset("c_msa_port", 587);
+       config_warn_if_port_unset("c_port_number", 504);
+       config_warn_if_port_unset("c_smtps_port", 465);
+       config_warn_if_port_unset("c_pop3s_port", 995);
+       config_warn_if_port_unset("c_imaps_port", 993);
+       config_warn_if_port_unset("c_pftcpdict_port", -1);
+       config_warn_if_port_unset("c_managesieve_port", 2020);
+       config_warn_if_port_unset("c_xmpp_c2s_port", 5222);
+       config_warn_if_port_unset("c_xmpp_s2s_port", 5269);
+       config_warn_if_port_unset("c_nntp_port", 119);
+       config_warn_if_port_unset("c_nntps_port", 563);
 
        if (getpwuid(ctdluid) == NULL) {
                syslog(LOG_EMERG, "The UID (%d) citadel is configured to use is not defined in your system (/etc/passwd?)!", ctdluid);
@@ -71,51 +89,139 @@ void brand_new_installation_set_defaults(void) {
 
        struct utsname my_utsname;
        struct hostent *he;
+       char detected_hostname[256];
 
        /* Determine our host name, in case we need to use it as a default */
        uname(&my_utsname);
 
        /* set some sample/default values in place of blanks... */
-       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) {
-                       safestrncpy(config.c_fqdn, he->h_name, sizeof config.c_fqdn);
-               }
-               else {
-                       safestrncpy(config.c_fqdn, my_utsname.nodename, sizeof config.c_fqdn);
-               }
+       extract_token(detected_hostname, my_utsname.nodename, 0, '.', sizeof detected_hostname);
+       CtdlSetConfigStr("c_nodename", detected_hostname);
+
+       if ((he = gethostbyname(my_utsname.nodename)) != NULL) {
+               CtdlSetConfigStr("c_fqdn", he->h_name);
+       }
+       else {
+               CtdlSetConfigStr("c_fqdn", my_utsname.nodename);
        }
 
-       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;
-       safestrncpy(config.c_moreprompt, "<more>", 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;
-
-       if (config.c_createax == 0) {
-               config.c_createax = 3;
+       CtdlSetConfigStr("c_humannode",         "Citadel Server");
+       CtdlSetConfigInt("c_initax",            4);
+       CtdlSetConfigStr("c_moreprompt",        "<more>");
+       CtdlSetConfigStr("c_twitroom",          "Trashcan");
+       CtdlSetConfigStr("c_baseroom",          BASEROOM);
+       CtdlSetConfigStr("c_aideroom",          "Aide");
+       CtdlSetConfigInt("c_sleeping",          900);
+
+       if (CtdlGetConfigInt("c_createax") == 0) {
+               CtdlSetConfigInt("c_createax", 3);
        }
 
        /*
         * Default port numbers for various services
         */
-       config.c_smtp_port = 25;
-       config.c_pop3_port = 110;
-       config.c_imap_port = 143;
-       config.c_msa_port = 587;
-       config.c_smtps_port = 465;
-       config.c_pop3s_port = 995;
-       config.c_imaps_port = 993;
-       config.c_pftcpdict_port = -1 ;
-       config.c_managesieve_port = 2020;
-       config.c_xmpp_c2s_port = 5222;
-       config.c_xmpp_s2s_port = 5269;
-       config.c_nntp_port = 119;
-       config.c_nntps_port = 563;
+       CtdlSetConfigInt("c_port_number",       504);
+       CtdlSetConfigInt("c_smtp_port",         25);
+       CtdlSetConfigInt("c_pop3_port",         110);
+       CtdlSetConfigInt("c_imap_port",         143);
+       CtdlSetConfigInt("c_msa_port",          587);
+       CtdlSetConfigInt("c_smtps_port",        465);
+       CtdlSetConfigInt("c_pop3s_port",        995);
+       CtdlSetConfigInt("c_imaps_port",        993);
+       CtdlSetConfigInt("c_pftcpdict_port",    -1);
+       CtdlSetConfigInt("c_managesieve_port",  2020);
+       CtdlSetConfigInt("c_xmpp_c2s_port",     5222);
+       CtdlSetConfigInt("c_xmpp_s2s_port",     5269);
+       CtdlSetConfigInt("c_nntp_port",         119);
+       CtdlSetConfigInt("c_nntps_port",        563);
+
+       /*
+        * Prevent the "new installation, set defaults" behavior from occurring again
+        */
+       CtdlSetConfigLong("c_config_created_or_migrated", (long)time(NULL));
+}
+
+
+
+/*
+ * Migrate a supplied legacy configuration to the new in-db format.
+ * No individual site should ever have to do this more than once.
+ */
+void migrate_legacy_config(struct legacy_config *lconfig)
+{
+       CtdlSetConfigStr(       "c_nodename"            ,       lconfig->c_nodename             );
+       CtdlSetConfigStr(       "c_fqdn"                ,       lconfig->c_fqdn                 );
+       CtdlSetConfigStr(       "c_humannode"           ,       lconfig->c_humannode            );
+       CtdlSetConfigInt(       "c_creataide"           ,       lconfig->c_creataide            );
+       CtdlSetConfigInt(       "c_sleeping"            ,       lconfig->c_sleeping             );
+       CtdlSetConfigInt(       "c_initax"              ,       lconfig->c_initax               );
+       CtdlSetConfigInt(       "c_regiscall"           ,       lconfig->c_regiscall            );
+       CtdlSetConfigInt(       "c_twitdetect"          ,       lconfig->c_twitdetect           );
+       CtdlSetConfigStr(       "c_twitroom"            ,       lconfig->c_twitroom             );
+       CtdlSetConfigStr(       "c_moreprompt"          ,       lconfig->c_moreprompt           );
+       CtdlSetConfigInt(       "c_restrict"            ,       lconfig->c_restrict             );
+       CtdlSetConfigStr(       "c_site_location"       ,       lconfig->c_site_location        );
+       CtdlSetConfigStr(       "c_sysadm"              ,       lconfig->c_sysadm               );
+       CtdlSetConfigInt(       "c_maxsessions"         ,       lconfig->c_maxsessions          );
+       CtdlSetConfigStr(       "c_ip_addr"             ,       lconfig->c_ip_addr              );
+       CtdlSetConfigInt(       "c_port_number"         ,       lconfig->c_port_number          );
+       CtdlSetConfigInt(       "c_ep_mode"             ,       lconfig->c_ep.expire_mode       );
+       CtdlSetConfigInt(       "c_ep_value"            ,       lconfig->c_ep.expire_value      );
+       CtdlSetConfigInt(       "c_userpurge"           ,       lconfig->c_userpurge            );
+       CtdlSetConfigInt(       "c_roompurge"           ,       lconfig->c_roompurge            );
+       CtdlSetConfigStr(       "c_logpages"            ,       lconfig->c_logpages             );
+       CtdlSetConfigInt(       "c_createax"            ,       lconfig->c_createax             );
+       CtdlSetConfigLong(      "c_maxmsglen"           ,       lconfig->c_maxmsglen            );
+       CtdlSetConfigInt(       "c_min_workers"         ,       lconfig->c_min_workers          );
+       CtdlSetConfigInt(       "c_max_workers"         ,       lconfig->c_max_workers          );
+       CtdlSetConfigInt(       "c_pop3_port"           ,       lconfig->c_pop3_port            );
+       CtdlSetConfigInt(       "c_smtp_port"           ,       lconfig->c_smtp_port            );
+       CtdlSetConfigInt(       "c_rfc822_strict_from"  ,       lconfig->c_rfc822_strict_from   );
+       CtdlSetConfigInt(       "c_aide_zap"            ,       lconfig->c_aide_zap             );
+       CtdlSetConfigInt(       "c_imap_port"           ,       lconfig->c_imap_port            );
+       CtdlSetConfigLong(      "c_net_freq"            ,       lconfig->c_net_freq             );
+       CtdlSetConfigInt(       "c_disable_newu"        ,       lconfig->c_disable_newu         );
+       CtdlSetConfigInt(       "c_enable_fulltext"     ,       lconfig->c_enable_fulltext      );
+       CtdlSetConfigStr(       "c_baseroom"            ,       lconfig->c_baseroom             );
+       CtdlSetConfigStr(       "c_aideroom"            ,       lconfig->c_aideroom             );
+       CtdlSetConfigInt(       "c_purge_hour"          ,       lconfig->c_purge_hour           );
+       CtdlSetConfigInt(       "c_mbxep_mode"          ,       lconfig->c_mbxep.expire_mode    );
+       CtdlSetConfigInt(       "c_mbxep_value"         ,       lconfig->c_mbxep.expire_value   );
+       CtdlSetConfigStr(       "c_ldap_host"           ,       lconfig->c_ldap_host            );
+       CtdlSetConfigInt(       "c_ldap_port"           ,       lconfig->c_ldap_port            );
+       CtdlSetConfigStr(       "c_ldap_base_dn"        ,       lconfig->c_ldap_base_dn         );
+       CtdlSetConfigStr(       "c_ldap_bind_dn"        ,       lconfig->c_ldap_bind_dn         );
+       CtdlSetConfigStr(       "c_ldap_bind_pw"        ,       lconfig->c_ldap_bind_pw         );
+       CtdlSetConfigInt(       "c_msa_port"            ,       lconfig->c_msa_port             );
+       CtdlSetConfigInt(       "c_imaps_port"          ,       lconfig->c_imaps_port           );
+       CtdlSetConfigInt(       "c_pop3s_port"          ,       lconfig->c_pop3s_port           );
+       CtdlSetConfigInt(       "c_smtps_port"          ,       lconfig->c_smtps_port           );
+       CtdlSetConfigInt(       "c_auto_cull"           ,       lconfig->c_auto_cull            );
+       CtdlSetConfigInt(       "c_allow_spoofing"      ,       lconfig->c_allow_spoofing       );
+       CtdlSetConfigInt(       "c_journal_email"       ,       lconfig->c_journal_email        );
+       CtdlSetConfigInt(       "c_journal_pubmsgs"     ,       lconfig->c_journal_pubmsgs      );
+       CtdlSetConfigStr(       "c_journal_dest"        ,       lconfig->c_journal_dest         );
+       CtdlSetConfigStr(       "c_default_cal_zone"    ,       lconfig->c_default_cal_zone     );
+       CtdlSetConfigInt(       "c_pftcpdict_port"      ,       lconfig->c_pftcpdict_port       );
+       CtdlSetConfigInt(       "c_managesieve_port"    ,       lconfig->c_managesieve_port     );
+       CtdlSetConfigInt(       "c_auth_mode"           ,       lconfig->c_auth_mode            );
+       CtdlSetConfigStr(       "c_funambol_host"       ,       lconfig->c_funambol_host        );
+       CtdlSetConfigInt(       "c_funambol_port"       ,       lconfig->c_funambol_port        );
+       CtdlSetConfigStr(       "c_funambol_source"     ,       lconfig->c_funambol_source      );
+       CtdlSetConfigStr(       "c_funambol_auth"       ,       lconfig->c_funambol_auth        );
+       CtdlSetConfigInt(       "c_rbl_at_greeting"     ,       lconfig->c_rbl_at_greeting      );
+       CtdlSetConfigStr(       "c_master_user"         ,       lconfig->c_master_user          );
+       CtdlSetConfigStr(       "c_master_pass"         ,       lconfig->c_master_pass          );
+       CtdlSetConfigStr(       "c_pager_program"       ,       lconfig->c_pager_program        );
+       CtdlSetConfigInt(       "c_imap_keep_from"      ,       lconfig->c_imap_keep_from       );
+       CtdlSetConfigInt(       "c_xmpp_c2s_port"       ,       lconfig->c_xmpp_c2s_port        );
+       CtdlSetConfigInt(       "c_xmpp_s2s_port"       ,       lconfig->c_xmpp_s2s_port        );
+       CtdlSetConfigLong(      "c_pop3_fetch"          ,       lconfig->c_pop3_fetch           );
+       CtdlSetConfigLong(      "c_pop3_fastest"        ,       lconfig->c_pop3_fastest         );
+       CtdlSetConfigInt(       "c_spam_flag_only"      ,       lconfig->c_spam_flag_only       );
+       CtdlSetConfigInt(       "c_guest_logins"        ,       lconfig->c_guest_logins         );
+       CtdlSetConfigInt(       "c_nntp_port"           ,       lconfig->c_nntp_port            );
+       CtdlSetConfigInt(       "c_nntps_port"          ,       lconfig->c_nntps_port           );
 }
 
 
@@ -127,7 +233,19 @@ void brand_new_installation_set_defaults(void) {
 void initialize_config_system(void) {
        FILE *cfp;
        int rv;
-       ctdlconfig = NewHash(1, NULL);
+       struct legacy_config lconfig;   // legacy configuration
+       ctdlconfig = NewHash(1, NULL);  // set up the real config system
+
+       /* Ensure that we are linked to the correct version of libcitadel */
+       if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
+               fprintf(stderr, "You are running libcitadel version %d.%02d\n",
+                       (libcitadel_version_number() / 100), (libcitadel_version_number() % 100)
+               );
+               fprintf(stderr, "citserver was compiled against version %d.%02d\n",
+                       (LIBCITADEL_VERSION_NUMBER / 100), (LIBCITADEL_VERSION_NUMBER % 100)
+               );
+               exit(CTDLEXIT_LIBCITADEL);
+       }
 
        if (chdir(ctdl_bbsbase_dir) != 0) {
                fprintf(stderr,
@@ -138,30 +256,42 @@ void initialize_config_system(void) {
                exit(CTDLEXIT_HOME);
        }
 
-       memset(&config, 0, sizeof(struct config));
+       memset(&config, 0, sizeof(struct legacy_config));
        cfp = fopen(file_citadel_config, "rb");
        if (cfp != NULL) {
-               rv = fread((char *) &config, sizeof(struct config), 1, cfp);
+               if (CtdlGetConfigLong("c_config_created_or_migrated") <= 0) {
+                       fprintf(stderr, "Citadel Server found BOTH legacy and new configurations present.\n");
+                       fprintf(stderr, "Exiting to prevent data corruption.\n");
+                       exit(CTDLEXIT_CONFIG);
+               }
+               rv = fread((char *) &config, sizeof(struct legacy_config), 1, cfp);
                if (rv != 1)
                {
                        fprintf(stderr, 
-                               "Warning: The config file %s has unexpected size. \n",
+                               "Warning: Found a legacy config file %s has unexpected size. \n",
                                file_citadel_config
                        );
                }
+
+               migrate_legacy_config(&lconfig);
+
                fclose(cfp);
-       }
-       else {
-               brand_new_installation_set_defaults();
+               if (unlink(file_citadel_config) != 0) {
+                       fprintf(stderr, "Unable to remove legacy config file %s after migrating it.\n", file_citadel_config);
+                       fprintf(stderr, "Exiting to prevent data corruption.\n");
+                       exit(CTDLEXIT_CONFIG);
+               }
+
+               /*
+                * Prevent migration/initialization from happening again.
+                */
+               CtdlSetConfigLong("c_config_created_or_migrated", (long)time(NULL));
+
        }
 
-       /* Ensure that we are linked to the correct version of libcitadel */
-       if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
-               fprintf(stderr, "    You are running libcitadel version %d.%02d\n",
-                       (libcitadel_version_number() / 100), (libcitadel_version_number() % 100));
-               fprintf(stderr, "citserver was compiled against version %d.%02d\n",
-                       (LIBCITADEL_VERSION_NUMBER / 100), (LIBCITADEL_VERSION_NUMBER % 100));
-               exit(CTDLEXIT_LIBCITADEL);
+       /* New installation?  Set up configuration */
+       if (CtdlGetConfigLong("c_config_created_or_migrated") <= 0) {
+               brand_new_installation_set_defaults();
        }
 
        /* Only allow LDAP auth mode if we actually have LDAP support */
@@ -177,67 +307,32 @@ void initialize_config_system(void) {
         * configurable.  Also check to make sure the limit has not been
         * set below 8192 bytes.
          */
-        if (config.c_maxmsglen <= 0)
-                config.c_maxmsglen = 10485760;
-        if (config.c_maxmsglen < 8192)
-                config.c_maxmsglen = 8192;
-
-        /* Default lower and upper limits on number of worker threads */
-
-       if (config.c_min_workers < 3)           /* no less than 3 */
-               config.c_min_workers = 5;
+        if (CtdlGetConfigLong("c_maxmsglen") <= 0)     CtdlSetConfigLong("c_maxmsglen", 10485760);
+        if (CtdlGetConfigLong("c_maxmsglen") < 8192)   CtdlSetConfigLong("c_maxmsglen", 8192);
 
-       if (config.c_max_workers == 0)                  /* default maximum */
-               config.c_max_workers = 256;
-
-       if (config.c_max_workers < config.c_min_workers)   /* max >= min */
-               config.c_max_workers = config.c_min_workers;
+        /*
+        * Default lower and upper limits on number of worker threads
+        */
+       if (CtdlGetConfigInt("c_min_workers") < 5)      CtdlSetConfigInt("c_min_workers", 5);   // min
+       if (CtdlGetConfigInt("c_max_workers") == 0)     CtdlSetConfigInt("c_max_workers", 256); // default max
+       if (CtdlGetConfigInt("c_max_workers") < CtdlGetConfigInt("c_min_workers")) {
+               CtdlSetConfigInt("c_max_workers", CtdlGetConfigInt("c_min_workers"));           // max >= min
+       }
 
        /* Networking more than once every five minutes just isn't sane */
-       if (config.c_net_freq == 0L)
-               config.c_net_freq = 3600L;      /* once per hour default */
-       if (config.c_net_freq < 300L) 
-               config.c_net_freq = 300L;
+       if (CtdlGetConfigLong("c_net_freq") == 0)       CtdlSetConfigLong("c_net_freq", 3600);  // once per hour default
+       if (CtdlGetConfigLong("c_net_freq") < 300)      CtdlSetConfigLong("c_net_freq", 300);   // minimum 5 minutes
 
        /* Same goes for POP3 */
-       if (config.c_pop3_fetch == 0L)
-               config.c_pop3_fetch = 3600L;    /* once per hour default */
-       if (config.c_pop3_fetch < 300L) 
-               config.c_pop3_fetch = 300L;
-       if (config.c_pop3_fastest == 0L)
-               config.c_pop3_fastest = 3600L;  /* once per hour default */
-       if (config.c_pop3_fastest < 300L) 
-               config.c_pop3_fastest = 300L;
+       if (CtdlGetConfigLong("c_pop3_fetch") == 0)     CtdlSetConfigLong("c_pop3_fetch", 3600);        // once per hour default
+       if (CtdlGetConfigLong("c_pop3_fetch") < 300)    CtdlSetConfigLong("c_pop3_fetch", 300);         // 5 minutes min
+       if (CtdlGetConfigLong("c_pop3_fastest") == 0)   CtdlSetConfigLong("c_pop3_fastest", 3600);      // once per hour default
+       if (CtdlGetConfigLong("c_pop3_fastest") < 300)  CtdlSetConfigLong("c_pop3_fastest", 300);       // 5 minutes min
 
        /* "create new user" only works with native authentication mode */
-       if (config.c_auth_mode != AUTHMODE_NATIVE) {
-               config.c_disable_newu = 1;
-       }
-}
-
-long config_msgnum = 0;
-
-/*
- * Occasionally, we will need to write the config file, because some operations
- * change site-wide parameters.
- */
-void put_config(void)
-{
-       FILE *cfp;
-       int blocks_written = 0;
-
-       cfp = fopen(file_citadel_config, "w");
-       if (cfp != NULL) {
-               blocks_written = fwrite((char *) &config, sizeof(struct config), 1, cfp);
-               if (blocks_written == 1) {
-                       chown(file_citadel_config, CTDLUID, (-1));
-                       chmod(file_citadel_config, 0600);
-                       fclose(cfp);
-                       return;
-               }
-               fclose(cfp);
+       if (CtdlGetConfigInt("c_auth_mode") != AUTHMODE_NATIVE) {
+               CtdlSetConfigInt("c_disable_newu", 1);
        }
-       syslog(LOG_EMERG, "%s: %s", file_citadel_config, strerror(errno));
 }
 
 
index 8da53f8970adb1297217ea632e7bff2076232d4b..79f24427439249371bf2d8650b2787180bb77b7c 100644 (file)
 #define CtdlGetConfigInt(x)    atoi(CtdlGetConfigStr(x))
 #define CtdlGetConfigLong(x)   atol(CtdlGetConfigStr(x))
 
+
+
+
+/*
+ * This is the format of the legacy config file.  Do not attempt to do anything with it other
+ * than migrate it into the new format. 
+ */
+struct legacy_config {
+       char c_nodename[16];            /* short name of this node on a Citadel network */
+       char c_fqdn[64];                /* this site's fully qualified domain name */
+       char c_humannode[21];           /* human-readable site name */
+       char c_niu_7[16];
+       uid_t c_niu_6;
+       char c_creataide;               /* 1 = creating a room auto-grants room aide privileges */
+       int c_sleeping;                 /* watchdog timer (seconds) */
+       char c_initax;                  /* initial access level for new users */
+       char c_regiscall;               /* after c_regiscall logins user will be asked to register */
+       char c_twitdetect;              /* automatically move messages from problem users to trashcan */
+       char c_twitroom[ROOMNAMELEN];   /* name of trashcan */
+       char c_moreprompt[80];          /* paginator prompt */
+       char c_restrict;                /* require per-user permission to send Internet mail */
+       long c_niu_1;
+       char c_site_location[32];       /* geographic location of this Citadel site */
+       char c_sysadm[26];              /* name of system administrator */
+       char c_niu_2[15];
+       int c_niu_3;
+       int c_maxsessions;              /* maximum number of concurrent sessions allowed */
+       char c_ip_addr[20];             /* bind address for listening sockets */
+       int c_port_number;              /* port number for Citadel protocol (usually 504) */
+       int c_niu_4;
+       struct ExpirePolicy c_ep;       /* default expire policy for the entire site */
+       int c_userpurge;                /* user purge time (in days) */
+       int c_roompurge;                /* room purge time (in days) */
+       char c_logpages[ROOMNAMELEN];
+       char c_createax;
+       long c_maxmsglen;
+       int c_min_workers;
+       int c_max_workers;
+       int c_pop3_port;
+       int c_smtp_port;
+       int c_rfc822_strict_from;
+       int c_aide_zap;
+       int c_imap_port;
+       time_t c_net_freq;
+       char c_disable_newu;
+       char c_enable_fulltext;
+       char c_baseroom[ROOMNAMELEN];
+       char c_aideroom[ROOMNAMELEN];
+       int c_purge_hour;
+       struct ExpirePolicy c_mbxep;
+       char c_ldap_host[128];
+       int c_ldap_port;
+       char c_ldap_base_dn[256];
+       char c_ldap_bind_dn[256];
+       char c_ldap_bind_pw[256];
+       int c_msa_port;
+       int c_imaps_port;
+       int c_pop3s_port;
+       int c_smtps_port;
+       char c_auto_cull;
+       char c_niu_5;
+       char c_allow_spoofing;
+       char c_journal_email;
+       char c_journal_pubmsgs;
+       char c_journal_dest[128];
+       char c_default_cal_zone[128];
+       int c_pftcpdict_port;
+       int c_managesieve_port;
+       int c_auth_mode;
+       char c_funambol_host[256];
+       int c_funambol_port;
+       char c_funambol_source[256];
+       char c_funambol_auth[256];
+       char c_rbl_at_greeting;
+       char c_master_user[32];
+       char c_master_pass[32];
+       char c_pager_program[256];
+       char c_imap_keep_from;
+       int c_xmpp_c2s_port;
+       int c_xmpp_s2s_port;
+       time_t c_pop3_fetch;
+       time_t c_pop3_fastest;
+       int c_spam_flag_only;
+       int c_guest_logins;
+       int c_nntp_port;
+       int c_nntps_port;
+};
+
+
+
+
 void initialize_config_system(void);
 void shutdown_config_system(void);
 void put_config(void);
index 22d7097ca556797f66e79bbef21a7cf0fbc97030..3fd1419834ebb9c71e70f05f381631deb17964fa 100644 (file)
@@ -312,7 +312,7 @@ void cmd_conf(char *argbuf)
                cprintf("%s\n", config.c_nodename);
                cprintf("%s\n", config.c_fqdn);
                cprintf("%s\n", config.c_humannode);
-               cprintf("%s\n", config.c_phonenum);
+               cprintf("xxx\n"); /* placeholder -- field no longer in use */
                cprintf("%d\n", config.c_creataide);
                cprintf("%d\n", config.c_sleeping);
                cprintf("%d\n", config.c_initax);
@@ -408,7 +408,7 @@ void cmd_conf(char *argbuf)
                                safestrncpy(config.c_humannode, buf, sizeof config.c_humannode);
                                break;
                        case 3:
-                               safestrncpy(config.c_phonenum, buf, sizeof config.c_phonenum);
+                               /* placeholder -- field no longer in use */
                                break;
                        case 4:
                                config.c_creataide = atoi(buf);
index 80ee3a9425bea7a99aaea3f8bbbbc02bd82587b6..744e64fd3d19f75512f25af9a93361d4460933ad 100644 (file)
@@ -293,89 +293,6 @@ enum {
  */
 void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name);
 
-/* 
- * Global system configuration
- */
-struct config {
-       char c_nodename[16];            /* short name of this node on a Citadel network */
-       char c_fqdn[64];                /* this site's fully qualified domain name */
-       char c_humannode[21];           /* human-readable site name */
-       char c_phonenum[16];            /* telephone number */
-       uid_t c_niu_6;
-       char c_creataide;               /* 1 = creating a room auto-grants room aide privileges */
-       int c_sleeping;                 /* watchdog timer (seconds) */
-       char c_initax;                  /* initial access level for new users */
-       char c_regiscall;               /* after c_regiscall logins user will be asked to register */
-       char c_twitdetect;              /* automatically move messages from problem users to trashcan */
-       char c_twitroom[ROOMNAMELEN];   /* name of trashcan */
-       char c_moreprompt[80];          /* paginator prompt */
-       char c_restrict;                /* require per-user permission to send Internet mail */
-       long c_niu_1;
-       char c_site_location[32];       /* geographic location of this Citadel site */
-       char c_sysadm[26];              /* name of system administrator */
-       char c_niu_2[15];
-       int c_niu_3;
-       int c_maxsessions;              /* maximum number of concurrent sessions allowed */
-       char c_ip_addr[20];             /* bind address for listening sockets */
-       int c_port_number;              /* port number for Citadel protocol (usually 504) */
-       int c_niu_4;
-       struct ExpirePolicy c_ep;       /* default expire policy for the entire site */
-       int c_userpurge;                /* user purge time (in days) */
-       int c_roompurge;                /* room purge time (in days) */
-       char c_logpages[ROOMNAMELEN];
-       char c_createax;
-       long c_maxmsglen;
-       int c_min_workers;
-       int c_max_workers;
-       int c_pop3_port;
-       int c_smtp_port;
-       int c_rfc822_strict_from;
-       int c_aide_zap;
-       int c_imap_port;
-       time_t c_net_freq;
-       char c_disable_newu;
-       char c_enable_fulltext;
-       char c_baseroom[ROOMNAMELEN];
-       char c_aideroom[ROOMNAMELEN];
-       int c_purge_hour;
-       struct ExpirePolicy c_mbxep;
-       char c_ldap_host[128];
-       int c_ldap_port;
-       char c_ldap_base_dn[256];
-       char c_ldap_bind_dn[256];
-       char c_ldap_bind_pw[256];
-       int c_msa_port;
-       int c_imaps_port;
-       int c_pop3s_port;
-       int c_smtps_port;
-       char c_auto_cull;
-       char c_niu_5;
-       char c_allow_spoofing;
-       char c_journal_email;
-       char c_journal_pubmsgs;
-       char c_journal_dest[128];
-       char c_default_cal_zone[128];
-       int c_pftcpdict_port;
-       int c_managesieve_port;
-       int c_auth_mode;
-       char c_funambol_host[256];
-       int c_funambol_port;
-       char c_funambol_source[256];
-       char c_funambol_auth[256];
-       char c_rbl_at_greeting;
-       char c_master_user[32];
-       char c_master_pass[32];
-       char c_pager_program[256];
-       char c_imap_keep_from;
-       int c_xmpp_c2s_port;
-       int c_xmpp_s2s_port;
-       time_t c_pop3_fetch;
-       time_t c_pop3_fastest;
-       int c_spam_flag_only;
-       int c_guest_logins;
-       int c_nntp_port;
-       int c_nntps_port;
-};
 
 #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))
index e4d39d0ece7407372d4413b0a038d87ed1d170ea..51c390290c3f188c85e319700ce377f274eb7cf8 100644 (file)
@@ -435,7 +435,6 @@ void migr_do_export(void) {
        client_write("<c_nodename>", 12);       xml_strout(config.c_nodename);          client_write("</c_nodename>\n", 14);
        client_write("<c_fqdn>", 8);            xml_strout(config.c_fqdn);              client_write("</c_fqdn>\n", 10);
        client_write("<c_humannode>", 13);      xml_strout(config.c_humannode);         client_write("</c_humannode>\n", 15);
-       client_write("<c_phonenum>", 12);       xml_strout(config.c_phonenum);          client_write("</c_phonenum>\n", 14);
        cprintf("<c_creataide>%d</c_creataide>\n", config.c_creataide);
        cprintf("<c_sleeping>%d</c_sleeping>\n", config.c_sleeping);
        cprintf("<c_initax>%d</c_initax>\n", config.c_initax);
@@ -622,7 +621,6 @@ int migr_config(void *data, const char *el)
        if (!strcasecmp(el, "c_nodename"))                      SET_CFGSTRBUF(c_nodename, migr_chardata);
        else if (!strcasecmp(el, "c_fqdn"))                     SET_CFGSTRBUF(c_fqdn, migr_chardata);
        else if (!strcasecmp(el, "c_humannode"))                SET_CFGSTRBUF(c_humannode, migr_chardata);
-       else if (!strcasecmp(el, "c_phonenum"))                 SET_CFGSTRBUF(c_phonenum, migr_chardata);
        else if (!strcasecmp(el, "c_creataide"))                config.c_creataide = atoi(ChrPtr(migr_chardata));
        else if (!strcasecmp(el, "c_sleeping"))                 config.c_sleeping = atoi(ChrPtr(migr_chardata));
        else if (!strcasecmp(el, "c_initax"))                   config.c_initax = atoi(ChrPtr(migr_chardata));