Browse Source

TT#111357 add chmod setting for created output dirs

Change-Id: I233b83febd087f202e047194ad3ad97c6651ea3b
pull/1218/head
Richard Fuchs 5 years ago
parent
commit
b8b395e21f
4 changed files with 23 additions and 8 deletions
  1. +16
    -7
      recording-daemon/main.c
  2. +1
    -0
      recording-daemon/main.h
  3. +1
    -1
      recording-daemon/output.c
  4. +5
    -0
      recording-daemon/rtpengine-recording.pod

+ 16
- 7
recording-daemon/main.c View File

@ -40,6 +40,7 @@ int output_mixed;
int output_single; int output_single;
int output_enabled = 1; int output_enabled = 1;
mode_t output_chmod; mode_t output_chmod;
mode_t output_chmod_dir = 0700;
uid_t output_chown = -1; uid_t output_chown = -1;
gid_t output_chgrp = -1; gid_t output_chgrp = -1;
char *output_pattern = NULL; 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) { static void options(int *argc, char ***argv) {
AUTO_CLEANUP_GBUF(os_str); AUTO_CLEANUP_GBUF(os_str);
AUTO_CLEANUP_GBUF(chmod_mode); AUTO_CLEANUP_GBUF(chmod_mode);
AUTO_CLEANUP_GBUF(chmod_dir_mode);
AUTO_CLEANUP_GBUF(user_uid); AUTO_CLEANUP_GBUF(user_uid);
AUTO_CLEANUP_GBUF(group_gid); 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-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-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", 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-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" }, { "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" }, { "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) if (num_threads <= 0)
num_threads = num_cpu_cores(8); num_threads = num_cpu_cores(8);


+ 1
- 0
recording-daemon/main.h View File

@ -22,6 +22,7 @@ extern int output_mixed;
extern int output_single; extern int output_single;
extern int output_enabled; extern int output_enabled;
extern mode_t output_chmod; extern mode_t output_chmod;
extern mode_t output_chmod_dir;
extern uid_t output_chown; extern uid_t output_chown;
extern gid_t output_chgrp; extern gid_t output_chgrp;
extern char *output_pattern; extern char *output_pattern;


+ 1
- 1
recording-daemon/output.c View File

@ -130,7 +130,7 @@ done:;
char *last_sep = strrchr(ret->full_filename, G_DIR_SEPARATOR); char *last_sep = strrchr(ret->full_filename, G_DIR_SEPARATOR);
if (last_sep) { if (last_sep) {
*last_sep = '\0'; *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", ilog(LOG_WARN, "Failed to create (parent) directory for '%s': %s",
ret->full_filename, strerror(errno)); ret->full_filename, strerror(errno));
*last_sep = G_DIR_SEPARATOR; *last_sep = G_DIR_SEPARATOR;


+ 5
- 0
recording-daemon/rtpengine-recording.pod View File

@ -236,6 +236,11 @@ multiple audio sources in sync.
Change the file permissions of recording files to the given mode. Must be given Change the file permissions of recording files to the given mode. Must be given
as an octal integer, for example B<0660>. as an octal integer, for example B<0660>.
=item B<--output-chmod-dir=>I<INT>
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<USER>|I<UID> =item B<--output-chown=>I<USER>|I<UID>
=item B<--output-chgrp=>I<GROUP>|I<GID> =item B<--output-chgrp=>I<GROUP>|I<GID>


Loading…
Cancel
Save