X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Futillib%2Fcitadel_dirs.c;h=e242db80d03287222e1433fb8dc065ddd84e2e85;hb=43a89745e7dd300cc0f0abe9239126de5edea8e3;hp=3b0afc1b6ca66b6dae715a5f0ac68afb20bdea96;hpb=73bcf6081a14008eb1020126273f133a324bb910;p=citadel.git diff --git a/citadel/utillib/citadel_dirs.c b/citadel/utillib/citadel_dirs.c index 3b0afc1b6..e242db80d 100644 --- a/citadel/utillib/citadel_dirs.c +++ b/citadel/utillib/citadel_dirs.c @@ -1,7 +1,7 @@ /* * citadel_dirs.c : calculate pathnames for various files used in the Citadel system * - * Copyright (c) 1987-2014 by the citadel.org team + * Copyright (c) 1987-2018 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. @@ -19,17 +19,16 @@ #include #include #include +#include #include #include "citadel.h" +#include "citadel_dirs.h" /* our directories... */ char ctdl_home_directory[PATH_MAX] = ""; char ctdl_bio_dir[PATH_MAX]="bio"; -char ctdl_bb_dir[PATH_MAX]="bitbucket"; 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"; @@ -42,8 +41,6 @@ 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"; -char ctdl_netout_dir[PATH_MAX]="network/spoolout"; -char ctdl_netin_dir[PATH_MAX]="network/spoolin"; char ctdl_netdigest_dir[PATH_MAX]="network/digest"; char ctdl_nettmp_dir[PATH_MAX]="network/spooltmp"; char ctdl_netcfg_dir[PATH_MAX]="netconfigs"; @@ -67,11 +64,7 @@ char file_crpt_file_key[PATH_MAX]=""; 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] = ""; @@ -152,25 +145,13 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, 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; #else basedir=DATA_DIR; #endif COMPUTE_DIRECTORY(ctdl_bio_dir); - COMPUTE_DIRECTORY(ctdl_bb_dir); COMPUTE_DIRECTORY(ctdl_data_dir); - COMPUTE_DIRECTORY(ctdl_dspam_dir); COMPUTE_DIRECTORY(ctdl_file_dir); COMPUTE_DIRECTORY(ctdl_image_dir); COMPUTE_DIRECTORY(ctdl_info_dir); @@ -178,9 +159,7 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, 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); @@ -193,14 +172,10 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, basedir=SPOOL_DIR; #endif COMPUTE_DIRECTORY(ctdl_spool_dir); - COMPUTE_DIRECTORY(ctdl_netout_dir); - COMPUTE_DIRECTORY(ctdl_netin_dir); COMPUTE_DIRECTORY(ctdl_netdigest_dir); COMPUTE_DIRECTORY(ctdl_nettmp_dir); StripSlashes(ctdl_spool_dir, 1); - StripSlashes(ctdl_netout_dir, 1); - StripSlashes(ctdl_netin_dir, 1); StripSlashes(ctdl_netdigest_dir, 1); StripSlashes(ctdl_nettmp_dir, 1); @@ -277,26 +252,11 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, "%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. @@ -311,18 +271,10 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, #endif ); StripSlashes(file_mail_aliases, 0); - snprintf(file_funambol_msg, - sizeof file_funambol_msg, - "%sfunambol_newmail_soap.xml", - ctdl_shared_dir); - StripSlashes(file_funambol_msg, 0); DBG_PRINT(ctdl_bio_dir); - DBG_PRINT(ctdl_bb_dir); DBG_PRINT(ctdl_data_dir); - DBG_PRINT(ctdl_dspam_dir); DBG_PRINT(ctdl_file_dir); - DBG_PRINT(ctdl_hlp_dir); DBG_PRINT(ctdl_image_dir); DBG_PRINT(ctdl_info_dir); DBG_PRINT(ctdl_key_dir); @@ -331,8 +283,6 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, DBG_PRINT(ctdl_etc_dir); DBG_PRINT(ctdl_run_dir); DBG_PRINT(ctdl_spool_dir); - DBG_PRINT(ctdl_netout_dir); - DBG_PRINT(ctdl_netin_dir); DBG_PRINT(ctdl_netdigest_dir); DBG_PRINT(ctdl_nettmp_dir); DBG_PRINT(ctdl_netcfg_dir); @@ -353,9 +303,7 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, DBG_PRINT(file_crpt_file_csr); DBG_PRINT(file_crpt_file_cer); DBG_PRINT(file_chkpwd); - DBG_PRINT(file_base64); DBG_PRINT(file_guesstimezone); - DBG_PRINT(file_funambol_msg); } @@ -376,24 +324,31 @@ void remove_digest_file(struct ctdlroom *room) ctdl_netdigest_dir, room->QRnumber); StripSlashes(buf, 0); - fprintf(stderr, "----> %s \n", buf); unlink(buf); } -FILE *create_digest_file(struct ctdlroom *room) +FILE *create_digest_file(struct ctdlroom *room, int forceCreate) { - char buf[PATH_MAX]; + struct stat stbuf; + char fn[PATH_MAX]; + int exists; FILE *fp; - snprintf(buf, PATH_MAX, "%s/%ld.eml", + snprintf(fn, PATH_MAX, "%s/%ld.eml", ctdl_netdigest_dir, room->QRnumber); - StripSlashes(buf, 0); - fprintf(stderr, "----> %s \n", buf); + StripSlashes(fn, 0); + + exists = stat(fn, &stbuf); + if (!forceCreate && (exists == -1)) + return NULL; - fp = fopen(buf, "w+"); + fp = fopen(fn, "w+"); if (fp == NULL) { - + syslog(LOG_EMERG, + "failed to create digest file %s: %s", + fn, + strerror(errno)); } return fp; } @@ -403,49 +358,41 @@ int create_dir(char *which, long ACCESS, long UID, long GID) { int rv; rv = mkdir(which, ACCESS); - if ((rv == -1) && (errno == EEXIST)) + if ((rv == -1) && (errno != EEXIST)) { + syslog(LOG_EMERG, + "failed to create directory %s: %s", + which, + strerror(errno)); return rv; + } rv = chmod(which, ACCESS); - if (rv == -1) + if (rv == -1) { + syslog(LOG_EMERG, + "failed to set permissions for directory %s: %s", + which, + strerror(errno)); return rv; + } rv = chown(which, UID, GID); + if (rv == -1) { + syslog(LOG_EMERG, + "failed to set owner for directory %s: %s", + which, + strerror(errno)); + return rv; + } return rv; } int create_run_directories(long UID, long GID) { - int rv; - - rv = create_dir(ctdl_info_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_bio_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_usrpic_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_message_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_hlp_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_image_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_bb_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_file_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_netcfg_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_spool_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_netout_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_netin_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_netdigest_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_nettmp_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_key_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); - if (rv != -1) - rv = create_dir(ctdl_run_dir , S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, UID, GID); + int rv = 0; + rv += create_dir(ctdl_message_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); + rv += create_dir(ctdl_file_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); + rv += create_dir(ctdl_spool_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); + rv += create_dir(ctdl_netdigest_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); + rv += create_dir(ctdl_nettmp_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); + rv += create_dir(ctdl_key_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1); + rv += create_dir(ctdl_run_dir , S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, UID, GID); return rv; }