Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions hotplug-dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <libubus.h>

#include "procd.h"
#include "utils/utils.h"

#define HOTPLUG_BASEDIR "/etc/hotplug.d"
#define HOTPLUG_OBJECT_PREFIX "hotplug."
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -390,6 +394,7 @@ static int init_subsystems(void)
{
DIR *dir;
struct dirent *dirent;
struct stat st;

add_subsystem("button");

Expand All @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion system.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
Expand Down
Loading