diff --git a/recording-daemon/main.c b/recording-daemon/main.c index d477bb50e..9882e03a9 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -40,6 +40,7 @@ int output_mixed; int output_single; int output_enabled = 1; mode_t output_chmod; +mode_t output_chmod_dir = 0700; uid_t output_chown = -1; gid_t output_chgrp = -1; char *output_pattern = NULL; @@ -157,9 +158,21 @@ static void cleanup(void) { } +static mode_t chmod_parse(const char *s) { + if (!s || !*s) + return 0; + char *errp; + unsigned long m = strtoul(s, &errp, 8); + if (*errp || m > 077777) + die("Invalid mode value '%s'", s); + return m; +} + + static void options(int *argc, char ***argv) { AUTO_CLEANUP_GBUF(os_str); AUTO_CLEANUP_GBUF(chmod_mode); + AUTO_CLEANUP_GBUF(chmod_dir_mode); AUTO_CLEANUP_GBUF(user_uid); AUTO_CLEANUP_GBUF(group_gid); @@ -176,6 +189,7 @@ static void options(int *argc, char ***argv) { { "output-mixed", 0, 0, G_OPTION_ARG_NONE, &output_mixed, "Mix participating sources into a single output",NULL }, { "output-single", 0, 0, G_OPTION_ARG_NONE, &output_single, "Create one output file for each source",NULL }, { "output-chmod", 0, 0, G_OPTION_ARG_STRING, &chmod_mode, "File mode for recordings", "OCTAL" }, + { "output-chmod-dir", 0, 0, G_OPTION_ARG_STRING, &chmod_dir_mode,"Directory mode for recordings", "OCTAL" }, { "output-chown", 0, 0, G_OPTION_ARG_STRING, &user_uid, "File owner for recordings", "USER|UID" }, { "output-chgrp", 0, 0, G_OPTION_ARG_STRING, &group_gid, "File group for recordings", "GROUP|GID" }, { "mysql-host", 0, 0, G_OPTION_ARG_STRING, &c_mysql_host, "MySQL host for storage of call metadata","HOST|IP" }, @@ -261,13 +275,8 @@ static void options(int *argc, char ***argv) { } } - if (chmod_mode && *chmod_mode) { - char *errp; - unsigned long m = strtoul(chmod_mode, &errp, 8); - if (*errp || m > 077777) - die("Invalid mode value '%s'", chmod_mode); - output_chmod = m; - } + output_chmod = chmod_parse(chmod_mode); + output_chmod_dir = chmod_parse(chmod_dir_mode); if (num_threads <= 0) num_threads = num_cpu_cores(8); diff --git a/recording-daemon/main.h b/recording-daemon/main.h index 35c46ac51..ca177cd95 100644 --- a/recording-daemon/main.h +++ b/recording-daemon/main.h @@ -22,6 +22,7 @@ extern int output_mixed; extern int output_single; extern int output_enabled; extern mode_t output_chmod; +extern mode_t output_chmod_dir; extern uid_t output_chown; extern gid_t output_chgrp; extern char *output_pattern; diff --git a/recording-daemon/output.c b/recording-daemon/output.c index e59751ab9..9e56ea897 100644 --- a/recording-daemon/output.c +++ b/recording-daemon/output.c @@ -130,7 +130,7 @@ done:; char *last_sep = strrchr(ret->full_filename, G_DIR_SEPARATOR); if (last_sep) { *last_sep = '\0'; - if (g_mkdir_with_parents(ret->full_filename, 0700)) + if (g_mkdir_with_parents(ret->full_filename, output_chmod_dir)) ilog(LOG_WARN, "Failed to create (parent) directory for '%s': %s", ret->full_filename, strerror(errno)); *last_sep = G_DIR_SEPARATOR; diff --git a/recording-daemon/rtpengine-recording.pod b/recording-daemon/rtpengine-recording.pod index d6180a50a..56d99e6bb 100644 --- a/recording-daemon/rtpengine-recording.pod +++ b/recording-daemon/rtpengine-recording.pod @@ -236,6 +236,11 @@ multiple audio sources in sync. Change the file permissions of recording files to the given mode. Must be given as an octal integer, for example B<0660>. +=item B<--output-chmod-dir=>I + +Change the file permissions of recording files to the given mode. Must be given +as an octal integer, for example B<0700> (which is also the default value). + =item B<--output-chown=>I|I =item B<--output-chgrp=>I|I