char file_crpt_file_cer[PATH_MAX]="";
char file_chkpwd[PATH_MAX]="";
char file_base64[PATH_MAX]="";
+char file_guesstimezone[PATH_MAX]="";
char file_funambol_msg[PATH_MAX] = "";
char file_dpsam_conf[PATH_MAX] = "";
char file_dspam_log[PATH_MAX] = "";
"%sbase64",
ctdl_utilbin_dir);
+ snprintf(file_guesstimezone,
+ sizeof file_guesstimezone,
+ "%sguesstimezone.sh",
+ ctdl_utilbin_dir);
+
snprintf(file_dpsam_conf,
sizeof file_dpsam_conf,
"%sdspam.conf",
DBG_PRINT(file_crpt_file_cer);
DBG_PRINT(file_chkpwd);
DBG_PRINT(file_base64);
+ DBG_PRINT(file_guesstimezone);
DBG_PRINT(file_funambol_msg);
}
extern char file_crpt_file_cer[PATH_MAX];
extern char file_chkpwd[PATH_MAX];
extern char file_base64[PATH_MAX];
+extern char file_guesstimezone[PATH_MAX];
extern char file_dpsam_conf[PATH_MAX];
extern char file_dspam_log[PATH_MAX];
--- /dev/null
+#!/bin/sh
+
+# guesstimezone.sh - an ugly hack of a script to try to guess the time
+# zone currently in use on the host system, and output its name.
+
+# Copyright (c) by Art Cancro
+
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 3 of the License, or (at your option)
+# any later version.
+
+# 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.
+
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 675 Mass Ave, Cambridge, MA 02139, USA.
+
+md5sum </dev/null >/dev/null 2>/dev/null || exit 1
+
+LOCALTIMESUM=`md5sum /etc/localtime | awk ' { print $1 } ' 2>/dev/null`
+find /usr/share/zoneinfo -type f -print | while read filename
+do
+ THISTIMESUM=`md5sum $filename | awk ' { print $1 } '`
+ if [ $LOCALTIMESUM = $THISTIMESUM ] ; then
+ echo $filename | cut -c21-
+ exit 0
+ fi
+done 2>/dev/null
+exit 2
return;
}
+
+/*
+ * Attempt to guess the name of the time zone currently in use
+ * on the underlying host system.
+ */
+void guess_time_zone(void) {
+ FILE *fp;
+ char buf[PATH_MAX];
+
+ fp = popen(file_guesstimezone, "r");
+ 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);
+ CtdlLogPrintf(CTDL_INFO, "Configuring timezone: %s\n", config.c_default_cal_zone);
+ }
+ fclose(fp);
+ }
+}
+
+
/*
* Do various things to our configuration file
*/
config.c_xmpp_s2s_port = 5269;
}
+ if (IsEmptyStr(config.c_default_cal_zone)) {
+ guess_time_zone();
+ }
+
put_config();
}