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 44C6C5A005A for ; Thu, 20 Jun 2024 02:49:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1718844566; bh=bw7dqC9CS1bxpl62VMmOACG6KHob1cH3m195Vrudc3Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LwIG/gKt6iXNf4oesnTg9vuteVFggGPioDkLVFA8u5OssBQ9m3f1ZcZFoG7fg4Xwn 2u6dGQASssYqp/xHrzF1oVXpswG2rOoKL0JFv6pr4Bk2aTo+qWmr9atOl2De8PUjbe 76TvDUVz4gnMltmAGonIJKoFMz0sSn0p6IJpzuUwahseDwfYJHek7egGA14VdUmU7T UcMhGLKBX9sSANmC0jIkJ1xIqz9nkbotGN+dA6HkJ/DD+H+DpgTBZqG70ZKCJQqILh DXBrbIMJWbWFvsQmOQVwnClTTx+t9eKQrIyOG4ghycSAFmKXCsdU/HYOEStzvU5VL7 I32vVagODxSEA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4W4MMB5R41z4x0H; Thu, 20 Jun 2024 10:49:26 +1000 (AEST) Date: Thu, 20 Jun 2024 10:49:21 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v3 8/8] conf, passt: Don't call __openlog() if a log file is used Message-ID: References: <20240619194028.2913930-1-sbrivio@redhat.com> <20240619194028.2913930-9-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="meZaQugRErn0Ir2Q" Content-Disposition: inline In-Reply-To: <20240619194028.2913930-9-sbrivio@redhat.com> Message-ID-Hash: 2B3BA5KJQFSMAPGDYOASPOBCNNYTFCWL X-Message-ID-Hash: 2B3BA5KJQFSMAPGDYOASPOBCNNYTFCWL 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: --meZaQugRErn0Ir2Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 19, 2024 at 09:40:28PM +0200, Stefano Brivio wrote: > If a log file is configured, we would otherwise open a connection to > the system logger (if any), print any message that we might have > before we initialise the log file, and then keep that connection > around for no particular reason. >=20 > Call __openlog() as an alternative to the log file setup, instead. >=20 > This way, we might skip printing some messages during the > initialisation phase, but they're probably not really valuable to > have in a system log, and we're going to print them to standard > error anyway. >=20 > Suggested-by: David Gibson > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > conf.c | 9 +++++---- > passt.c | 4 ---- > 2 files changed, 5 insertions(+), 8 deletions(-) >=20 > diff --git a/conf.c b/conf.c > index 09bf6dd..5a4f559 100644 > --- a/conf.c > +++ b/conf.c > @@ -1220,6 +1220,7 @@ void conf(struct ctx *c, int argc, char **argv) > {"no-copy-addrs", no_argument, NULL, 19 }, > { 0 }, > }; > + const char *logname =3D (c->mode =3D=3D MODE_PASTA) ? "pasta" : "passt"; > char userns[PATH_MAX] =3D { 0 }, netns[PATH_MAX] =3D { 0 }; > bool copy_addrs_opt =3D false, copy_routes_opt =3D false; > struct in6_addr *dns6 =3D c->ip6.dns, dns6_tmp; > @@ -1680,10 +1681,10 @@ void conf(struct ctx *c, int argc, char **argv) > =20 > conf_ugid(runas, &uid, &gid); > =20 > - if (logfile) { > - logfile_init(c->mode =3D=3D MODE_PASTA ? "pasta" : "passt", > - logfile, logsize); > - } > + if (logfile) > + logfile_init(logname, logfile, logsize); > + else > + __openlog(logname, 0, LOG_DAEMON); > =20 > if (c->debug) > __setlogmask(LOG_UPTO(LOG_DEBUG)); > diff --git a/passt.c b/passt.c > index 0ba208d..72c83ad 100644 > --- a/passt.c > +++ b/passt.c > @@ -224,8 +224,6 @@ int main(int argc, char **argv) > strncpy(argv0, argv[0], PATH_MAX - 1); > name =3D basename(argv0); > if (strstr(name, "pasta")) { > - __openlog("pasta", 0, LOG_DAEMON); > - > sa.sa_handler =3D pasta_child_handler; > if (sigaction(SIGCHLD, &sa, NULL)) > die_perror("Couldn't install signal handlers"); > @@ -235,8 +233,6 @@ int main(int argc, char **argv) > =20 > c.mode =3D MODE_PASTA; > } else if (strstr(name, "passt")) { > - __openlog("passt", 0, LOG_DAEMON); > - > c.mode =3D MODE_PASST; > } else { > exit(EXIT_FAILURE); --=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 --meZaQugRErn0Ir2Q Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmZzfJAACgkQzQJF27ox 2GcoUQ//WrhJrHI8aGbktiSafTzJKMjT75kWZGZlyiIeScEQ5HB9SdZgp+rnExXg uxV7JMJ3DLcFtF+aefyrppEfEBBtlXo5SdW8JqcqwC/FKnSSURuWQHELQurttKzK 28XThUP0IbSrPJ5iXg+qqcBPiClXuoMXOIrszaYBw/bookLejL3R7g6+kqlJ/ae3 Jo0C+EnP59akY1s8FEk7SNJn0wtprj4fUarVT4zizUU7yy9YaCoodv2e6ONMuT7/ jUQLQ/fEdoy5QANPDkSvty7hPllB3aMvqV+gnTEzBL3lXPQbqwY6eJJio6tk2qNW dJ0uP8Na/xvx455QDZKHB+L+OFGWksXslUOUq2H5/7En6zutfY7CbnAngjlcOz0u B6qjAXuTxQCIaXx1lsOxoiPGRpbAqYuDIlboiWoIjzAj2MyE902DfUkqopUIDtKr VVgsoUfSDyjH/5TbMY/L6TTwthSuMyNPl9dqO7GHcnX24fQ5R9dfOaYbmUKnNEyG oDQh3CZ9eDPoz7q9dSbMrm3AwZk0/a/4JNLzWhEj/63/zfVO89XkLcsqZp6b3Atb 37iuoTGhCHTkVu6EuQOZ0nS0x7JKdsVIQBBAQDjSFkLV+lpikgXMMiekOVPOZfEs NZCmNhazdftXR8b84bvbNzrN6FIIedU6Y/XI71aH63HVT87fedQ= =1d/a -----END PGP SIGNATURE----- --meZaQugRErn0Ir2Q--