From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 869585A0272; Fri, 07 Feb 2025 01:54:39 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] passt-repair: Don't use perror(), accept ECONNRESET as termination Date: Fri, 7 Feb 2025 01:54:39 +0100 Message-ID: <20250207005439.3117473-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: NBV7PIRLKYZNO4IR5ZDJOFDYHKPK7DYM X-Message-ID-Hash: NBV7PIRLKYZNO4IR5ZDJOFDYHKPK7DYM X-MailFrom: sbrivio@passt.top 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 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: 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. While at it: ECONNRESET is just a close() from passt, treat it like EOF. Signed-off-by: Stefano Brivio --- passt-repair.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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) } if ((s = 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); _exit(1); } @@ -108,8 +108,12 @@ int main(int argc, char **argv) loop: ret = recvmsg(s, &msg, 0); if (ret < 0) { - perror("Failed to receive message"); - _exit(1); + if (errno == ECONNRESET) { + ret = 0; + } else { + fprintf(stderr, "Failed to read message: %i\n", errno); + _exit(1); + } } if (!ret) /* Done */ -- 2.43.0