From 973a2dae902c5d7c5f89754d538749bec0de71af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Wed, 25 Feb 2009 22:06:38 +0000 Subject: [PATCH] + correct FS-flags on citadel.co* on startup + separate automatical generated config files * move these automatic generated files to /var/lib/citadel/data in the debian build * move citadel.control and citadel.config on upgrade if we find them in the old location. --- citadel/citadel_dirs.c | 16 +++++++++++++--- citadel/citadel_dirs.h | 1 + citadel/configure.ac | 12 ++++++++++++ citadel/control.c | 5 +++++ citadel/debian/citadel-server.postinst | 11 +++++++++++ citadel/debian/rules | 1 + 6 files changed, 43 insertions(+), 3 deletions(-) diff --git a/citadel/citadel_dirs.c b/citadel/citadel_dirs.c index fe187f019..9d7085bb7 100644 --- a/citadel/citadel_dirs.c +++ b/citadel/citadel_dirs.c @@ -40,6 +40,7 @@ char ctdl_message_dir[PATH_MAX]="messages"; char ctdl_usrpic_dir[PATH_MAX]="userpics"; char ctdl_bbsbase_dir[PATH_MAX]=""; char ctdl_etc_dir[PATH_MAX]=""; +char ctdl_autoetc_dir[PATH_MAX]=""; /* attention! this may be non volatile on some oses */ char ctdl_run_dir[PATH_MAX]=""; char ctdl_spool_dir[PATH_MAX]="network"; @@ -133,6 +134,15 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, #endif StripSlashes(ctdl_sbin_dir, 1); StripSlashes(ctdl_bin_dir, 1); + +#ifndef HAVE_AUTO_ETC_DIR + basedir=ctdldir; +#else + basedir=AUTO_ETC_DIR; +#endif + COMPUTE_DIRECTORY(ctdl_autoetc_dir); + StripSlashes(ctdl_autoetc_dir, 1); + #ifndef HAVE_ETC_DIR basedir=ctdldir; #else @@ -218,18 +228,18 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, snprintf(file_arcq, sizeof file_arcq, "%srefcount_adjustments.dat", - ctdl_etc_dir); + ctdl_autoetc_dir); StripSlashes(file_arcq, 0); snprintf(file_citadel_control, sizeof file_citadel_control, "%scitadel.control", - ctdl_etc_dir + ctdl_autoetc_dir ); StripSlashes(file_citadel_control, 0); snprintf(file_citadel_config, sizeof file_citadel_config, "%scitadel.config", - ctdl_etc_dir); + ctdl_autoetc_dir); StripSlashes(file_citadel_config, 0); snprintf(file_citadel_rc, sizeof file_citadel_rc, diff --git a/citadel/citadel_dirs.h b/citadel/citadel_dirs.h index 4c2d67ffc..897986d6d 100644 --- a/citadel/citadel_dirs.h +++ b/citadel/citadel_dirs.h @@ -20,6 +20,7 @@ extern char ctdl_key_dir[PATH_MAX]; extern char ctdl_message_dir[PATH_MAX]; extern char ctdl_usrpic_dir[PATH_MAX]; extern char ctdl_etc_dir[PATH_MAX]; +extern char ctdl_autoetc_dir[PATH_MAX]; extern char ctdl_run_dir[PATH_MAX]; extern char ctdl_spool_dir[PATH_MAX]; extern char ctdl_netout_dir[PATH_MAX]; diff --git a/citadel/configure.ac b/citadel/configure.ac index 84d935cf5..6a59d0076 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -95,6 +95,18 @@ AC_ARG_WITH(sysconfdir, ] ) +dnl Checks for the Configdir +AC_ARG_WITH(autosysconfdir, + [ --with-autosysconfdir directory to store the automaticaly maintained configs under], + [ if test "x$withval" != "xno" ; then + AC_DEFINE(HAVE_AUTO_ETC_DIR, [], [should we search our automatic config in an alternate place?]) + AC_DEFINE_UNQUOTED(AUTO_ETC_DIR, "$withval", [where to search our automatic config files]) + MAKE_AUTO_ETC_DIR=$withval + AC_SUBST(MAKE_AUTO_ETC_DIR) + fi + ] +) + dnl Checks for where to put our utilities AC_ARG_WITH(utility-bindir, [ --with-utility-bindir directory where to find helper binaries], diff --git a/citadel/control.c b/citadel/control.c index 305ed3d23..03ffa7c75 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -164,6 +164,8 @@ void get_control(void) if (control_fp != NULL) { lock_control(); fchown(fileno(control_fp), config.c_ctdluid, -1); + fchmod(fileno(control_fp), + S_IRUSR|S_IWUSR); } } if (control_fp == NULL) { @@ -171,6 +173,8 @@ void get_control(void) if (control_fp != NULL) { lock_control(); fchown(fileno(control_fp), config.c_ctdluid, -1); + fchmod(fileno(control_fp), + S_IRUSR|S_IWUSR); memset(&CitControl, 0, sizeof(struct CitControl)); fwrite(&CitControl, sizeof(struct CitControl), 1, control_fp); @@ -188,6 +192,7 @@ void get_control(void) fread(&CitControl, sizeof(struct CitControl), 1, control_fp); already_have_control = 1; chown(file_citadel_control, config.c_ctdluid, (-1)); + } /* diff --git a/citadel/debian/citadel-server.postinst b/citadel/debian/citadel-server.postinst index f9120899d..25663616f 100644 --- a/citadel/debian/citadel-server.postinst +++ b/citadel/debian/citadel-server.postinst @@ -40,6 +40,17 @@ case "$1" in #This is not debian conformant, and uniq to the citadel.org debs. export ALTER_ETC_SERVICES=yes # + if test -S /var/run/citadel/citadel.socket; then + /usr/sbin/sendcommand "DOWN" + fi + while test -S /var/run/citadel/citadel.socket; do + sleep 1 + done + if test ! -f /var/lib/citadel/data/citadel.control -a -f /etc/citadel/citadel.control; then + mv /etc/citadel/citadel.control /var/lib/citadel/data/ + mv /etc/citadel/citadel.config /var/lib/citadel/data/ + fi + echo -n "applying your settings.... " /usr/lib/citadel-server/setup -q echo "done" diff --git a/citadel/debian/rules b/citadel/debian/rules index d3a750c08..e29c9d0e5 100755 --- a/citadel/debian/rules +++ b/citadel/debian/rules @@ -50,6 +50,7 @@ configure-stamp: --with-staticdatadir=/etc/citadel/ \ --with-ssldir=/etc/ssl/citadel/ \ --with-utility-bindir=/usr/lib/citadel-server/ \ + --with-autosysconfdir=/var/lib/citadel/data/ \ --with-pam \ --with-db \ --with-zlib \ -- 2.30.2