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 77FDA5A004E for ; Thu, 20 Jun 2024 02:16:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1718842593; bh=cGYPL9q81Zi2VJUs5oOhN0iq3rwUTD1Ole44goaEXUw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jx4zFZLmfOial0kbgktVo9NfvMrr2hP+cFvllCwLjZUesEjNGDqacFOAudvTf/3Mr Ku7TH+Em5u0dfv4KiQms1cUbAdHFt84f/dgzSRk5AGcpDrCwajpLJWHC3xINA0ii3t 65ZHWU+UIVabYSGzqhNTJ9RG0DnNH65aLK2xLTMRzvQ/syyoEtuUwhIwrtyrIOYg2E TYQsjsLu85oTRuAbX6kpw0E3MKFzzQzDJLufFIdQUX3E3aUHWB5bOT9CmGQ/Aq6RiV rIkk7GP8X4zNzIVpFr8Pp765YSGGhNarohayyldCTQ2b8o2A/ewP/BIjFerX3sywDH VkHMnegLnMXuQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4W4LdF0pcxz4wqK; Thu, 20 Jun 2024 10:16:33 +1000 (AEST) Date: Thu, 20 Jun 2024 10:16:02 +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> <20240619103433.57405b48@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="v+dKnuzb0wqOo6Yi" Content-Disposition: inline In-Reply-To: <20240619103433.57405b48@elisabeth> Message-ID-Hash: 5AQR7662T6FHIMW4PJT4W6NF6ZUZFBZX X-Message-ID-Hash: 5AQR7662T6FHIMW4PJT4W6NF6ZUZFBZX 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: --v+dKnuzb0wqOo6Yi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 19, 2024 at 10:34:48AM +0200, Stefano Brivio wrote: > On Wed, 19 Jun 2024 12:14:53 +1000 > David Gibson wrote: >=20 > > 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); =20 > >=20 > > Hm.. kind of preexisting, but shouldn't we still skip the __openlog() > > if we have a logfile? >=20 > Ah, true. I would add this as a separate patch. >=20 > > 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)). >=20 > I would rather keep __openlog() as openlog() implementation, because > the semantics are well specified like this. I concur. > We just need another function, or even a direct setting, for LOG_PERROR > (or get rid of that flag, internally?). I feel like our needs for when we log to stderr are specific enough that it's simpler to just not use LOG_PERROR at all, and handle the printing to stderr ourselves. --=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 --v+dKnuzb0wqOo6Yi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmZzdMEACgkQzQJF27ox 2GdO+Q/+I2X1jjSKM7jMpGWEQB77tCfMMF3QltxG8vgt6k6H2v41pkX5kyVD6GMz 92YgWmWxJ25ZGPHKF9I9IMn98sHaSRGTds0QuNy+/++9py822WCLEmGD4E4HsHRM d3aY/0z7ZDS/N3T81w2eubfZCBx6wUe/h09VQD2FzWGFiet5vPjcQFmsXuUmxUyd OmMpozLVbzBKKzAb7fSQibDQWOL/jeZUAJHiNiud4JXUcT7gprU/kRQw+0OGzfxK NLU5GNnEHb/xkaehFPvnqydd//xyWo/BIaR5ea+vPqceOwjqbTmUuVkBMtai20hG wqw6rZnhrYIHO5SDfABtZtbEsEdJ9712ZnA2h6XduDam+4WwZyNzZ54yDtypuYYk VSZJNE8fQh+Q4KAhCIibxLi5+S3jhWMWmiZCW8MLrvQOHGb1UizQG8Zg/aig9Ypb ab7UatGtYLR3yVEoycfV3lQHCCkhXiUbU6Dy/AAnoYJ5PDJXn27FuKX23uqiV3BW ZV+IrBYpXfJ2QksEyEwpOiaaRNr8BAqk6d2NYZAx3QgPWRMc+91FOvWfOlo21DDW lD+7ozfRZiNqZIRI6xMulZY9TH7LKesgHxtDPk8dcFx8fewXXpRVldw7UfPFyMlK ZvlrJ9//gRAYq3yLbJ+5XnxWfYn+DbeldpolX1jhGvuZlpmAZxU= =Pr93 -----END PGP SIGNATURE----- --v+dKnuzb0wqOo6Yi--