X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fcitadel_dirs.c;h=9bc46c8e917cc4f9fc7e4dd3dfb254c4bfe093c3;hb=4eb74b26380dfde31c86c685f0589e0c653aebf0;hp=f4233cefb9f91781dc15f2b3158df955c6137c98;hpb=bf9c6f06eea1bc9d99b53df6d7c08944aafcfc19;p=citadel.git diff --git a/citadel/citadel_dirs.c b/citadel/citadel_dirs.c index f4233cefb..9bc46c8e9 100644 --- a/citadel/citadel_dirs.c +++ b/citadel/citadel_dirs.c @@ -1,5 +1,22 @@ -#include "sysdep.h" -#include +/* + * citadel_dirs.c : calculate pathnames for various files used in the Citadel system + * + * Copyright (c) 1987-2009 by the citadel.org team + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #include #include #include @@ -20,7 +37,7 @@ #endif #include - +#include #include "citadel.h" @@ -33,6 +50,7 @@ char ctdl_data_dir[PATH_MAX]="data"; char ctdl_dspam_dir[PATH_MAX]="dspam"; char ctdl_file_dir[PATH_MAX]="files"; char ctdl_hlp_dir[PATH_MAX]="help"; +char ctdl_shared_dir[PATH_MAX]=""; char ctdl_image_dir[PATH_MAX]="images"; char ctdl_info_dir[PATH_MAX]="info"; char ctdl_key_dir[PATH_MAX]=SSL_DIR; @@ -40,6 +58,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"; @@ -66,11 +85,15 @@ char file_crpt_file_csr[PATH_MAX]=""; 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] = ""; + + + #define COMPUTE_DIRECTORY(SUBDIR) memcpy(dirbuffer,SUBDIR, sizeof dirbuffer);\ snprintf(SUBDIR,sizeof SUBDIR, "%s%s%s%s%s%s%s", \ (home&!relh)?ctdl_home_directory:basedir, \ @@ -84,7 +107,7 @@ char file_dspam_log[PATH_MAX] = ""; #define DBG_PRINT(A) if (dbg==1) fprintf (stderr,"%s : %s \n", #A, A) -void calc_dirs_n_files(int relh, int home, const char *relhome, const char *ctdldir, int dbg) +void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, int dbg) { const char* basedir = ""; char dirbuffer[PATH_MAX] = ""; @@ -93,6 +116,7 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char *ctd * Ok, we keep our binaries either in the citadel base dir, * or in /usr/sbin / /usr/bin */ + StripSlashes(ctdldir, 1); #ifdef HAVE_ETC_DIR snprintf(ctdl_sbin_dir, sizeof ctdl_sbin_dir, "/usr/sbin/"); snprintf(ctdl_bin_dir, sizeof ctdl_bin_dir, "/usr/bin/"); @@ -100,6 +124,16 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char *ctd snprintf(ctdl_sbin_dir, sizeof ctdl_sbin_dir, ctdldir); snprintf(ctdl_bin_dir, sizeof ctdl_bin_dir, 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; @@ -108,6 +142,8 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char *ctd #endif COMPUTE_DIRECTORY(ctdl_netcfg_dir); COMPUTE_DIRECTORY(ctdl_etc_dir); + StripSlashes(ctdl_netcfg_dir, 1); + StripSlashes(ctdl_etc_dir, 1); #ifndef HAVE_UTILBIN_DIR basedir=ctdldir; @@ -115,6 +151,7 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char *ctd basedir=UTILBIN_DIR; #endif COMPUTE_DIRECTORY(ctdl_utilbin_dir); + StripSlashes(ctdl_utilbin_dir, 1); #ifndef HAVE_RUN_DIR basedir=ctdldir; @@ -122,14 +159,25 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char *ctd basedir=RUN_DIR; #endif COMPUTE_DIRECTORY(ctdl_run_dir); + StripSlashes(ctdl_run_dir, 1); #ifndef HAVE_STATICDATA_DIR basedir=ctdldir; #else basedir=STATICDATA_DIR; #endif - COMPUTE_DIRECTORY(ctdl_hlp_dir); COMPUTE_DIRECTORY(ctdl_message_dir); + StripSlashes(ctdl_message_dir, 1); + +#ifndef HAVE_HELP_DIR + basedir=ctdldir; +#else + basedir=HELP_DIR; +#endif + COMPUTE_DIRECTORY(ctdl_hlp_dir); + StripSlashes(ctdl_hlp_dir, 1); + COMPUTE_DIRECTORY(ctdl_shared_dir); + StripSlashes(ctdl_shared_dir, 1); #ifndef HAVE_DATA_DIR basedir=ctdldir; @@ -145,6 +193,17 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char *ctd COMPUTE_DIRECTORY(ctdl_info_dir); COMPUTE_DIRECTORY(ctdl_usrpic_dir); COMPUTE_DIRECTORY(ctdl_bbsbase_dir); + + StripSlashes(ctdl_bio_dir, 1); + StripSlashes(ctdl_bb_dir, 1); + StripSlashes(ctdl_data_dir, 1); + StripSlashes(ctdl_dspam_dir, 1); + StripSlashes(ctdl_file_dir, 1); + StripSlashes(ctdl_image_dir, 1); + StripSlashes(ctdl_info_dir, 1); + StripSlashes(ctdl_usrpic_dir, 1); + StripSlashes(ctdl_bbsbase_dir, 1); + #ifndef HAVE_SPOOL_DIR basedir=ctdldir; #else @@ -154,83 +213,98 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char *ctd COMPUTE_DIRECTORY(ctdl_netout_dir); COMPUTE_DIRECTORY(ctdl_netin_dir); + StripSlashes(ctdl_spool_dir, 1); + StripSlashes(ctdl_netout_dir, 1); + StripSlashes(ctdl_netin_dir, 1); + /* ok, now we know the dirs, calc some commonly used files */ 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, "%scitadel.rc", ctdl_etc_dir); - + StripSlashes(file_citadel_rc, 0); snprintf(file_lmtp_socket, sizeof file_lmtp_socket, "%slmtp.socket", ctdl_run_dir); - + StripSlashes(file_lmtp_socket, 0); snprintf(file_lmtp_unfiltered_socket, sizeof file_lmtp_socket, "%slmtp-unfiltered.socket", ctdl_run_dir); - + StripSlashes(file_lmtp_unfiltered_socket, 0); snprintf(file_citadel_socket, sizeof file_citadel_socket, "%scitadel.socket", ctdl_run_dir); + StripSlashes(file_citadel_socket, 0); snprintf(file_pid_file, sizeof file_pid_file, "%scitadel.pid", ctdl_run_dir); + StripSlashes(file_pid_file, 0); snprintf(file_pid_paniclog, sizeof file_pid_paniclog, "%spanic.log", ctdl_home_directory); + StripSlashes(file_pid_paniclog, 0); snprintf(file_crpt_file_key, sizeof file_crpt_file_key, "%s/citadel.key", ctdl_key_dir); + StripSlashes(file_crpt_file_key, 0); snprintf(file_crpt_file_csr, sizeof file_crpt_file_csr, "%s/citadel.csr", ctdl_key_dir); + StripSlashes(file_crpt_file_csr, 0); snprintf(file_crpt_file_cer, sizeof file_crpt_file_cer, "%s/citadel.cer", ctdl_key_dir); - + StripSlashes(file_crpt_file_cer, 0); snprintf(file_chkpwd, sizeof file_chkpwd, "%schkpwd", ctdl_utilbin_dir); - + StripSlashes(file_chkpwd, 0); snprintf(file_base64, sizeof file_base64, "%sbase64", ctdl_utilbin_dir); + StripSlashes(file_base64, 0); + snprintf(file_guesstimezone, + sizeof file_guesstimezone, + "%sguesstimezone.sh", + ctdl_utilbin_dir); snprintf(file_dpsam_conf, sizeof file_dpsam_conf, "%sdspam.conf", ctdl_etc_dir); + StripSlashes(file_dpsam_conf, 0); snprintf(file_dspam_log, sizeof file_dspam_log, "%sdspam.log", ctdl_home_directory); - + StripSlashes(file_dspam_log, 0); /* * DIRTY HACK FOLLOWS! due to configs in the network dir in the * legacy installations, we need to calculate ifdeffed here. @@ -244,12 +318,13 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char *ctd ctdl_spool_dir #endif ); - + StripSlashes(file_mail_aliases, 0); snprintf(file_funambol_msg, sizeof file_funambol_msg, "%sfunambol_newmail_soap.xml", - ctdl_spool_dir); - + ctdl_shared_dir); + StripSlashes(file_funambol_msg, 0); + DBG_PRINT(ctdl_bio_dir); DBG_PRINT(ctdl_bb_dir); DBG_PRINT(ctdl_data_dir); @@ -286,6 +361,7 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, const char *ctd DBG_PRINT(file_crpt_file_cer); DBG_PRINT(file_chkpwd); DBG_PRINT(file_base64); + DBG_PRINT(file_guesstimezone); DBG_PRINT(file_funambol_msg); }