From bafdfff100d3bf1e91d35664b97cfd101d564416 Mon Sep 17 00:00:00 2001 From: Kartashov Alexey Date: Thu, 9 Oct 2025 10:55:35 +0400 Subject: [PATCH 1/3] system: fix arguments validation in ubus handler Fix arguments validation (broken access to blob_attr property) Fixes: 03aab02 ("add a ubus handler that allows sending signals to processes") Signed-off-by: Kartashov Alexey [improved commit message] Signed-off-by: Daniel Golle --- system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system.c b/system.c index 7a4c24d..f6fe444 100644 --- a/system.c +++ b/system.c @@ -538,7 +538,7 @@ static int proc_signal(struct ubus_context *ctx, struct ubus_object *obj, return UBUS_STATUS_INVALID_ARGUMENT; blobmsg_parse(signal_policy, __SIGNAL_MAX, tb, blob_data(msg), blob_len(msg)); - if (!tb[SIGNAL_PID || !tb[SIGNAL_NUM]]) + if (!tb[SIGNAL_PID] || !tb[SIGNAL_NUM]) return UBUS_STATUS_INVALID_ARGUMENT; kill(blobmsg_get_u32(tb[SIGNAL_PID]), blobmsg_get_u32(tb[SIGNAL_NUM])); From c4e9859876d5db7d8d69e8dc92bc7fde44ee96ec Mon Sep 17 00:00:00 2001 From: Jeffrey Bosboom Date: Sat, 13 Dec 2025 22:38:47 -0800 Subject: [PATCH 2/3] hotplug-dispatch: use stat if d_type is DT_UNKNOWN As documented in the readdir man page, support for d_type varies by filesystem. The ISO 9660 filesystem used in the x86 target's bootable ISO images always sets d_type to DT_UNKNOWN. Fall back to checking S_ISDIR(st_mode) when d_type is DT_UNKNOWN. Fixes: 08938fe ("procd: add hotplug-call dispatcher") Signed-off-by: Jeffrey Bosboom --- hotplug-dispatch.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hotplug-dispatch.c b/hotplug-dispatch.c index fd87a09..c89c90a 100644 --- a/hotplug-dispatch.c +++ b/hotplug-dispatch.c @@ -390,6 +390,7 @@ static int init_subsystems(void) { DIR *dir; struct dirent *dirent; + struct stat st; add_subsystem("button"); @@ -399,7 +400,11 @@ static int init_subsystems(void) while ((dirent = readdir(dir))) { /* skip everything but directories */ - if (dirent->d_type != DT_DIR) + if (dirent->d_type == DT_UNKNOWN) { + if ((fstatat(dirfd(dir), dirent->d_name, &st, AT_SYMLINK_NOFOLLOW) == -1) + || !S_ISDIR(st.st_mode)) + continue; + } else if (dirent->d_type != DT_DIR) continue; /* skip '.' and '..' as well as hidden files */ From 64f97ffb6a26582ab0deac87c653723566efe9d9 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 8 Apr 2025 12:01:21 +0200 Subject: [PATCH 3/3] hotplug-dispatch: redirect output to /dev/null During the hotplug call via the procd, a list is first created with the files in the hotplug.d directory. After that the scripts are then executed in lexical order. However, if a script is deleted after the list has been created, the following message is displayed on the tty console. Command failed: Not found /bin/sh: .: line 1: can't open '/etc/hotplug.d/ntp/25-travelmate_ntp': No such file or directory So that the message is not displayed in the tty console the 'stderr' must be redirected to '/dev/null'. Signed-off-by: Florian Eckert --- hotplug-dispatch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hotplug-dispatch.c b/hotplug-dispatch.c index c89c90a..aa0fcb9 100644 --- a/hotplug-dispatch.c +++ b/hotplug-dispatch.c @@ -33,6 +33,7 @@ #include #include "procd.h" +#include "utils/utils.h" #define HOTPLUG_BASEDIR "/etc/hotplug.d" #define HOTPLUG_OBJECT_PREFIX "hotplug." @@ -120,7 +121,10 @@ static void hotplug_exec(struct uloop_timeout *t) pc->process.pid = fork(); if (pc->process.pid == 0) { /* child */ - exit(execve(exec_argv[0], exec_argv, pc->envp)); + patch_stdio("/dev/null"); + execve(exec_argv[0], exec_argv, pc->envp); + ERROR("Failed to execute script: %m\n"); + exit(EXIT_FAILURE); } else if (pc->process.pid < 0) { /* fork error */ free(script);