summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-06-19 13:13:26 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-06-19 13:13:26 +0000
commitc2804864b67f66191121bea2a76c9f249bf1e347 (patch)
tree77a85c0989383dc757a358c4310133d11995a166
parentf34cb3f8fb7a131bdaa172c7860f5055f8acba9a (diff)
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@
-rw-r--r--usr.sbin/acme-client/main.c5
-rw-r--r--usr.sbin/acme-client/util.c25
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 <kristaps@bsd.lv>
*
@@ -21,6 +21,7 @@
#include <err.h>
#include <libgen.h>
#include <locale.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -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 <kristaps@bsd.lv>
*
@@ -21,7 +21,6 @@
#include <err.h>
#include <errno.h>
#include <limits.h>
-#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -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;
}