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 EFA845A004E for ; Thu, 20 Jun 2024 02:49:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1718844566; bh=YED+4/iV2mdnDO7aoF4eveutQHwKq+cBOXB56vKRaJA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WF4il6tDqoe3Q8uRy8G5X0j7nXrI1Fe/Zwmy2qLQhgpjA5/aHZic+seCW+a59QDnc p9n+TWmL59rdPyiewBQcvvySRj/PLw3VCGVwfaV/Z7hPrBSv9gIPjecPQosjIV650W 0m1mtttQLwM84N7Kd1tZjsWKLMFCkWVJXDuCXSunSzszoYOYiyrSHPaK9p56qd+ARb Zync2VGSOv8HnVE/OSDPdJCbnpG0T0wluhH82veHUU2/NqbdW9WPHa0y0PB+QQ3pBV kfzNkDUUsK1JiclHd35kcq8xgk7YHs3IvEu0kSuFKDwa4nJ0sy8OFYrYeeoLPYcwjX tyQRMkgZPjn9w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4W4MMB4d7Wz4wqK; Thu, 20 Jun 2024 10:49:26 +1000 (AEST) Date: Thu, 20 Jun 2024 10:27:53 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v3 1/8] conf, passt: Don't try to log to stderr after we close it Message-ID: References: <20240619194028.2913930-1-sbrivio@redhat.com> <20240619194028.2913930-2-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="iu1RKkIDpONwPr8U" Content-Disposition: inline In-Reply-To: <20240619194028.2913930-2-sbrivio@redhat.com> Message-ID-Hash: FADEU6WQAWKZE5UHHHDTVDKAQNEHH4AO X-Message-ID-Hash: FADEU6WQAWKZE5UHHHDTVDKAQNEHH4AO 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: --iu1RKkIDpONwPr8U Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 19, 2024 at 09:40:21PM +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)))) > __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 --iu1RKkIDpONwPr8U Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmZzd4gACgkQzQJF27ox 2Ge+JA//UwHJ5noWEYzpF1tzfTGQR/1CNMS6vPfUegQ3Mx6Vi6V1e+ect/VOLTHQ 8XNqMV/Ckju2i0m9Z17h6W31TSiTFt1JWEpCzBVxaPXh3kZDaYXvxj4LhRkFhdHM P7USkuZlxKhMCMuxHej3GhXpmgnMV5d/xPpNTb+fuZvZoHmrQ127VAJQT5XnGTSC N4PoBd4k8GwRWS+E40TU0whNFWFivt1Valz3ayiyuEnjhL/xA10oD+Jea1RVn8S2 dl/vJoa6S6degUa3f6WlSr+neFkX84LqPvLv5hK6cXeJPh6qInJJmkd2KfhC+SLy 0JYu+AST64hgONiARuYrhut6UDBdyBkAt+aAyfkiMkHByZplSjlxO2ASLoV1OfNp PVhuj156+8XkZS9Eaa+mn99u6urdRY6czF5QXe3wjrOOOWpD7NpSJQCVRrx2kDoA pL8kmgAM4rTmoovloj+9zUVC1ZhvyKVDajKqsTCc0v1d7EUmHmU9Ceyrar5LGO66 208TPeNLPpxkoKWUGM5k03b4j6ducll9FFjX7ld7t4OCYaCPtllIjG+k9ijq8M9V nWxjlxb/cqu/hBdApkLmULTbiuwO3cPc6ckb7qJKfGpfHD8pBJgB7gBshwy9KLu5 wk4YZAFkrDRKHrkDB9DeUFUpoRPc2eCJiRp94mLadfMnes/EYj4= =sHTf -----END PGP SIGNATURE----- --iu1RKkIDpONwPr8U--