git: c85ba9733b0d - main - sysutils/conmon: Fix podman's restart-policy handling

From: Doug Rabson <dfr_at_FreeBSD.org>
Date: Mon, 12 Jun 2023 10:10:16 UTC
The branch main has been updated by dfr:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c85ba9733b0dd5ec45bc9816b3ff065ab1f3218f

commit c85ba9733b0dd5ec45bc9816b3ff065ab1f3218f
Author:     Doug Rabson <dfr@FreeBSD.org>
AuthorDate: 2023-06-06 07:42:07 +0000
Commit:     Doug Rabson <dfr@FreeBSD.org>
CommitDate: 2023-06-12 10:08:56 +0000

    sysutils/conmon: Fix podman's restart-policy handling
    
    Approved-by:    dch
    Differential Revision: https://reviews.freebsd.org/D40437
---
 sysutils/conmon/Makefile                     |  2 +-
 sysutils/conmon/files/patch-src_close__fds.c | 33 ++++++++++++++++++++++++++++
 sysutils/conmon/pkg-message                  | 17 ++++++++++++++
 3 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/sysutils/conmon/Makefile b/sysutils/conmon/Makefile
index 251c26caa78b..5114574ede56 100644
--- a/sysutils/conmon/Makefile
+++ b/sysutils/conmon/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	conmon
 DISTVERSIONPREFIX=	v
 DISTVERSION=	2.1.7
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	sysutils
 
 MAINTAINER=	dfr@FreeBSD.org
diff --git a/sysutils/conmon/files/patch-src_close__fds.c b/sysutils/conmon/files/patch-src_close__fds.c
new file mode 100644
index 000000000000..70c296705df3
--- /dev/null
+++ b/sysutils/conmon/files/patch-src_close__fds.c
@@ -0,0 +1,33 @@
+--- src/close_fds.c.orig	2023-02-28 02:39:11 UTC
++++ src/close_fds.c
+@@ -22,6 +22,12 @@
+ 
+ #include <sys/stat.h>
+ 
++#ifdef __FreeBSD__
++#define OPEN_FILES_DIR "/dev/fd"
++#else
++#define OPEN_FILES_DIR "/proc/self/fd"
++#endif
++
+ static int open_files_max_fd;
+ static fd_set *open_files_set;
+ 
+@@ -31,7 +37,7 @@ static void __attribute__((constructor)) init()
+ 	ssize_t size = 0;
+ 	DIR *d;
+ 
+-	d = opendir("/proc/self/fd");
++	d = opendir(OPEN_FILES_DIR);
+ 	if (!d)
+ 		return;
+ 
+@@ -85,7 +91,7 @@ void close_all_fds_ge_than(int firstfd)
+ 	struct dirent *ent;
+ 	DIR *d;
+ 
+-	d = opendir("/proc/self/fd");
++	d = opendir(OPEN_FILES_DIR);
+ 	if (!d)
+ 		return;
+ 
diff --git a/sysutils/conmon/pkg-message b/sysutils/conmon/pkg-message
new file mode 100644
index 000000000000..f3784b3d66c6
--- /dev/null
+++ b/sysutils/conmon/pkg-message
@@ -0,0 +1,17 @@
+[
+{ type: install
+  message: <<EOM
+
+To properly support podman's container restart policy, conmon needs fdescfs(5)
+to be mounted on /dev/fd.
+
+If /dev/fd is not already mounted:
+
+	mount -t fdescfs fdesc /dev/fd
+
+To make it permanent, add the following line to /etc/fstab:
+
+	fdesc	/dev/fd		fdescfs		rw	0	0
+EOM
+}
+]