log: add option to set file permissions

This commit is contained in:
Nick Peng
2022-12-21 21:30:08 +08:00
parent 945653667f
commit f7f1f37faa
10 changed files with 62 additions and 0 deletions

View File

@@ -90,6 +90,7 @@ struct tlog_log {
time_t last_waitpid;
mode_t file_perm;
mode_t archive_perm;
int mode_changed;
int waiters;
int is_exit;
@@ -332,6 +333,7 @@ void tlog_set_permission(struct tlog_log *log, unsigned int file, unsigned int a
{
log->file_perm = file;
log->archive_perm = archive;
log->mode_changed = 1;
}
int tlog_localtime(struct tlog_time *tm)
@@ -1205,6 +1207,10 @@ static int _tlog_write(struct tlog_log *log, const char *buff, int bufflen)
return -1;
}
if (log->mode_changed != 0) {
fchmod(log->fd, log->file_perm);
}
log->last_try = 0;
log->print_errmsg = 1;
/* get log file size */