From d7c05bd5f83de097d211cbdbff6f9049fbd68185 Mon Sep 17 00:00:00 2001 From: claudio Date: Wed, 19 Jun 2024 13:13:25 +0000 Subject: [PATCH] Kill the SIGPIPE signal handler which is installed around write opertations. Instead just SIG_IGN SIGPIPE in main.c for all of acme-client. More work to be done here but at least this distraction is gone. OK florian@ deraadt@ op@ --- usr.sbin/acme-client/main.c | 5 ++++- usr.sbin/acme-client/util.c | 25 +------------------------ 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/usr.sbin/acme-client/main.c b/usr.sbin/acme-client/main.c index bec17254297..2c1c8a2370f 100644 --- a/usr.sbin/acme-client/main.c +++ b/usr.sbin/acme-client/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.55 2022/05/05 19:51:35 florian Exp $ */ +/* $Id: main.c,v 1.56 2024/06/19 13:13:25 claudio Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons * @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -202,6 +203,8 @@ main(int argc, char *argv[]) if (socketpair(AF_UNIX, SOCK_STREAM, 0, rvk_fds) == -1) err(EXIT_FAILURE, "socketpair"); + signal(SIGPIPE, SIG_IGN); + /* Start with the network-touching process. */ if ((pids[COMP_NET] = fork()) == -1) diff --git a/usr.sbin/acme-client/util.c b/usr.sbin/acme-client/util.c index cb53440d58e..67710cd3cd9 100644 --- a/usr.sbin/acme-client/util.c +++ b/usr.sbin/acme-client/util.c @@ -1,4 +1,4 @@ -/* $Id: util.c,v 1.13 2022/12/28 21:30:15 jmc Exp $ */ +/* $Id: util.c,v 1.14 2024/06/19 13:13:25 claudio Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons * @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -31,8 +30,6 @@ #include "extern.h" -static volatile sig_atomic_t sig; - static const char *const comps[COMP__MAX] = { "netproc", /* COMP_NET */ "keyproc", /* COMP_KEY */ @@ -71,14 +68,6 @@ static const char *const comms[COMM__MAX] = { "revoke-response", /* COMM_REVOKE_RESP */ }; -static void -sigpipe(int code) -{ - - (void)code; - sig = 1; -} - /* * This will read a long-sized operation. * Operations are usually enums, so this should be alright. @@ -169,21 +158,15 @@ readbuf(int fd, enum comm comm, size_t *sz) int writeop(int fd, enum comm comm, long op) { - void (*sigfp)(int); ssize_t ssz; int er; - sigfp = signal(SIGPIPE, sigpipe); - if ((ssz = write(fd, &op, sizeof(long))) == -1) { if ((er = errno) != EPIPE) warn("write: %s", comms[comm]); - signal(SIGPIPE, sigfp); return er == EPIPE ? 0 : -1; } - signal(SIGPIPE, sigfp); - if ((size_t)ssz != sizeof(long)) { warnx("short write: %s", comms[comm]); return -1; @@ -201,21 +184,16 @@ writebuf(int fd, enum comm comm, const void *v, size_t sz) { ssize_t ssz; int er, rc = -1; - void (*sigfp)(int); /* * First, try to write the length. * If the other end of the pipe has closed, we allow the short * write to propagate as a return value of zero. - * To detect this, catch SIGPIPE. */ - sigfp = signal(SIGPIPE, sigpipe); - if ((ssz = write(fd, &sz, sizeof(size_t))) == -1) { if ((er = errno) != EPIPE) warn("write: %s length", comms[comm]); - signal(SIGPIPE, sigfp); return er == EPIPE ? 0 : -1; } @@ -233,7 +211,6 @@ writebuf(int fd, enum comm comm, const void *v, size_t sz) else rc = 1; - signal(SIGPIPE, sigfp); return rc; } -- 2.20.1