Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 337528 Details for
Bug 454914
sys-apps/openrc: Feature Request: Open logfile before chuid option
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Patch allowing opening of stdout/stderr files before chuid
file_454914.txt (text/plain), 4.20 KB, created by
Cameron Tacklind
on 2013-01-31 23:56:37 UTC
(
hide
)
Description:
Patch allowing opening of stdout/stderr files before chuid
Filename:
MIME Type:
Creator:
Cameron Tacklind
Created:
2013-01-31 23:56:37 UTC
Size:
4.20 KB
patch
obsolete
>diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c >index bfa8852..9e484d9 100644 >--- a/src/rc/start-stop-daemon.c >+++ b/src/rc/start-stop-daemon.c >@@ -596,7 +596,7 @@ expand_home(const char *home, const char *path) > } > > #include "_usage.h" >-#define getoptstring "I:KN:PR:Sa:bc:d:e:g:ik:mn:op:s:tu:r:w:x:1:2:" getoptstring_COMMON >+#define getoptstring "I:KN:PR:Sa:bc:d:e:g:ik:mn:op:s:tu:r:w:x:1:2:lL" getoptstring_COMMON > static const struct option longopts[] = { > { "ionice", 1, NULL, 'I'}, > { "stop", 0, NULL, 'K'}, >@@ -624,6 +624,8 @@ static const struct option longopts[] = { > { "stdout", 1, NULL, '1'}, > { "stderr", 1, NULL, '2'}, > { "progress", 0, NULL, 'P'}, >+ { "userlog", 0, NULL, 'l'}, >+ { "rootlog", 0, NULL, 'L'}, > longopts_COMMON > }; > static const char * const longopts_help[] = { >@@ -653,6 +655,8 @@ static const char * const longopts_help[] = { > "Redirect stdout to file", > "Redirect stderr to file", > "Print dots each second while waiting", >+ "Opens log redirect file after chuid (default)", >+ "Opens log redirect file before chuid (root owns log files)", > longopts_help_COMMON > }; > #include "_usage.c" >@@ -693,6 +697,7 @@ start_stop_daemon(int argc, char **argv) > gid_t gid = 0; > char *home = NULL; > int tid = 0; >+ bool user_log = true; > char *redirect_stderr = NULL; > char *redirect_stdout = NULL; > int stdout_fd; >@@ -900,6 +905,12 @@ start_stop_daemon(int argc, char **argv) > exec = optarg; > break; > >+ case 'l': >+ user_log = true; >+ break; >+ case 'L': >+ user_log = false; >+ break; > case '1': /* --stdout /path/to/stdout.lgfile */ > redirect_stdout = optarg; > break; >@@ -1168,6 +1179,26 @@ start_stop_daemon(int argc, char **argv) > fprintf(fp, "%d\n", mypid); > fclose(fp); > } >+ stdout_fd = devnull_fd; >+ stderr_fd = devnull_fd; >+ if (!user_log) { >+ if (redirect_stdout) { >+ if ((stdout_fd = open(redirect_stdout, >+ O_WRONLY | O_CREAT | O_APPEND, >+ S_IRUSR | S_IWUSR)) == -1) >+ eerrorx("%s: unable to open the logfile" >+ " for stdout `%s': %s", >+ applet, redirect_stdout, strerror(errno)); >+ } >+ if (redirect_stderr) { >+ if ((stderr_fd = open(redirect_stderr, >+ O_WRONLY | O_CREAT | O_APPEND, >+ S_IRUSR | S_IWUSR)) == -1) >+ eerrorx("%s: unable to open the logfile" >+ " for stderr `%s': %s", >+ applet, redirect_stderr, strerror(errno)); >+ } >+ } > > #ifdef HAVE_PAM > if (changeuser != NULL) { >@@ -1265,8 +1296,7 @@ start_stop_daemon(int argc, char **argv) > setenv("PATH", newpath, 1); > } > >- stdout_fd = devnull_fd; >- stderr_fd = devnull_fd; >+ if (user_log) { > if (redirect_stdout) { > if ((stdout_fd = open(redirect_stdout, > O_WRONLY | O_CREAT | O_APPEND, >@@ -1283,6 +1313,7 @@ start_stop_daemon(int argc, char **argv) > " for stderr `%s': %s", > applet, redirect_stderr, strerror(errno)); > } >+ } > > /* We don't redirect stdin as some daemons may need it */ > if (background || quiet || redirect_stdout)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 454914
: 337528