git: 7ddec062787b - main - sysutils/devctl-jail-kmod: new port

From: Luca Pizzamiglio <pizzamig_at_FreeBSD.org>
Date: Mon, 03 Oct 2022 17:09:27 UTC
The branch main has been updated by pizzamig:

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

commit 7ddec062787b2ef2443e540d0b56489bb1fffc0c
Author:     Luca Pizzamiglio <pizzamig@FreeBSD.org>
AuthorDate: 2022-10-03 17:04:42 +0000
Commit:     Luca Pizzamiglio <pizzamig@FreeBSD.org>
CommitDate: 2022-10-03 17:08:45 +0000

    sysutils/devctl-jail-kmod: new port
    
    This kernel module provides jails status changes
    in devctl, and available to devd
    
        Initial non working draft
        Fix include order for 13+
        Fix category's makefile
    
        Remove devctl_notify_f that has been removed in later version
        The flag used is the default one, so we are not introducing
        different behaviors
---
 sysutils/Makefile                                  |  1 +
 sysutils/devctl-jail-kmod/Makefile                 | 19 ++++++++
 sysutils/devctl-jail-kmod/distinfo                 |  3 ++
 .../devctl-jail-kmod/files/patch-devctl__jail.c    | 50 ++++++++++++++++++++++
 sysutils/devctl-jail-kmod/pkg-descr                |  3 ++
 5 files changed, 76 insertions(+)

diff --git a/sysutils/Makefile b/sysutils/Makefile
index 3f425b3abc91..a262a1a51746 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -263,6 +263,7 @@
     SUBDIR += deltup
     SUBDIR += desktop-installer
     SUBDIR += detox
+    SUBDIR += devctl-jail-kmod
     SUBDIR += devcpu-data
     SUBDIR += devcpu-data-amd
     SUBDIR += devcpu-data-intel
diff --git a/sysutils/devctl-jail-kmod/Makefile b/sysutils/devctl-jail-kmod/Makefile
new file mode 100644
index 000000000000..09ad9bc79b7f
--- /dev/null
+++ b/sysutils/devctl-jail-kmod/Makefile
@@ -0,0 +1,19 @@
+PORTNAME=	devctl-jail-kmod
+DISTVERSION=	g20190521
+CATEGORIES=	sysutils
+
+MAINTAINER=	pizzamig@FreeBSD.org
+COMMENT=	Module to expose jail lifecycle events
+
+LICENSE=	BSD3CLAUSE
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+USES=	kmod uidfix
+USE_GITHUB=	yes
+GH_ACCOUNT=	fubarnetes
+GH_PROJECT=	kmod_devctl_jail
+GH_TAGNAME=	d3c17d2381a
+
+PLIST_FILES=	${KMODDIR}/devctl_jail.ko
+
+.include <bsd.port.mk>
diff --git a/sysutils/devctl-jail-kmod/distinfo b/sysutils/devctl-jail-kmod/distinfo
new file mode 100644
index 000000000000..4885e795e88b
--- /dev/null
+++ b/sysutils/devctl-jail-kmod/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1663582453
+SHA256 (fubarnetes-kmod_devctl_jail-g20190521-d3c17d2381a_GH0.tar.gz) = 6ad5e1a8cfd4704499be29c5881ac41817220ba0cd51521ed2e9f9054afbbcfb
+SIZE (fubarnetes-kmod_devctl_jail-g20190521-d3c17d2381a_GH0.tar.gz) = 4187
diff --git a/sysutils/devctl-jail-kmod/files/patch-devctl__jail.c b/sysutils/devctl-jail-kmod/files/patch-devctl__jail.c
new file mode 100644
index 000000000000..969cbc22a0ef
--- /dev/null
+++ b/sysutils/devctl-jail-kmod/files/patch-devctl__jail.c
@@ -0,0 +1,50 @@
+--- devctl_jail.c.orig	2019-05-21 13:00:05 UTC
++++ devctl_jail.c
+@@ -34,10 +34,10 @@
+ 
+ #include <sys/cdefs.h>
+ #include <sys/types.h>
++#include <sys/param.h>  /* defines used in kernel.h */
+ #include <sys/module.h>
+ #include <sys/systm.h>  /* uprintf */
+ #include <sys/errno.h>
+-#include <sys/param.h>  /* defines used in kernel.h */
+ #include <sys/kernel.h> /* types used in module initialization */
+ #include <sys/jail.h>
+ #include <sys/proc.h>
+@@ -73,7 +73,7 @@ devctl_jail_prison_create(void *obj, void *data __unus
+   sbuf_new(&sb, buf, DEVCTL_JAIL_LOGSIZE, SBUF_FIXEDLEN);
+   sbuf_printf(&sb, "jid=%d", pr->pr_id);
+   sbuf_finish(&sb);
+-  devctl_notify_f("kernel", "jail", "created", sbuf_data(&sb), M_NOWAIT);
++  devctl_notify("kernel", "jail", "created", sbuf_data(&sb));
+   sbuf_delete(&sb);
+   free(buf, M_DEVCTL_JAIL);
+   return (0);
+@@ -117,7 +117,7 @@ devctl_jail_prison_set(void *obj, void *data)
+   }
+ 
+   sbuf_finish(&sb);
+-  devctl_notify_f("kernel", "jail", "updated", sbuf_data(&sb), M_NOWAIT);
++  devctl_notify("kernel", "jail", "updated", sbuf_data(&sb));
+   sbuf_delete(&sb);
+   free(buf, M_DEVCTL_JAIL);
+   return (0);
+@@ -143,7 +143,7 @@ devctl_jail_prison_remove(void *obj, void *data __unus
+   sbuf_new(&sb, buf, DEVCTL_JAIL_LOGSIZE, SBUF_FIXEDLEN);
+   sbuf_printf(&sb, "jid=%d", pr->pr_id);
+   sbuf_finish(&sb);
+-  devctl_notify_f("kernel", "jail", "removed", sbuf_data(&sb), M_NOWAIT);
++  devctl_notify("kernel", "jail", "removed", sbuf_data(&sb));
+   sbuf_delete(&sb);
+   free(buf, M_DEVCTL_JAIL);
+   return (0);
+@@ -165,7 +165,7 @@ devctl_jail_prison_attach(void *obj, void *data __unus
+   sbuf_new(&sb, buf, DEVCTL_JAIL_LOGSIZE, SBUF_FIXEDLEN);
+   sbuf_printf(&sb, "jid=%d pid=%d", pr->pr_id, td->td_proc->p_pid);
+   sbuf_finish(&sb);
+-  devctl_notify_f("kernel", "jail", "attached", sbuf_data(&sb), M_NOWAIT);
++  devctl_notify("kernel", "jail", "attached", sbuf_data(&sb));
+   sbuf_delete(&sb);
+   free(buf, M_DEVCTL_JAIL);
+   return (0);
diff --git a/sysutils/devctl-jail-kmod/pkg-descr b/sysutils/devctl-jail-kmod/pkg-descr
new file mode 100644
index 000000000000..0e99d254bd02
--- /dev/null
+++ b/sysutils/devctl-jail-kmod/pkg-descr
@@ -0,0 +1,3 @@
+Kernel mdule providing dectl notifications for jails
+Jails event like start and stop can be notified via devd.
+Devd acions can be added to send messages to syslogd