buildoot: enforce sysrepo group, umask, and permissions

This patch enables umask and nacm defalts in the Buildoot sysrepo
package and a patch to sysrepo to set the sysrepo group also on the
event pipes in /etc/sysrepo/, without which it would be hard to inject
any type of new event as non-root user now since the umask now prevent
all 'other' users from interacting with sysrepo.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-01-22 22:44:13 +01:00
parent 078839d988
commit 7559f4be83
9 changed files with 58 additions and 40 deletions
@@ -1,15 +1,11 @@
From efe7706fd7397c2feb384afea00ee97e74287df0 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
Date: Tue, 28 Mar 2023 10:37:53 +0200
Subject: [PATCH 1/8] sysrepo-plugind: add support for running in foreground
Subject: [PATCH 1/9] sysrepo-plugind: add support for running in foreground
with syslog
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Wires
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Mattias Walström <lazzer@gmail.com>
---
src/executables/sysrepo-plugind.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
@@ -1,10 +1,7 @@
From 11b9938206cf2bafc456bb22e14c7f85a604760c Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
Date: Tue, 7 May 2024 15:41:53 +0200
Subject: [PATCH 2/8] Allow SR_EV_DONE to return any error to sysrepocfg
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Subject: [PATCH 2/9] Allow SR_EV_DONE to return any error to sysrepocfg
Organization: Wires
Importing a system configuration with sysrepocfg the model callbacks do
@@ -20,7 +17,6 @@ This patch is a clumsy way of forcing the (first) error to bubble up to
the surface and cause a non-zero exit code from sysrepocfg.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Mattias Walström <lazzer@gmail.com>
---
src/shm_sub.c | 40 +++++++++++++++++++++++++++++++---------
src/shm_sub.h | 2 +-
@@ -1,13 +1,10 @@
From 9e0267d4f20733b2a26df6d0ee0bc4019db8b13f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= <lazzer@gmail.com>
Date: Wed, 8 May 2024 17:00:50 +0200
Subject: [PATCH 3/8] Allow to copy from factory default
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Subject: [PATCH 3/9] Allow to copy from factory default
Organization: Wires
Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
---
src/sysrepo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -1,16 +1,13 @@
From e0c899ba266b959544d7cc08c917cebba7ac91c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= <lazzer@gmail.com>
Date: Mon, 6 May 2024 14:49:32 +0200
Subject: [PATCH 4/8] Add -z switch to sysrepoctl to install factory config
Subject: [PATCH 4/9] Add -z switch to sysrepoctl to install factory config
from a json file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Wires
This to be able to load the yang modules during build time instead on boot.
Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
---
src/executables/sysrepoctl.c | 20 +++++++++++++--
src/lyd_mods.h | 7 ++++++
@@ -1,10 +1,7 @@
From c7602dc8eabb941e0a163208aaf4de92dd5ef526 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
Date: Wed, 21 Aug 2024 16:00:35 +0200
Subject: [PATCH 5/8] Introduce new log level [SEC] for audit trails
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Subject: [PATCH 5/9] Introduce new log level [SEC] for audit trails
Organization: Wires
This adds a new log level for security and audit trail related log
@@ -22,7 +19,6 @@ system log daemon, dropping any [SEVERITY] prefix. Also, \n is most
often dropped by log daemons.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Mattias Walström <lazzer@gmail.com>
---
src/log.c | 18 +++++++++++++++++-
src/log.h | 1 +
@@ -1,10 +1,7 @@
From a86dfdd4a5cb74c1f8c90c8d5aea6f5505c1b88c Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
Date: Wed, 21 Aug 2024 16:04:43 +0200
Subject: [PATCH 6/8] Add audit trail for high priority system changes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Subject: [PATCH 6/9] Add audit trail for high priority system changes
Organization: Wires
Committing a change to running, copying to a datastore, or calling an
@@ -16,7 +13,6 @@ is when the system actually activates the changes. Copying to startup
or other datastores is handled separately.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Mattias Walström <lazzer@gmail.com>
---
src/sysrepo.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
@@ -1,10 +1,7 @@
From dbf08c67d8f17bdf98466b18fd72a230269e5d46 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
Date: Fri, 23 Aug 2024 12:22:06 +0200
Subject: [PATCH 7/8] On error in sr_shmsub_listen_thread(), exit process
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Subject: [PATCH 7/9] On error in sr_shmsub_listen_thread(), exit process
Organization: Wires
If processing callback events in, e.g., sysrepo-plugind, make sure to
@@ -12,7 +9,6 @@ log the error and exit(1) the entire process so the system can decide
to handle the problem. For example, restart all dependent services.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Mattias Walström <lazzer@gmail.com>
---
src/shm_sub.c | 2 ++
1 file changed, 2 insertions(+)
@@ -1,13 +1,10 @@
From 2549c966c090dd38a7a09907d27d13107d15aedd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= <lazzer@gmail.com>
Date: Tue, 16 Dec 2025 08:18:32 +0100
Subject: [PATCH 8/8] Cross compile fixes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Subject: [PATCH 8/9] Cross compile fixes
Organization: Wires
Signed-off-by: Mattias Walström <lazzer@gmail.com>
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
---
CMakeModules/SetupPrintedContext.cmake | 9 +++++++++
1 file changed, 9 insertions(+)
@@ -0,0 +1,47 @@
From 78d62382bf9d665764844a0f686b27e42d73bea9 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
Date: Wed, 7 Jan 2026 18:09:32 +0100
Subject: [PATCH 9/9] sr_mkfifo(): set sysrepo group if available
Organization: Wires
We already set the umask, set the group to allow users of the sysrepo
group to initiate events.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
---
src/common.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/common.c b/src/common.c
index 447fbd28..ad39f0ef 100644
--- a/src/common.c
+++ b/src/common.c
@@ -3883,6 +3883,7 @@ sr_error_info_t *
sr_mkfifo(const char *path, mode_t mode)
{
sr_error_info_t *err_info = NULL;
+ gid_t gid;
/* apply umask on mode */
mode &= ~SR_UMASK;
@@ -3900,6 +3901,17 @@ sr_mkfifo(const char *path, mode_t mode)
return err_info;
}
+ /* and group, if any */
+ if (sr_is_prod_env() && strlen(SR_GROUP)) {
+ if ((err_info = sr_get_gid(SR_GROUP, &gid)))
+ return err_info;
+
+ if (chown(path, -1, gid) == -1) {
+ SR_ERRINFO_SYSERRNO(&err_info, "chown");
+ return err_info;
+ }
+ }
+
return NULL;
}
--
2.43.0