aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2024-06-06 17:18:32 +0200
committerStefano Brivio <sbrivio@redhat.com>2024-06-21 15:32:15 +0200
commitb74801645c23bbb349df7522663f9ac253d6dc95 (patch)
treec081ae8ba46576d334236924f47310f5d075bca4
parent65923ba79877c412870c37f6d55d6bb6d1d941e8 (diff)
downloadpasst-b74801645c23bbb349df7522663f9ac253d6dc95.tar
passt-b74801645c23bbb349df7522663f9ac253d6dc95.tar.gz
passt-b74801645c23bbb349df7522663f9ac253d6dc95.tar.bz2
passt-b74801645c23bbb349df7522663f9ac253d6dc95.tar.lz
passt-b74801645c23bbb349df7522663f9ac253d6dc95.tar.xz
passt-b74801645c23bbb349df7522663f9ac253d6dc95.tar.zst
passt-b74801645c23bbb349df7522663f9ac253d6dc95.zip
conf, passt: Don't try to log to stderr after we close it
If we don't run in foreground, we close standard error as we daemonise, so it makes no sense to check if the controlling terminal is an interactive terminal or if --force-stderr was given, to decide if we want to log to standard error. Make --force-stderr depend on --foreground. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--conf.c3
-rw-r--r--passt.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/conf.c b/conf.c
index 4fff2b1..8687e43 100644
--- a/conf.c
+++ b/conf.c
@@ -1631,6 +1631,9 @@ void conf(struct ctx *c, int argc, char **argv)
conf_ugid(runas, &uid, &gid);
+ if (!c->foreground && c->force_stderr)
+ die("Can't log to standard error if not running in foreground");
+
if (logfile) {
logfile_init(c->mode == MODE_PASTA ? "pasta" : "passt",
logfile, logsize);
diff --git a/passt.c b/passt.c
index a5e2c5a..aa9648a 100644
--- a/passt.c
+++ b/passt.c
@@ -302,7 +302,7 @@ int main(int argc, char **argv)
if (isolate_prefork(&c))
die("Failed to sandbox process, exiting");
- if (!c.force_stderr && !isatty(fileno(stderr)))
+ if (!c.foreground || (!c.force_stderr && !isatty(fileno(stderr))))
__openlog(log_name, 0, LOG_DAEMON);
if (!c.foreground)