exit(CTDLEXIT_HOME);
}
- memset(&config, 0, sizeof(struct legacy_config));
+ memset(&lconfig, 0, sizeof(struct legacy_config));
cfp = fopen(file_citadel_config, "rb");
if (cfp != NULL) {
if (CtdlGetConfigLong("c_config_created_or_migrated") <= 0) {
fprintf(stderr, "Exiting to prevent data corruption.\n");
exit(CTDLEXIT_CONFIG);
}
- rv = fread((char *) &config, sizeof(struct legacy_config), 1, cfp);
+ rv = fread((char *) &lconfig, sizeof(struct legacy_config), 1, cfp);
if (rv != 1)
{
fprintf(stderr,
struct cdbdata *cdb;
int key_len = strlen(key);
+ if (IsEmptyStr(key)) return(NULL);
+
+ /* Temporary hack to make sure we didn't mess up any porting - FIXME remove this after testing thoroughly */
+ if (!strncmp(key, "config", 6)) {
+ syslog(LOG_EMERG, "You requested a key starting with 'config' which probably means a porting error: %s", key);
+ abort();
+ }
+
/* First look in memory */
if (GetHash(ctdlconfig, key, key_len, (void *)&value))
{
* These functions implement the portions of AUTHMODE_LDAP and AUTHMODE_LDAP_AD which
* actually speak to the LDAP server.
*
- * Copyright (c) 2011-2014 by the citadel.org development team.
+ * Copyright (c) 2011-2015 by the citadel.org development 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.
#include "citadel_ldap.h"
#include "ctdl_module.h"
#include "user_ops.h"
+#include "config.h"
#ifdef HAVE_LDAP
#define LDAP_DEPRECATED 1 /* Suppress libldap's warning that we are using deprecated API calls */
char server_url[256];
int ret;
- snprintf(server_url, sizeof server_url, "ldap://%s:%d", config.c_ldap_host, config.c_ldap_port);
+ snprintf(server_url, sizeof server_url, "ldap://%s:%d", CtdlGetConfigStr("c_ldap_host"), CtdlGetConfigInt("c_ldap_port"));
ret = ldap_initialize(ld, server_url);
if (ret != LDAP_SUCCESS) {
syslog(LOG_ALERT, "LDAP: Could not connect to %s : %s",
ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ctdl_require_ldap_version);
ldap_set_option(ldserver, LDAP_OPT_REFERRALS, (void *)LDAP_OPT_OFF);
- striplt(config.c_ldap_bind_dn);
- striplt(config.c_ldap_bind_pw);
- syslog(LOG_DEBUG, "LDAP bind DN: %s", config.c_ldap_bind_dn);
+ striplt(CtdlGetConfigStr("c_ldap_bind_dn"));
+ striplt(CtdlGetConfigStr("c_ldap_bind_pw"));
+ syslog(LOG_DEBUG, "LDAP bind DN: %s", CtdlGetConfigStr("c_ldap_bind_dn"));
i = ldap_simple_bind_s(ldserver,
- (!IsEmptyStr(config.c_ldap_bind_dn) ? config.c_ldap_bind_dn : NULL),
- (!IsEmptyStr(config.c_ldap_bind_pw) ? config.c_ldap_bind_pw : NULL)
+ (!IsEmptyStr(CtdlGetConfigStr("c_ldap_bind_dn")) ? CtdlGetConfigStr("c_ldap_bind_dn") : NULL),
+ (!IsEmptyStr(CtdlGetConfigStr("c_ldap_bind_pw")) ? CtdlGetConfigStr("c_ldap_bind_pw") : NULL)
);
if (i != LDAP_SUCCESS) {
syslog(LOG_ALERT, "LDAP: Cannot bind: %s (%d)", ldap_err2string(i), i);
tv.tv_sec = 10;
tv.tv_usec = 0;
- if (config.c_auth_mode == AUTHMODE_LDAP_AD) {
+ if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD) {
if (lookup_based_on_username != 0)
snprintf(searchstring, sizeof(searchstring), "(displayName=%s)",username);
else
syslog(LOG_DEBUG, "LDAP search: %s", searchstring);
(void) ldap_search_ext_s(
ldserver, /* ld */
- config.c_ldap_base_dn, /* base */
+ CtdlGetConfigStr("c_ldap_base_dn"), /* base */
LDAP_SCOPE_SUBTREE, /* scope */
searchstring, /* filter */
NULL, /* attrs (all attributes) */
syslog(LOG_DEBUG, "dn = %s", user_dn);
}
- if (config.c_auth_mode == AUTHMODE_LDAP_AD) {
+ if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD) {
values = ldap_get_values(ldserver, search_result, "displayName");
if (values) {
if (values[0]) {
}
/* If we know the username is the CN/displayName, we already set the uid*/
if (lookup_based_on_username==0) {
- if (config.c_auth_mode == AUTHMODE_LDAP_AD) {
+ if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD) {
values = ldap_get_values(ldserver, search_result, "objectGUID");
if (values) {
if (values[0]) {
ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ctdl_require_ldap_version);
ldap_set_option(ldserver, LDAP_OPT_REFERRALS, (void *)LDAP_OPT_OFF);
- striplt(config.c_ldap_bind_dn);
- striplt(config.c_ldap_bind_pw);
- syslog(LOG_DEBUG, "LDAP bind DN: %s", config.c_ldap_bind_dn);
+ striplt(CtdlGetConfigStr("c_ldap_bind_dn"));
+ striplt(CtdlGetConfigStr("c_ldap_bind_pw"));
+ syslog(LOG_DEBUG, "LDAP bind DN: %s", CtdlGetConfigStr("c_ldap_bind_dn"));
i = ldap_simple_bind_s(ldserver,
- (!IsEmptyStr(config.c_ldap_bind_dn) ? config.c_ldap_bind_dn : NULL),
- (!IsEmptyStr(config.c_ldap_bind_pw) ? config.c_ldap_bind_pw : NULL)
+ (!IsEmptyStr(CtdlGetConfigStr("c_ldap_bind_dn")) ? CtdlGetConfigStr("c_ldap_bind_dn") : NULL),
+ (!IsEmptyStr(CtdlGetConfigStr("c_ldap_bind_pw")) ? CtdlGetConfigStr("c_ldap_bind_pw") : NULL)
);
if (i != LDAP_SUCCESS) {
syslog(LOG_ALERT, "LDAP: Cannot bind: %s (%d)", ldap_err2string(i), i);
/*
* Bring external RSS feeds into rooms.
*
- * Copyright (c) 2007-2012 by the citadel.org team
+ * Copyright (c) 2007-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.
CM_SetField(&SaveMsg->Msg, eAuthor, HKEY("rss"));
}
- CM_SetField(&SaveMsg->Msg, eNodeName, CFG_KEY(c_nodename));
+ CM_SetField(&SaveMsg->Msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
if (SaveMsg->title != NULL) {
long len;
char *Sbj;
* This module glues libSieve to the Citadel server in order to implement
* the Sieve mailbox filtering language (RFC 3028).
*
- * Copyright (c) 1987-2012 by the citadel.org team
+ * Copyright (c) 1987-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.
}
if (haschar(my.envelope_from, '@') == 0) {
strcat(my.envelope_from, "@");
- strcat(my.envelope_from, config.c_fqdn);
+ strcat(my.envelope_from, CtdlGetConfigStr("c_fqdn"));
}
/* Keep track of the envelope-to address (use body-to if not found) */
}
if (haschar(my.envelope_to, '@') == 0) {
strcat(my.envelope_to, "@");
- strcat(my.envelope_to, config.c_fqdn);
+ strcat(my.envelope_to, CtdlGetConfigStr("c_fqdn"));
}
CM_Free(msg);
extract_token(script_name, argbuf, 1, '|', sizeof script_name);
if (!IsEmptyStr(script_name)) {
cprintf("%d Transmit script now\n", SEND_LISTING);
- script_content = CtdlReadMessageBody(HKEY("000"), config.c_maxmsglen, NULL, 0, 0);
+ script_content = CtdlReadMessageBody(HKEY("000"), CtdlGetConfigLong("c_maxmsglen"), NULL, 0, 0);
msiv_putscript(&u, script_name, script_content);
changes_made = 1;
}
* The VRFY and EXPN commands have been removed from this implementation
* because nobody uses these commands anymore, except for spammers.
*
- * Copyright (c) 1998-2013 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.
/* If this config option is set, reject connections from problem
* addresses immediately instead of after they execute a RCPT
*/
- if ( (config.c_rbl_at_greeting) && (sSMTP->is_msa == 0) ) {
+ if ( (CtdlGetConfigInt("c_rbl_at_greeting")) && (sSMTP->is_msa == 0) ) {
if (rbl_check(message_to_spammer)) {
if (server_shutting_down)
cprintf("421 %s\r\n", message_to_spammer);
/* Note: the FQDN *must* appear as the first thing after the 220 code.
* Some clients (including citmail.c) depend on it being there.
*/
- cprintf("220 %s ESMTP Citadel server ready.\r\n", config.c_fqdn);
+ cprintf("220 %s ESMTP Citadel server ready.\r\n", CtdlGetConfigStr("c_fqdn"));
}
cprintf("250-Greetings and joyous salutations.\r\n");
}
cprintf("250-HELP\r\n");
- cprintf("250-SIZE %ld\r\n", config.c_maxmsglen);
+ cprintf("250-SIZE %ld\r\n", CtdlGetConfigLong("c_maxmsglen"));
#ifdef HAVE_OPENSSL
/*
/* Otherwise, make sure outsiders aren't trying to forge mail from
* this system (unless, of course, c_allow_spoofing is enabled)
*/
- else if (config.c_allow_spoofing == 0) {
+ else if (CtdlGetConfigInt("c_allow_spoofing") == 0) {
process_rfc822_addr(ChrPtr(sSMTP->from), user, node, name);
syslog(LOG_DEBUG, "Claimed envelope sender is '%s' == '%s' @ '%s' ('%s')",
ChrPtr(sSMTP->from), user, node, name
/* RBL check */
if ( (!CCC->logged_in) /* Don't RBL authenticated users */
&& (!sSMTP->is_lmtp) ) { /* Don't RBL LMTP clients */
- if (config.c_rbl_at_greeting == 0) { /* Don't RBL again if we already did it */
+ if (CtdlGetConfigInt("c_rbl_at_greeting") == 0) { /* Don't RBL again if we already did it */
if (rbl_check(message_to_spammer)) {
if (server_shutting_down)
cprintf("421 %s\r\n", message_to_spammer);
" by %s; %s\n",
ChrPtr(sSMTP->helo_node),
(long int) CCC->cs_UDSclientUID,
- config.c_fqdn,
+ CtdlGetConfigStr("c_fqdn"),
nowstamp);
}
else {
ChrPtr(sSMTP->helo_node),
CCC->cs_host,
CCC->cs_addr,
- config.c_fqdn,
+ CtdlGetConfigStr("c_fqdn"),
nowstamp);
}
}
- body = CtdlReadMessageBodyBuf(HKEY("."), config.c_maxmsglen, defbody, 1, NULL);
+ body = CtdlReadMessageBodyBuf(HKEY("."), CtdlGetConfigLong("c_maxmsglen"), defbody, 1, NULL);
FreeStrBuf(&defbody);
if (body == NULL) {
cprintf("550 Unable to save message: internal error.\r\n");
* to something ugly like "0000058008.Sent Items>" when the message
* is read with a Citadel client.
*/
- if ( (CCC->logged_in) && (config.c_rfc822_strict_from != CFG_SMTP_FROM_NOFILTER) ) {
+ if ( (CCC->logged_in) && (CtdlGetConfigInt("c_rfc822_strict_from") != CFG_SMTP_FROM_NOFILTER) ) {
int validemail = 0;
if (!CM_IsEmpty(msg, erFc822Addr) &&
- ((config.c_rfc822_strict_from == CFG_SMTP_FROM_CORRECT) ||
- (config.c_rfc822_strict_from == CFG_SMTP_FROM_REJECT) ) )
+ ((CtdlGetConfigInt("c_rfc822_strict_from") == CFG_SMTP_FROM_CORRECT) ||
+ (CtdlGetConfigInt("c_rfc822_strict_from") == CFG_SMTP_FROM_REJECT) ) )
{
if (!IsEmptyStr(CCC->cs_inet_email))
validemail = strcmp(CCC->cs_inet_email, msg->cm_fields[erFc822Addr]) == 0;
}
}
- if (!validemail && (config.c_rfc822_strict_from == CFG_SMTP_FROM_REJECT)) {
+ if (!validemail && (CtdlGetConfigInt("c_rfc822_strict_from") == CFG_SMTP_FROM_REJECT)) {
syslog(LOG_ERR, "invalid sender '%s' - rejecting this message", msg->cm_fields[erFc822Addr]);
cprintf("550 Invalid sender '%s' - rejecting this message.\r\n", msg->cm_fields[erFc822Addr]);
return;
}
- CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
- CM_SetField(msg, eHumanNode, CFG_KEY(c_humannode));
+ CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
+ CM_SetField(msg, eHumanNode, CtdlGetConfigStr("c_humannode"), strlen(CtdlGetConfigStr("c_humannode")));
CM_SetField(msg, eOriginalRoom, HKEY(MAILROOM));
if (sSMTP->preferred_sender_name != NULL)
CM_SetField(msg, eAuthor, SKEY(sSMTP->preferred_sender_name));
#endif
- CtdlRegisterServiceHook(config.c_smtp_port, /* SMTP MTA */
+ CtdlRegisterServiceHook(CtdlGetConfigInt("c_smtp_port"), /* SMTP MTA */
NULL,
smtp_mta_greeting,
smtp_command_loop,
CitadelServiceSMTP_MTA);
#ifdef HAVE_OPENSSL
- CtdlRegisterServiceHook(config.c_smtps_port,
+ CtdlRegisterServiceHook(CtdlGetConfigInt("c_smtps_port"), /* SMTPS MTA */
NULL,
smtps_greeting,
smtp_command_loop,
CitadelServiceSMTPS_MTA);
#endif
- CtdlRegisterServiceHook(config.c_msa_port, /* SMTP MSA */
+ CtdlRegisterServiceHook(CtdlGetConfigInt("c_msa_port"), /* SMTP MSA */
NULL,
smtp_msa_greeting,
smtp_command_loop,
* 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 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 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.
*/
#include "sysdep.h"
boundary = NewStrBufPlain(HKEY("=_Citadel_Multipart_"));
StrBufAppendPrintf(boundary,
"%s_%04x%04x",
- config.c_fqdn,
+ CtdlGetConfigStr("c_fqdn"),
getpid(),
++seq);
/* 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 */
/*
* Server-side module for Wiki rooms. This handles things like version control.
*
- * Copyright (c) 2009-2012 by the citadel.org team
+ * Copyright (c) 2009-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.
uuid,
Now,
CCC->user.fullname,
- config.c_nodename);
+ CtdlGetConfigStr("c_nodename"));
memolen = CtdlEncodeBase64(encoded_memo, memo, memolen, 0);
xmlesc(xmlbuf1, cptr->cs_inet_email, sizeof xmlbuf1),
xmlesc(xmlbuf2, cptr->user.fullname, sizeof xmlbuf2)
);
- cprintf("<group>%s</group>", xmlesc(xmlbuf1, config.c_humannode, sizeof xmlbuf1));
+ cprintf("<group>%s</group>", xmlesc(xmlbuf1, CtdlGetConfigStr("c_humannode"), sizeof xmlbuf1));
cprintf("</item>");
}