diff --git a/hotplug-dispatch.c b/hotplug-dispatch.c index fd87a09..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); @@ -390,6 +394,7 @@ static int init_subsystems(void) { DIR *dir; struct dirent *dirent; + struct stat st; add_subsystem("button"); @@ -399,7 +404,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 */ 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]));