From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id CE7675A0052 for ; Tue, 18 Jun 2024 02:52:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1718671915; bh=8BEZqpeJIgVTWr6QDU0UrReK+gg0ElXA2Q4N95KEv1o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lS7Ry7b5MYUXy52jJvYrHEk4bxmtIyNevAxGWAJZ7cF4oJYU7jWShtzewMTFAZJ9i OW1X9YbwvGambF8oZCWXX2XrGtFVJchoVtAopRCWo4YnKbFBiJylK84FzWOwPEl4FV xR4FX7ytLeju5CuMgBiE+JdHYZZmrc8ul0cQBPNw3932MxftANepNJE/M29LnTKz+O oFZcEeeUojW5Z7EMVld/2H9zzcXWiuy1WuWv6RkhJ0dNWGzjf7uExfn1io+60kDG7c doZz+ZumF9jDczM+tm/THj8EMnu/B6Fru/W5jaLf08NltYJbqM7d9CcuLfo9CkWJ/7 YoU6s9AGt091w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4W37Vz1jRPz4wcK; Tue, 18 Jun 2024 10:51:55 +1000 (AEST) Date: Tue, 18 Jun 2024 10:36:28 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 1/6] conf, passt: Don't try to log to stderr after we close it Message-ID: References: <20240617120319.1206857-1-sbrivio@redhat.com> <20240617120319.1206857-2-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FF9At/SH9FND/tTR" Content-Disposition: inline In-Reply-To: <20240617120319.1206857-2-sbrivio@redhat.com> Message-ID-Hash: T4HPNA2LPQAORIR4STGTKCR4WJFEFGS2 X-Message-ID-Hash: T4HPNA2LPQAORIR4STGTKCR4WJFEFGS2 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: --FF9At/SH9FND/tTR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 17, 2024 at 02:03:14PM +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 Reviewed-by: David Gibson > --- > 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)))) What's the rationale for the isatty() check in any case? > __openlog(log_name, 0, LOG_DAEMON); > =20 > 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 --FF9At/SH9FND/tTR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmZw1ocACgkQzQJF27ox 2Gc16g/8DHl9tbinyp/CXfp8wTP3NLu0JweiL7AuEveAtJHHQ43IyFTsQ9Q2W0mh p6BWh37N1m2efzOFFjpU4qY6p11SbhepDG411u2kpaXtFXQFVm0GWTTSijfx/WA0 QuRmsAihGPZJcycVXsprFJZJX9FhQi/s5OXfxj8unSus1sdJqqS9tFFDm+LdXb9H NBPGlJ+J7YzdYooQ8Pz1SOti6ByNW7fesF3EZIlMkGPq9qn6C55zKrFNJVy0re6T xYcuDi4PXuEy47WRwDlJ0myzRxnlUa0QsDDIbUrowk1jj2EQy/33jrO5BopZVH2y GpW/dW0aJ7fDaxkDPZy+tT8ZFPvBLp5JJp0o4e5IvnRf6seVU5kWDUC88InGwvuV zO4/mRY2ZWxaeloqiOStHKQv7hZlSSMDQxZ8uB0C3y72XjRy6EvMk7UfLirSmY/N SLXWJftgK0YyJAgzSCEX36KXOGjhNTQj7Ht9JzWhMvRpg//5aNx8cTROwxOUxsJ5 PY2CXrnGQfa7tFm/XOsd3u0lb6Z6vmfFtmduuyeHE2fBzpW+4e7PqkETeho8peKJ 2G/sjwcksGK0/2998RXnM6iGySDkhZhLy49DGm+hSWRAyfCpfe+rTHnpzIZE5AS8 jp9KWsSVY/FvJ5x+RRCsSg2UKMZqpRECvIppPTzMQ97fM3enUSU= =e3N/ -----END PGP SIGNATURE----- --FF9At/SH9FND/tTR--