From b3f9387f0d489dabddbc04abe7235c0db1cc1396 Mon Sep 17 00:00:00 2001 From: sthen Date: Wed, 7 Dec 2022 10:39:01 +0000 Subject: [PATCH] unbreak uacme's ualpn daemon on OpenBSD, based on a diff from Michel Belleau - Don't use process-shared semaphores unless multiple workers are used; OpenBSD's semaphore implementation doesn't support them. - Default to using a single worker on OpenBSD, so that extra flags aren't needed to allow ualpn to work. --- security/uacme/Makefile | 2 ++ security/uacme/patches/patch-ualpn_c | 48 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 security/uacme/patches/patch-ualpn_c diff --git a/security/uacme/Makefile b/security/uacme/Makefile index 1d6aadd57ea..05009b7d215 100644 --- a/security/uacme/Makefile +++ b/security/uacme/Makefile @@ -7,6 +7,8 @@ GH_TAGNAME= upstream/$V DISTNAME= uacme-$V WRKDIST= ${WRKDIR}/uacme-upstream-$V +REVISION= 0 + CATEGORIES= security www MAINTAINER= Stuart Henderson diff --git a/security/uacme/patches/patch-ualpn_c b/security/uacme/patches/patch-ualpn_c new file mode 100644 index 00000000000..a6dd4ca023a --- /dev/null +++ b/security/uacme/patches/patch-ualpn_c @@ -0,0 +1,48 @@ +Don't use process-shared semaphores unless multiple workers are used; +OpenBSD's implementation doesn't support them. + +Default to using a single worker, so that extra flags aren't needed +to make this work. + +Index: ualpn.c +--- ualpn.c.orig ++++ ualpn.c +@@ -328,7 +328,11 @@ static struct globs { + .logfile = NULL, + .family = AF_UNSPEC, + .proxy = 1, ++#ifdef __OpenBSD__ ++ .num_workers = 1, ++#else + .num_workers = 2, ++#endif + .max_auths = 100, + .progname = NULL, + .chroot = NULL, +@@ -4072,6 +4076,7 @@ int main(int argc, char **argv) + mode_t mask; + struct rlimit rl; + bool server_mode = false; ++ int needs_pshared = 0; + + g.argv = argv; + +@@ -4696,12 +4701,16 @@ int main(int argc, char **argv) + memset(g_shm, 0, g_shm_size); + for (size_t n = 0; n < g.max_auths; n++) + SGLIB_DL_LIST_ADD(auth_t, g_shm->avail, g_shm->pool + n, left, right); +- if (sem_init(&g_shm->sem, 1, 1)) { ++ ++ if (g.num_workers > 1) ++ needs_pshared = 1; ++ ++ if (sem_init(&g_shm->sem, needs_pshared, 1)) { + err("sem_init failed"); + cleanup_and_exit(2, EXIT_FAILURE); + } + +- if (sem_init(&g_shm->logsem, 1, 1)) { ++ if (sem_init(&g_shm->logsem, needs_pshared, 1)) { + err("sem_init failed"); + cleanup_and_exit(3, EXIT_FAILURE); + }