Apply logfile-chown and logfile-chmod options when logfile is rotated.

PR:		250900
This commit is contained in:
Max Khon 2020-11-20 07:58:19 +00:00
parent 590c70d6c3
commit 7eb5fadacf
2 changed files with 33 additions and 0 deletions

View file

@ -3,6 +3,7 @@
PORTNAME= uwsgi
PORTVERSION= 2.0.19.1
PORTREVISION= 1
CATEGORIES= www python
MASTER_SITES= http://projects.unbit.it/downloads/

View file

@ -0,0 +1,32 @@
--- core/logging.c.orig 2020-11-06 10:12:49.865752000 +0100
+++ core/logging.c 2020-11-06 10:17:57.825745000 +0100
@@ -536,13 +536,23 @@
uwsgi_error_open(logfile);
exit(1);
}
- else {
- if (dup2(fd, log_fd) < 0) {
- // this could be lost :(
- uwsgi_error("uwsgi_log_do_rotate()/dup2()");
- exit(1);
- }
+ if (dup2(fd, log_fd) < 0) {
+ // this could be lost :(
+ uwsgi_error("uwsgi_log_do_rotate()/dup2()");
close(fd);
+ exit(1);
+ }
+ close(fd);
+
+ if (uwsgi.chmod_logfile_value) {
+ if (fchmod(log_fd, uwsgi.chmod_logfile_value)) {
+ uwsgi_error("fchmod()");
+ }
+ }
+ if (uwsgi.logfile_chown) {
+ if (fchown(log_fd, uwsgi.uid, uwsgi.gid)) {
+ uwsgi_error("fchown()");
+ }
}
}
else {