From f9cc6fb48b7c0ed068499047bb73519dc317ae8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Thu, 29 Jul 2010 17:52:52 +0000 Subject: [PATCH] * add function to create the directory tree citadel needs to run (moved from setup.c) --- citadel/include/citadel_dirs.h | 8 ++++++-- citadel/utillib/citadel_dirs.c | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/citadel/include/citadel_dirs.h b/citadel/include/citadel_dirs.h index 19856270a..05ce0fc37 100644 --- a/citadel/include/citadel_dirs.h +++ b/citadel/include/citadel_dirs.h @@ -60,7 +60,11 @@ extern char file_funambol_msg[PATH_MAX]; extern void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, int dbg); -void assoc_file_name(char *buf, size_t n, - struct ctdlroom *qrbuf, const char *prefix); +extern void create_run_directories(long UID, long GUID); + +extern void assoc_file_name(char *buf, + size_t n, + struct ctdlroom *qrbuf, + const char *prefix); #endif /* __CITADEL_DIRS_H */ diff --git a/citadel/utillib/citadel_dirs.c b/citadel/utillib/citadel_dirs.c index 1aecdcded..a888cf234 100644 --- a/citadel/utillib/citadel_dirs.c +++ b/citadel/utillib/citadel_dirs.c @@ -379,3 +379,30 @@ void assoc_file_name(char *buf, size_t n, snprintf(buf, n, "%s%ld", prefix, qrbuf->QRnumber); } + +int create_dir(char *which, long ACCESS, long UID, long GID) +{ + int rv; + rv = mkdir(which, ACCESS); + rv = chmod(which, ACCESS); + rv = chown(which, UID, GID); + return rv; +} + +void create_run_directories(long UID, long GID) +{ + int rv; + + rv = create_dir(ctdl_info_dir , 0700, UID, -1); + rv = create_dir(ctdl_bio_dir , 0700, UID, -1); + rv = create_dir(ctdl_usrpic_dir , 0700, UID, -1); + rv = create_dir(ctdl_message_dir , 0700, UID, -1); + rv = create_dir(ctdl_hlp_dir , 0700, UID, -1); + rv = create_dir(ctdl_image_dir , 0700, UID, -1); + rv = create_dir(ctdl_bb_dir , 0700, UID, -1); + rv = create_dir(ctdl_file_dir , 0700, UID, -1); + rv = create_dir(ctdl_netcfg_dir , 0700, UID, -1); + rv = create_dir(ctdl_key_dir , 0700, UID, -1); + rv = create_dir(ctdl_run_dir , 0700, UID, GID); + +} -- 2.30.2