From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202502 header.b=K83jKaL4; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 948335A0276 for ; Fri, 07 Feb 2025 02:24:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1738891470; bh=O59Lo0VFi3z5NNYuOY4grKDqRgQPo08Dqc1CHyuX9aY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=K83jKaL4F7bbnOjXZUOi3MNdY5UE5hyfpaX1j734UFXBoAjJBht1yBSZwI1fsnHIm XznSepvPObXn7k8hUIcJwhSLtHaHJteXt1Nk8pyVGW9SPH1NMuGSsy+zwCp83YFpCb zGUbec0uSwZ3Z0EToa/2RSWsXcTnGAuQ0k9HW4FHyHXOUj2o4bYjMOfdnc9lO7Kc0D WlglHz73bdUgGFrYzJNR10XUXEQlkGHJen0Yg34YfPbTJ+4iuUZDtZ9ml5O/7r4cJ0 AAsGqCzXEd/F9I0BG4iZRC3IwJX/xFbCxs8Xjwdk9aN0m8UoRERh5egEzENlD/m99i vuGBTa5g9jdyQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Ypx8Z4sdrz4wj2; Fri, 7 Feb 2025 12:24:30 +1100 (AEDT) Date: Fri, 7 Feb 2025 12:15:35 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] passt-repair: Don't use perror(), accept ECONNRESET as termination Message-ID: References: <20250207005439.3117473-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pfEfiVNnCySXBuZT" Content-Disposition: inline In-Reply-To: <20250207005439.3117473-1-sbrivio@redhat.com> Message-ID-Hash: NM2TFSRI6NI6JLSGSUA6QJ7JZ36RA6IO X-Message-ID-Hash: NM2TFSRI6NI6JLSGSUA6QJ7JZ36RA6IO 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 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: --pfEfiVNnCySXBuZT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 07, 2025 at 01:54:39AM +0100, Stefano Brivio wrote: > If we use glibc's perror(), we need to allow dup() and fcntl() in our > seccomp profiles, which are a bit too much for this simple helper. On > top of that, we would probably need a wrapper to avoid allocation for > translated messages. >=20 > While at it: ECONNRESET is just a close() from passt, treat it like > EOF. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > passt-repair.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) >=20 > diff --git a/passt-repair.c b/passt-repair.c > index 3c3247b..d137a18 100644 > --- a/passt-repair.c > +++ b/passt-repair.c > @@ -95,7 +95,7 @@ int main(int argc, char **argv) > } > =20 > if ((s =3D socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { > - perror("Failed to create AF_UNIX socket"); > + fprintf(stderr, "Failed to create AF_UNIX socket: > %i\n", errno); We could use strerror_() here, couldn't we? > _exit(1); > } > =20 > @@ -108,8 +108,12 @@ int main(int argc, char **argv) > loop: > ret =3D recvmsg(s, &msg, 0); > if (ret < 0) { > - perror("Failed to receive message"); > - _exit(1); > + if (errno =3D=3D ECONNRESET) { > + ret =3D 0; > + } else { > + fprintf(stderr, "Failed to read message: %i\n", errno); > + _exit(1); > + } > } > =20 > if (!ret) /* Done */ --=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 --pfEfiVNnCySXBuZT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmelXrMACgkQzQJF27ox 2GflIg//YYexvVCV77E980TglbcX4NNcgKwzUbLROKyQDzkDcFnAoHtnKKe5uFKG LjIlXCwXr3V5DEElWjNwNcmBRWDGc1sgstJkYPOsWkdMkm5X5IXdt2ghcWlSmwaQ PAq0md1Mu3kEEve6dNrnicdtvfqj8FR1ewmQW0/HtE8ur1oSf2MUUL18Qv2/VEaT cOPYwErOYHSxAzTm4yuISfu/tAIhDYlJBywjPP2ue7q3ATjzNdZhPpJvy7ddDVSE R6Sr1wCD1lpRj/p9IRB5C6I0c3vjlnReAuqxOaIqFQWEFZk4YsybDTntNZrui4qx +9VhhkaJlp1MClTvDAlxrM/YvER7ZSYw2O4zzu7wtqCpfPjTnUJk9TY4GOiCRuvX XPaKAndHC4+S+m58dsuVx/ezPTqRwS2bGxLRlVz1o+bbteD/s00yEnPPodjk4AD8 J1ZMCf1XE4mnw4dCGEUeuPbfM8HGn+0ZVUzbPA0vq+RUxzvJFPcvRissbtp6oU5G 0TaLrfNStD6ENoWvsy998rvDmFzvYprnd9HbyLNHq4Zo/DBPBxClPt44zfvMclB7 E2B5Q0OcZISZVBdIOQ9udmNjOjl48vy42Jpqtp0ewsea/iI5iJqc8WUOd2GmQdXf bRS0lc3eaCt0L3t/PV4pAonQqVJkONGncabWQDekJ8wIV4lE1bU= =XBJr -----END PGP SIGNATURE----- --pfEfiVNnCySXBuZT--