From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 2C1405A0050 for ; Wed, 19 Jun 2024 04:34:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1718764462; bh=odokOqhVdHRPAAoDhF/7E3Lg/7M53BcDJN410StePE0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZxfhdSWtg1x1fMIQh4cJL1Jv4H2LsSoEub+Fb4rzKJjyArWDM2TlY8xOXeuRMso2M KCTwI9/5RXuVO+9OSPDYBz6NU2hgAN6CJIAzzOsut8EoYEiQ2bioCmKOzbbOuGUsbF 3Lha/nIYvmv59jehgaMBe0omqHERybmh6qB9JCmw+BmzqwxOYtS3tMDQxOvq0iNnjq YI0sAFsg8MmuKOU+bfzxLrktk+XERyoJNW678mqc9Kp0zHaCoAJWcMscEqsKt9hrYj sAXdfYUXYIqcWst3ULlHZN656tjQ6gRdazQoHNOipJbspDLNHlCs5GgMFZ0CZw4R0d NTWP/cjf5crrQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4W3nkk3gDTz4wcp; Wed, 19 Jun 2024 12:34:22 +1000 (AEST) Date: Wed, 19 Jun 2024 12:14:53 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 1/6] conf, passt: Don't try to log to stderr after we close it Message-ID: References: <20240618071427.1544869-1-sbrivio@redhat.com> <20240618071427.1544869-2-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3Jz02phe29LgAE6u" Content-Disposition: inline In-Reply-To: <20240618071427.1544869-2-sbrivio@redhat.com> Message-ID-Hash: ID3FNIGYUS2Y6OS72YE4GUI72BFNQU6H X-Message-ID-Hash: ID3FNIGYUS2Y6OS72YE4GUI72BFNQU6H X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Yalan Zhang X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --3Jz02phe29LgAE6u Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 18, 2024 at 09:14:22AM +0200, Stefano Brivio wrote: > 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. >=20 > Make --force-stderr depend on --foreground. >=20 > Signed-off-by: Stefano Brivio > --- > conf.c | 3 +++ > passt.c | 2 +- > 2 files changed, 4 insertions(+), 1 deletion(-) >=20 > diff --git a/conf.c b/conf.c > index 94b3ed6..dbdbb62 100644 > --- a/conf.c > +++ b/conf.c > @@ -1693,6 +1693,9 @@ void conf(struct ctx *c, int argc, char **argv) > =20 > conf_ugid(runas, &uid, &gid); > =20 > + if (!c->foreground && c->force_stderr) > + die("Can't log to standard error if not running in foreground"); > + > if (logfile) { > logfile_init(c->mode =3D=3D 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"); > =20 > - if (!c.force_stderr && !isatty(fileno(stderr))) > + if (!c.foreground || (!c.force_stderr && !isatty(fileno(stderr)))) > __openlog(log_name, 0, LOG_DAEMON); Hm.. kind of preexisting, but shouldn't we still skip the __openlog() if we have a logfile? Or make __openlog() open either the syslog or the logfile as appropriate (but in that case we should rename it not to look like openlog(3)). > if (!c.foreground) --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --3Jz02phe29LgAE6u Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmZyPxwACgkQzQJF27ox 2GcCAg//WXbhT8+oMk0a/eGz9Cp6PH0l7QExAfKC/oyZNIgKEN7RMvLTwFFg685f T1F0vIeAs7ZQip8B5DwgumO4fOz/mDHIOemJffvPzpaB8zOtBQhHwautTAcMUDsd OI5wWWCNIDFslG3lO8ozcebxPaNps6s8G3gOIsLE2k0xdeSNZ794L6Hr0+WCKQLT 3N0DirJgnSv3xPsdYUdknxmGcsfTqbWoByaSUdi3yJEyniSmZwhMO1pj70jD/pQZ tmem9bJSjx+pJmTY6ZWfEOXrAukRhqPpug3wIIF/EpA6T6eNhhIytqC6u3BvdFYV f7LsoLGkC+xKLmWdogp6n5xHfPQbZsd6I3pOYAo4cyxMEZhLAEx8V0hqHVAF8ak9 sZFP2HixYjTAjN6uNCUrVEX9EQO1+OOUX0uFK0Fn1eckr1kOXKVGjWLnM7B+ff22 it7N7CtKBY4C/mzx7b4Mr42K+rxf60T3ltQG4dosmxn2i/HgDVDm2S8B848di6KH uI/IpSLonKDu8FT0gWG802W2eWTQbIvUsimvVoedYL+yV6KG6u0phdMI6aByMeSG rdY4p4ww6DB877WooyUlYY7A3opAP45040G31yv0BIY+nzjBN5rNbhGakUfLTuHb Q0v9YqGS3xmA2ZPfSNGvRqokg0srn0vEOIuaMME0XZIdjvLZhH0= =kVxN -----END PGP SIGNATURE----- --3Jz02phe29LgAE6u--