config migration endless typing meow
authorArt Cancro <ajc@uncensored.citadel.org>
Tue, 5 May 2015 15:18:04 +0000 (11:18 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Tue, 5 May 2015 15:18:04 +0000 (11:18 -0400)
citadel/modules/smtp/serv_smtpqueue.c
citadel/modules/smtp/smtp_clienthandlers.c
citadel/modules/smtp/smtp_util.c
citadel/modules/upgrade/serv_upgrade.c
citadel/modules/vcard/serv_vcard.c
citadel/modules/wiki/serv_wiki.c

index 56ab4356ae55508e02edbcd4958f5ea5d007ff7f..a38dbe74262bf71c9ae7c3b3b42ca4aa9e46af74 100644 (file)
@@ -697,7 +697,7 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt, ParsedURL *Relay)
 
        CM_SetField(bmsg, eOriginalRoom, HKEY(MAILROOM));
        CM_SetField(bmsg, eAuthor, HKEY("Citadel"));
-       CM_SetField(bmsg, eNodeName, CFG_KEY(c_nodename));
+       CM_SetField(bmsg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
        CM_SetField(bmsg, eMsgSubject, HKEY("Delivery Status Notification (Failure)"));
        CM_SetAsFieldSB(bmsg, eMesageText, &BounceMB);
 
index 198649e1f2c00522b2f738b7ee04cbf15e1840ef..bab1d7159a80aa2ac6b365478537a7bdbee62f69 100644 (file)
  * RFC 2822 - Internet Message Format
  * RFC 2920 - SMTP Service Extension for Command Pipelining
  *
- * Copyright (c) 1998-2012 by the citadel.org team
+ * Copyright (c) 1998-2015 by the citadel.org team
  *
- *  This program is open source software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3.
- *  
- *  
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  
- *  
- *  
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  */
 
 #include "sysdep.h"
@@ -144,8 +138,7 @@ eNextState SMTPC_send_EHLO(SmtpOutMsg *Msg)
        /* At this point we know we are talking to a real SMTP server */
 
        /* Do a EHLO command.  If it fails, try the HELO command. */
-       StrBufPrintf(Msg->IO.SendBuf.Buf,
-                    "EHLO %s\r\n", config.c_fqdn);
+       StrBufPrintf(Msg->IO.SendBuf.Buf, "EHLO %s\r\n", CtdlGetconfigStr("c_fqdn"));
 
        SMTP_DBG_SEND();
        return eReadMessage;
@@ -180,8 +173,7 @@ eNextState SMTPC_read_EHLO_reply(SmtpOutMsg *Msg)
 eNextState STMPC_send_HELO(SmtpOutMsg *Msg)
 {
        AsyncIO *IO = &Msg->IO;
-       StrBufPrintf(Msg->IO.SendBuf.Buf,
-                    "HELO %s\r\n", config.c_fqdn);
+       StrBufPrintf(Msg->IO.SendBuf.Buf, "HELO %s\r\n", CtdlGetconfigStr("c_fqdn"));
 
        SMTP_DBG_SEND();
        return eReadMessage;
index 8609f91133bcd86e71d7c0f73ebeec569fe7fc8e..1cca96e3afced7b091e5c96a7c65d051c3c1e209 100644 (file)
  * The VRFY and EXPN commands have been removed from this implementation
  * because nobody uses these commands anymore, except for spammers.
  *
- * Copyright (c) 1998-2012 by the citadel.org team
+ * Copyright (c) 1998-2015 by the citadel.org team
  *
- *  This program is open source software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 3.
- *  
- *  
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  
- *  
- *  
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  */
 
 #include "sysdep.h"
@@ -129,11 +123,7 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
        strcpy(bounceto, "");
        boundary = NewStrBufPlain(HKEY("=_Citadel_Multipart_"));
 
-       StrBufAppendPrintf(boundary,
-                          "%s_%04x%04x",
-                          config.c_fqdn,
-                          getpid(),
-                          ++seq);
+       StrBufAppendPrintf(boundary, "%s_%04x%04x", CtdlGetConfigStr("c_fqdn"), getpid(), ++seq);
 
        lines = num_tokens(instr, '\n');
 
@@ -163,11 +153,9 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
        bmsg->cm_format_type = FMT_RFC822;
        CM_SetField(bmsg, eAuthor, HKEY("Citadel"));
        CM_SetField(bmsg, eOriginalRoom, HKEY(MAILROOM));
-       CM_SetField(bmsg, eNodeName, CFG_KEY(c_nodename));
+       CM_SetField(bmsg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
        CM_SetField(bmsg, eMsgSubject, HKEY("Delivery Status Notification (Failure)"));
-       StrBufAppendBufPlain(
-               BounceMB,
-               HKEY("Content-type: multipart/mixed; boundary=\""), 0);
+       StrBufAppendBufPlain(BounceMB, HKEY("Content-type: multipart/mixed; boundary=\""), 0);
        StrBufAppendBuf(BounceMB, boundary, 0);
        StrBufAppendBufPlain(BounceMB, HKEY("\"\r\n"), 0);
        StrBufAppendBufPlain(BounceMB, HKEY("MIME-Version: 1.0\r\n"), 0);
@@ -310,7 +298,7 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt)
 
                /* If not, post it in the Aide> room */
                if (successful_bounce == 0) {
-                       CtdlSubmitMsg(bmsg, NULL, config.c_aideroom, QP_EADDR);
+                       CtdlSubmitMsg(bmsg, NULL, CtdlGetConfigStr("c_aideroom"), QP_EADDR);
                }
 
                /* Free up the memory we used */
index fc8c1d58e7f1769f3d45b4d5354a33aa77fe784d..7cd9c10b5e5e34336081b5cee83563e6104c3f7f 100644 (file)
@@ -245,8 +245,8 @@ void guess_time_zone(void) {
        if (fp) {
                if (fgets(buf, sizeof buf, fp) && (strlen(buf) > 2)) {
                        buf[strlen(buf)-1] = 0;
-                       safestrncpy(config.c_default_cal_zone, buf, sizeof config.c_default_cal_zone);
-                       syslog(LOG_INFO, "Configuring timezone: %s", config.c_default_cal_zone);
+                       CtdlSetConfigStr("c_default_cal_zone", buf);
+                       syslog(LOG_INFO, "Configuring timezone: %s", buf);
                }
                fclose(fp);
        }
@@ -261,36 +261,38 @@ void guess_time_zone(void) {
  */
 void update_config(void) {
 
-       if (CitControl.MM_hosted_upgrade_level < 606) {
+       oldver = CitControl.MM_hosted_upgrade_level;
+
+       if (oldver < 606) {
                config.c_rfc822_strict_from = 0;
        }
 
-       if (CitControl.MM_hosted_upgrade_level < 609) {
+       if (oldver < 609) {
                config.c_purge_hour = 3;
        }
 
-       if (CitControl.MM_hosted_upgrade_level < 615) {
+       if (oldver < 615) {
                config.c_ldap_port = 389;
        }
 
-       if (CitControl.MM_hosted_upgrade_level < 623) {
+       if (oldver < 623) {
                strcpy(config.c_ip_addr, "*");
        }
 
-       if (CitControl.MM_hosted_upgrade_level < 650) {
+       if (oldver < 650) {
                config.c_enable_fulltext = 1;
        }
 
-       if (CitControl.MM_hosted_upgrade_level < 652) {
+       if (oldver < 652) {
                config.c_auto_cull = 1;
        }
 
-       if (CitControl.MM_hosted_upgrade_level < 725) {
+       if (oldver < 725) {
                config.c_xmpp_c2s_port = 5222;
                config.c_xmpp_s2s_port = 5269;
        }
 
-       if (CitControl.MM_hosted_upgrade_level < 830) {
+       if (oldver < 830) {
                config.c_nntp_port = 119;
                config.c_nntps_port = 563;
        }
@@ -298,8 +300,6 @@ void update_config(void) {
        if (IsEmptyStr(config.c_default_cal_zone)) {
                guess_time_zone();
        }
-
-       put_config();
 }
 
 
index 39820f7762dc7a821609c060995ec6ecb99c77c0..12e39696d4a9c2554d33a6af8273057a6d94aca2 100644 (file)
@@ -2,7 +2,7 @@
  * A server-side module for Citadel which supports address book information
  * using the standard vCard format.
  * 
- * Copyright (c) 1999-2012 by the citadel.org team
+ * Copyright (c) 1999-2015 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
@@ -385,7 +385,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg, recptypes *recp) {
 
        /* If users cannot create their own accounts, they cannot re-register either. */
        if ( (yes_my_citadel_config) &&
-            (config.c_disable_newu) &&
+            (CtdlGetConfigInt("c_disable_newu")) &&
             (CCC->user.axlevel < AxAideU) &&
             (CCC->vcard_updated_by_ldap==0) )
        {
@@ -433,7 +433,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg, recptypes *recp) {
        /* Insert or replace RFC2739-compliant free/busy URL */
        if (yes_my_citadel_config) {
                sprintf(buf, "http://%s/%s.vfb",
-                       config.c_fqdn,
+                       CtdlGetConfigStr("c_fqdn"),
                        usbuf.fullname);
                for (i=0; buf[i]; ++i) {
                        if (buf[i] == ' ') buf[i] = '_';
@@ -723,7 +723,7 @@ void cmd_regi(char *argbuf) {
        }
 
        /* If users cannot create their own accounts, they cannot re-register either. */
-       if ( (config.c_disable_newu) && (CCC->user.axlevel < AxAideU) ) {
+       if ( (CtdlGetConfigInt("c_disable_newu")) && (CCC->user.axlevel < AxAideU) ) {
                cprintf("%d Self-service registration is not allowed here.\n",
                        ERROR + HIGHER_ACCESS_REQUIRED);
        }
@@ -865,7 +865,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
 
 #ifdef HAVE_GETPWUID_R
        /* If using host auth mode, we add an email address based on the login */
-       if (config.c_auth_mode == AUTHMODE_HOST) {
+       if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
                struct passwd pwd;
                char pwd_buffer[SIZ];
                
@@ -876,7 +876,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
                syslog(LOG_DEBUG, "Searching for uid %d", usbuf->uid);
                if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer, &result) == 0) {
 #endif // HAVE_GETPWUID_R
-                       snprintf(buf, sizeof buf, "%s@%s", pwd.pw_name, config.c_fqdn);
+                       snprintf(buf, sizeof buf, "%s@%s", pwd.pw_name, CtdlGetConfigStr("c_fqdn"));
                        vcard_add_prop(v, "email;internet", buf);
                        need_default_vcard=0;
                }
@@ -889,7 +889,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
         * Is this an LDAP session?  If so, copy various LDAP attributes from the directory entry
         * into the user's vCard.
         */
-       if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+       if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
             //uid_t ldap_uid;
            int found_user;
             char ldap_cn[512];
@@ -907,7 +907,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
 #endif
        if (need_default_vcard!=0) {
          /* Everyone gets an email address based on their display name */
-         snprintf(buf, sizeof buf, "%s@%s", usbuf->fullname, config.c_fqdn);
+         snprintf(buf, sizeof buf, "%s@%s", usbuf->fullname, CtdlGetConfigStr("c_fqdn"));
          for (i=0; buf[i]; ++i) {
                if (buf[i] == ' ') buf[i] = '_';
          }
@@ -938,7 +938,7 @@ void vcard_purge(struct ctdluser *usbuf) {
        msg->cm_format_type = 0;
        CM_SetField(msg, eAuthor, usbuf->fullname, strlen(usbuf->fullname));
        CM_SetField(msg, eOriginalRoom, HKEY(ADDRESS_BOOK_ROOM));
-       CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
+       CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
        CM_SetField(msg, eMesageText, HKEY("Purge this vCard\n"));
 
        len = snprintf(buf, sizeof buf, VCARD_EXT_FORMAT,
@@ -1281,7 +1281,7 @@ void vcard_session_login_hook(void) {
         * Is this an LDAP session?  If so, copy various LDAP attributes from the directory entry
         * into the user's vCard.
         */
-       if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+       if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
                v = vcard_get_user(&CCC->user);
                if (v) {
                        if (Ctdl_LDAP_to_vCard(CCC->ldap_dn, v)) {
@@ -1553,7 +1553,7 @@ CTDL_MODULE_INIT(vcard)
                }
 
                /* for postfix tcpdict */
-               CtdlRegisterServiceHook(config.c_pftcpdict_port,        /* Postfix */
+               CtdlRegisterServiceHook(CtdlGetConfigInt("c_pftcpdict_port"),   /* Postfix */
                                        NULL,
                                        check_get_greeting,
                                        check_get,
index 44a38153c76ab49a991a9c5c566b0ed94565e6db..269777c944419fedd52b17db1009bba002c56c7a 100644 (file)
@@ -643,7 +643,7 @@ void wiki_rev(char *pagename, char *rev, char *operation)
                        CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
                        CM_SetField(msg, erFc822Addr, CCC->cs_inet_email, strlen(CCC->cs_inet_email));
                        CM_SetField(msg, eOriginalRoom, CCC->room.QRname, strlen(CCC->room.QRname));
-                       CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
+                       CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
                        CM_SetField(msg, eExclusiveID, pagename, strlen(pagename));
                        msgnum = CtdlSubmitMsg(msg, NULL, "", 0);       /* Replace the current revision */
                }