udebug: add support for logging via udebug Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
hotplug.c: set nl_pid to zero With the current solution where nl_pid is set through getpid we run into problems when running procd in a different PID namespace (e.g. container). The PID number inside the active PID namespace will be set which doesn't match the global PID. Therefore, procd will never receive any netlink messages. By setting nl_pid to zero the kernel will assign the global PID automatically and fixes the issue. Signed-off-by: Stefan Eichenberger <eichest@gmail.com> Acked-by: John Crispin <john@phrozen.org>
treewide: replace local mkdir_p implementations Replace local implementations of mkdir_p in favour of using the more robust implementation now added to libubox. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
procd: replace exit(-1) with exit(EXIT_FAILURE) Signed-off-by: Michael Heimpold <mhei@heimpold.de>
procd: add start-console support This adds a hotplug function to (re-)start inittab entries with askfirst or respawn. At the moment the devices used with these actions must be present during boot otherwise such lines are skipped. However, this prevents having inittab entries with consoles for e.g. USB gadget devices which only appear after kernel module loading and after configuring them with configfs. While it was possible to only scan the inittab for the desired item to start, I assume the inittab to be short and re-running the whole list will be negligible. Signed-off-by: Michael Heimpold <mhei@heimpold.de>
hotplug: improve error message during group ownership change procd currently outputs following error messages: procd: cannot set group dialout for /dev/ttyw8 procd: cannot set group dialout for /dev/ttyq1 procd: cannot set group dialout for /dev/ttywf from which it's not clear where the problem is, if it's either getgrnam or chown failing and why it's failing so this patch adds name of failed function and its errno. Ref: https://github.com/openwrt/openwrt/pull/1773#issuecomment-495555284 Signed-off-by: Petr Štetiar <ynezz@true.cz>
hotplug.c: Make sure hotplug buffer is NULL terminated Sets the final byte explicitly to NULL because we later do string operations on this buffer. Fixes Coverity issue 1430926 String not null terminated Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
procd: Add %m to several functions that return errno. Might help with debugging. No size impact. Signed-off-by: Rosen Penev <rosenp@gmail.com>
procd: Replace strerror(errno) with %m. Saves 1496 bytes from compiled size under glibc. No functional difference. Signed-off-by: Rosen Penev <rosenp@gmail.com>
procd: Fix minor null pointer dereference. Null pointer check was placed after assigning values to c. Signed-off-by: Rosen Penev <rosenp@gmail.com>
procd: Remove unnecessary memset calls. Changes allocation to calloc and {} as needed. Signed-off-by: Rosen Penev <rosenp@gmail.com>
procd: add missing new lines inside debug code Signed-off-by: John Crispin <john@phrozen.org>
hotplug: fix a memory leak in handle_button_complete() Found-by: Coverity Scan #1412460 Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
add missing includes Including sys/sysmacros.h is now necessary for makedev() on glibc 2.25. Signed-off-by: Felix Fietkau <nbd@nbd.name>
hotplug: fix uninitialized variable Commit e999ab7 (hotplug: Check chown return value) introduced a new variable "ret" which is not explicitely initialized, leading to the following compile error: hotplug.c:155:18: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized] if (!g || ret < 0) ^ cc1: all warnings being treated as errors Explicitely initialize it to zero to avoid that problem. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
hotplug: Check chown return value Fixes: plug/hotplug.c:152:10: error: ignoring return value of 'chown', declared with attribute warn_unused_result [-Werror=unused-result] chown(blobmsg_get_string(tb[0]), 0, g->gr_gid); Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
hotplug: makedev should be able to set the group of a device node Signed-off-by: John Crispin <john@phrozen.org>
hotplug: add BUTTON to environment vars for timeout action as done in pressed and released actions Signed-off-by: Günther Kelleter <guenther.kelleter@devolo.de>
allow buttons to call delayed timeout actions Signed-off-by: John Crispin <blogic@openwrt.org>
Revert "hotplug: support for interval commands" This reverts commit 9562ce477476a27851ec90cfbf971b8cb41c81a6. Revert requested by John, will be re-implemented in a different way.