X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=1c2b95d3e7d5d3e427bc4c20f59ba4483062dea9;hp=9f3a8f942b1176867fc7e0d55253cbae321f6130;hb=9a3633697faff9b12a64b6d727444eb370fd2340;hpb=fe4477ee14abb348ce9e167f8b4c09312d67de36 diff --git a/src/common/utils.c b/src/common/utils.c index 9f3a8f942..1c2b95d3e 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -309,10 +309,11 @@ error: * * Return 0 on success or else a negative value. */ +LTTNG_HIDDEN int utils_create_stream_file(char *path_name, char *file_name, uint64_t size, uint64_t count, int uid, int gid) { - int ret, out_fd; + int ret, out_fd, flags, mode; char full_path[PATH_MAX], *path_name_id = NULL, *path; assert(path_name); @@ -340,8 +341,15 @@ int utils_create_stream_file(char *path_name, char *file_name, uint64_t size, path = full_path; } - out_fd = run_as_open(path, O_WRONLY | O_CREAT | O_TRUNC, - S_IRWXU | S_IRWXG | S_IRWXO, uid, gid); + flags = O_WRONLY | O_CREAT | O_TRUNC; + /* Open with 660 mode */ + mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; + + if (uid < 0 || gid < 0) { + out_fd = open(path, flags, mode); + } else { + out_fd = run_as_open(path, flags, mode, uid, gid); + } if (out_fd < 0) { PERROR("open stream path %s", path); goto error_open; @@ -363,6 +371,7 @@ error: * * Return 0 on success or else a negative value. */ +LTTNG_HIDDEN int utils_rotate_stream_file(char *path_name, char *file_name, uint64_t size, uint64_t count, int uid, int gid, int out_fd, uint64_t *new_count) {