Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107195069
D18989.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D18989.diff
View Options
Index: head/lib/libcasper/services/cap_syslog/cap_syslog.c
===================================================================
--- head/lib/libcasper/services/cap_syslog/cap_syslog.c
+++ head/lib/libcasper/services/cap_syslog/cap_syslog.c
@@ -88,6 +88,9 @@
}
nvlist_add_number(nvl, "logopt", logopt);
nvlist_add_number(nvl, "facility", facility);
+ if (logopt & LOG_PERROR) {
+ nvlist_add_descriptor(nvl, "stderr", STDERR_FILENO);
+ }
nvl = cap_xfer_nvlist(chan, nvl);
if (nvl == NULL) {
return;
@@ -131,6 +134,7 @@
*/
static char *LogTag;
+static int prev_stderr = -1;
static void
slog_vsyslog(const nvlist_t *limits __unused, const nvlist_t *nvlin,
@@ -146,6 +150,8 @@
nvlist_t *nvlout __unused)
{
const char *ident;
+ uint64_t logopt;
+ int stderr_fd;
ident = dnvlist_get_string(nvlin, "ident", NULL);
if (ident != NULL) {
@@ -153,8 +159,19 @@
LogTag = strdup(ident);
}
- openlog(LogTag, nvlist_get_number(nvlin, "logopt"),
- nvlist_get_number(nvlin, "facility"));
+ logopt = nvlist_get_number(nvlin, "logopt");
+ if (logopt & LOG_PERROR) {
+ stderr_fd = dnvlist_get_descriptor(nvlin, "stderr", -1);
+ if (prev_stderr == -1)
+ prev_stderr = dup(STDERR_FILENO);
+ if (prev_stderr != -1)
+ (void)dup2(stderr_fd, STDERR_FILENO);
+ } else if (prev_stderr != -1) {
+ (void)dup2(prev_stderr, STDERR_FILENO);
+ close(prev_stderr);
+ prev_stderr = -1;
+ }
+ openlog(LogTag, logopt, nvlist_get_number(nvlin, "facility"));
}
static void
@@ -166,6 +183,12 @@
free(LogTag);
LogTag = NULL;
+
+ if (prev_stderr != -1) {
+ (void)dup2(prev_stderr, STDERR_FILENO);
+ close(prev_stderr);
+ prev_stderr = -1;
+ }
}
static void
@@ -198,4 +221,4 @@
return (0);
}
-CREATE_SERVICE("system.syslog", NULL, syslog_command, CASPER_SERVICE_STDIO);
+CREATE_SERVICE("system.syslog", NULL, syslog_command, 0);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 12, 12:01 PM (21 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15769172
Default Alt Text
D18989.diff (1 KB)
Attached To
Mode
D18989: Allow stdio access to be revoked from casper services
Attached
Detach File
Event Timeline
Log In to Comment