Skip to content

Commit ab2dd7d

Browse files
authored
Ensure the permissions of the log file are actually really 0666 (#2528)
Signed-off-by: Bob Weinand <[email protected]>
1 parent 18f237a commit ab2dd7d

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

ext/logging.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ void ddtrace_log_minit(void) {
3939
if (ZSTR_LEN(get_global_DD_TRACE_LOG_FILE())) {
4040
int fd = VCWD_OPEN_MODE(ZSTR_VAL(get_global_DD_TRACE_LOG_FILE()), O_CREAT | O_RDWR | O_APPEND, 0666);
4141
if (fd >= 0) {
42+
#ifndef _WIN32
43+
fchmod(fd, 0666); // ignore umask
44+
#endif
4245
atomic_store(&ddtrace_error_log_fd, fd);
4346

4447
time_t now;
@@ -60,6 +63,10 @@ void ddtrace_log_rinit(char *error_log) {
6063
}
6164

6265
int desired = VCWD_OPEN_MODE(error_log, O_CREAT | O_RDWR | O_APPEND, 0666);
66+
#ifndef _WIN32
67+
fchmod(desired, 0666); // ignore umask
68+
#endif
69+
6370
time_t now;
6471
time(&now);
6572
atomic_store(&dd_error_log_fd_rotated, (uintmax_t) now);
@@ -123,6 +130,9 @@ int ddtrace_log_with_time(int fd, const char *msg, int msg_len) {
123130
char pathbuf[MAXPATHLEN];
124131
if (ddtrace_get_fd_path(fd, pathbuf) >= 0) {
125132
int new_fd = VCWD_OPEN_MODE(pathbuf, O_CREAT | O_RDWR | O_APPEND, 0666);
133+
#ifndef _WIN32
134+
fchmod(new_fd, 0666); // ignore umask
135+
#endif
126136
dup2(new_fd, fd); // atomic replace
127137
close(new_fd);
128138
}

0 commit comments

Comments
 (0)