summaryrefslogtreecommitdiff
path: root/state.c
Commit message (Collapse)AuthorAgeFilesLines
* procd: fix compiler warningJohn Crispin2021-01-261-1/+4
| | | | | | | | | | | | | | [ 37%] Building C object CMakeFiles/procd.dir/state.c.o /projects/procd/state.c: In function ‘state_enter’: /projects/procd/state.c:147:4: error: ignoring return value of ‘chown’, declared with attribute warn_unused_result [-Werror=unused-result] 147 | chown(p->pw_dir, p->pw_uid, p->pw_gid); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[2]: *** [CMakeFiles/procd.dir/build.make:89: CMakeFiles/procd.dir/state.c.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:241: CMakeFiles/procd.dir/all] Error 2 make: *** [Makefile:130: all] Error 2 Signed-off-by: John Crispin <john@phrozen.org>
* early: fall-back to run ubus as root if user can't be foundDaniel Golle2020-12-041-1/+4
| | | | | | | Users have been reporting problems in case the ubus user is missing in /etc/passwd. Run ubus as root in that case and display warning. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* early: run ubusd non-root as user ubus, group ubusDaniel Golle2020-10-191-1/+8
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* state: fix reboot causing shutdown inside LXC containerPetr Štetiar2020-01-211-22/+30
| | | | | | | | | | | | | | | | | | | | | | Executing `reboot` command in OpenWrt system runing inside LXC container results in a shutdown of the container instead of rebooting the container. This appears to have been caused by commit 832369078d81 ("state: fix shutdown when running in a container (FS#2425)"), which exits the pid einz instead of the reboot(). While at it, refactor the halting code into separate function to shorten the switch/case block and make it clearer, decrease the indentation level by reversing the container if condition, replace magic 0 with EXIT_SUCCESS constant in exit() and make it wait 1s for reboot message delivery in both container/host cases as well. Ref: FS#2666 Cc: Paul Spooren <mail@aparcar.org> Fixes: 832369078d81 ("state: fix shutdown when running in a container (FS#2425)") Tested-by: Baptiste Jonglez <lede@bitsofnetworks.org> Signed-off-by: Petr Štetiar <ynezz@true.cz>
* state: fix shutdown when running in a container (FS#2425)Paul Spooren2019-08-051-11/+16
| | | | | | | | | | | | | | | | | Applies patch from @mikma [0] to fix Docker shutdown. Added detection to state.c if running in a container or not. Tested with a x86/64 Docker image. Fixes FS#2425 CC: Mikael Magnusson <mikma@users.sourceforge.net> CC: Petr Štetiar <ynezz@true.cz> [0]: https://github.com/mikma/lxd-openwrt/blob/master/patches/procd-master/0003-docker-fix-problem-stopping-container.patch Signed-off-by: Paul Spooren <mail@aparcar.org> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> [coding style aligment]
* procd: Add %m to several functions that return errno.Rosen Penev2018-01-021-3/+3
| | | | | | Might help with debugging. No size impact. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* add late variant of respawn and askconsoleJohn Crispin2016-09-281-0/+2
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* service: get rid of service_init and service_validate_init, use static avl ↵Felix Fietkau2016-03-051-1/+0
| | | | | | tree initialization Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* add a build-time option to disable init related codeFelix Fietkau2016-03-051-1/+4
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* properly handle return codesJohn Crispin2015-03-281-8/+14
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* Convert log calls to ulog() apiJo-Philipp Wich2015-02-251-0/+3
| | | | Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* Fix ctrl+alt+del supportMichel Stam2014-10-121-0/+2
| | | | | | | | The previous patch did not catch SIGINT, which is used by the kernel to indicate to the init process that the system should reboot. Signed-off-by: Michel Stam <m.stam@fugro.nl>
* Show the shutdown sequence on the active virtual terminalMichel Stam2014-10-121-0/+52
| | | | | | | | | | | | procd by default writes to /dev/console. When rebooting, this means that the terminal on which the reboot sequence was started will not see what is going on. This patch fixes that by reopening stdin, stdout and stderr to the console device specified on the commandline, /dev/tty0 or /dev/console upon reboot. Also, due to (probably) pivot-root, /proc/1/fd shows 1-3 pointing to /console. This patch also fixes that. Signed-off-by: Michel Stam <m.stam@fugro.nl>
* make procd wait for ubus to come upJohn Crispin2014-10-061-3/+11
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* Fix 'reboot' message when the system is powering downMichel Stam2014-10-021-1/+4
| | | | | | | | While executing a system halt (via the powerbutton or otherwise), the system displays rebooting, whereas it should display that it is going to turn off. Signed-off-by: Michel Stam <m.stam@fugro.nl>
* Reboot busybox style via procdMichel Stam2014-10-021-1/+14
| | | | | | | | | | It has been observed that, very rarely, the system does not reboot when procd enters the shutdown state. Busybox seems to have an obscure fix in its shutdown, where the parent (procd) process is put in an infinite loop, and a special child is executed to execute reboot(). This may very well be the cause. Signed-off-by: Michel Stam <m.stam@fugro.nl>
* Kill processes on shutdownMichel Stam2014-10-021-0/+10
| | | | | | | | Procd as it currently is does not kill the running processes during shutdown. As this might cause undesired behaviour, this should be implemented. Implementation was taken from busybox 1.19.4 Signed-off-by: Michel Stam <m.stam@fugro.nl>
* Fix procd not handling rapid reboot signals very wellMichel Stam2014-10-021-0/+2
| | | | | | | | | | When keeping ctrl-alt-del pressed, or when running; while true; do /sbin/reboot done effectively the procd shutdown cycle gets into an undefined state, Signed-off-by: Michel Stam <m.stam@fugro.nl>
* state.c: pass ubus commandline is writable buffer to service_start_early()Jo-Philipp Wich2014-01-201-1/+2
| | | | | | | | | The service_start_early() function uses strtok() on the command line argument, therfore we cannot pass it constant string literals directly. Fixes OpenWrt bug #14832 Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* debloat and reorganize codeJohn Crispin2013-11-151-6/+9
| | | | | | | split app into procd and init binaries remove log support, this is an external service now Signed-off-by: John Crispin <blogic@openwrt.org>
* add service_validator supportJohn Crispin2013-11-121-0/+2
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* Fix event type reporting when calling 'procd_shutdown'.Yousong Zhou2013-07-231-1/+1
| | | | Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
* the cloexec logic of the watchdog was brokenJohn Crispin2013-07-141-4/+3
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* fix up watchdog init codeJohn Crispin2013-07-111-0/+3
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* get rid of sleep() callsJohn Crispin2013-06-271-2/+1
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* add respawn supportJohn Crispin2013-06-241-0/+1
| | | | | | https://dev.openwrt.org/ticket/13751 Signed-off-by: John Crispin <blogic@openwrt.org>
* drop good bye messageJohn Crispin2013-06-141-1/+1
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* add state handlerJohn Crispin2013-03-131-0/+93