summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* trace: add missing limits.h includelede-17.01Hans Dedecker2018-02-051-0/+1
| | | | | | | Fixes compile issue when using glibc as INT_MAX is reported as undeclared. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* procd: Fix minor null pointer dereference.Rosen Penev2018-01-041-3/+3
| | | | | | Null pointer check was placed after assigning values to c. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* procd: initd: fix path allocation in early_insmodNathan Hintz2018-01-041-1/+1
| | | | | | | | | | Noticed that /tmp was not being created on /dev/zram0. This was on ixp4xx (nslu2) using GCC 6.3 and musl. The allocation should be using the length of the passed string (module path), not the size of the pointer to the string. Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
* service: fix calls to blobmsg_parse()Pierre Lebleu2017-11-141-8/+8
| | | | | | | We should use blobmsg_data() rather than blob_data() and blobmsg_data_len() rather than blob_len(). Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
* procd: add missing new lines inside debug codeJohn Crispin2017-11-142-7/+5
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* service: fix SERVICE_ATTR_NAME usage in service_handle_setpme.lebleu@gmail.com2017-10-041-1/+1
| | | | | | The SERVICE_SET_NAME belongs to enum SERVICE_SET_XXXX, not SERVICE_ATTR_NAME. Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
* watchdog: fix inline watchdog_get_magicclose function prototypeHans Dedecker2017-08-081-1/+2
| | | | | | | Fix procd compilation issue which occurs when DISABLE_INIT is set as the inline watchdog_get_magicclose function prototype was wrong. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* procd: Do not leak pipe file descriptors to childrenMichal Sojka2017-07-312-0/+3
| | | | | | | Without this change, a process started by procd can have access to stdout/err of processes started by procd before. Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
* watchdog: add support for starting/stopping kernel watchdogHans Dedecker2017-07-123-18/+74
| | | | | | | | | | Extend the ubus watchdog cmd with the parameter magicclose; when set and in case the stopped parameter is enabled the kernel watchdog will be stopped by first sending the magic character 'V' followed by a close of the watchdog fd. In case stopped is set to disabled the watchdog fd will be created again. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> Acked-by: John Crispin <john@phrozen.org>
* system: introduce new attribute board_nameDaniel Golle2017-06-201-0/+34
| | | | | | | | | | | | | | | | | | | The system board call returns the verbose model string instead of the board name. Unfortunately we have not yet estabkushed clear convention regarding device-tree 'compatible' or 'model' property and sysupgrade image name (same accounts for scraping /proc/cpuinfo on legacy targets). This is odd as the idea was to return information needed to identify the right sysupgrade image. On most targets we got a large shell-script which translates either /proc/cpuinfo or the 'model' property back into the board name used here. Hence introduce a new attribute board_name to return either /tmp/sysinfo/board_name or /proc/device-tree/compatible. This combines commit 79bbe6d (system: return legacy board name) and commit 453116e (system: introduce new attribute board_name) from the master branch into a single commit. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* preinit: define _GNU_SOURCEHans Dedecker2017-06-201-0/+1
| | | | | | | In uClibc getdelim is only defined if _GNU_SOURCE is defined; fix compilation issue by defining _GNU_SOURCE Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* upgraded: cmake: Find and include uloop.hFlorian Fainelli2017-06-201-0/+2
| | | | | | | | Add a CMake FIND_PATH and INCLUDE_DIRECTORIES searching for libubox/uloop.h. Some external toolchains which do not include standard locations would fail to find the header otherwise. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
* hotplug: fix a memory leak in handle_button_complete()Alexander Couzens2017-06-201-1/+4
| | | | | Found-by: Coverity Scan #1412460 Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
* service/service_stopped(): fix a use-after-freeAlexander Couzens2017-06-201-1/+1
| | | | | Found-by: Coverity Scan #1412548 Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
* upgraded: define __GNU_SOURCEMatthias Schiffer2017-06-201-0/+2
| | | | | | It is required on non-musl libcs for O_DIRECTORY. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* rcS: add missing fcntl.h includeMatthias Schiffer2017-06-201-0/+1
| | | | | | Fixes: d42b21ed9305 "procd/rcS: Use /dev/null as stdin" Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* procd/rcS: Use /dev/null as stdinMichal Sojka2017-06-201-0/+6
| | | | | | | | | | | | This change ensures that /etc/init.d/* scripts are started with /dev/null as stdin. This is useful in cases where an init.d script reads (e.g. by mistake) from stdin, which a user can perceive as if some characters typed into shell on serial console are "eaten" by something else (i.e. by the init.d script running on background). This is very annoying, because each character needs to be pressed several times before it appears on the screen. Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
* procd: Log initscript output prefixed with script nameMichal Sojka2017-06-201-2/+3
| | | | | | It helps with debugging of initscript problems. Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
* procd: Don't use syslog before its initializationMichal Sojka2017-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | When procd starts a rcS script, it captures its stdout and stderr and logs them via syslog(). The problem with that is that the rest of procd code uses ulog rather than syslog() directly and ulog_open() doesn't call openlog() immediately, but only after something is logged with ulog(). This lazy calling of openlog() can result in the following unwanted behavior: 1) When rcS's stdout/err is logged via syslog(), the log identifier is not set yet (due to openlog() not called) and so the log message lacks information about source. 2) procd can also log stdout/err from services. When a message from a service needs to be logged, ulog_open() is called to change the log identifier to match the service name/PID. After logging the service messages, ulog_open() is called again the change the identifier back to "procd". The lazy call to openlog() means that the messages logged directly with syslog() will be logged with the identification of the previously logged service and not of the rcS script that produced the message. Both problems are fixed by replacing direct call to syslog() with ULOG_NOTE, which automatically calls openlog() if needed. Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
* procd: Add missing \n in debug messageMichal Sojka2017-06-201-1/+1
| | | | Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
* procd: service gets deleted when its last instance is freedAlin Năstac2017-06-202-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the following regression introduced in commit 961dc692aff7457f874bce61f8e766514edcf794: 1) reboot using the following configuration root@OpenWrt:~# uci show system.ntp system.ntp=timeserver system.ntp.enable_server='0' system.ntp.use_dhcp='1' system.ntp.dhcp_interface='wan' root@OpenWrt:~# uci show network.wan network.wan=interface network.wan.proto='dhcp' network.wan.ifname='eth4' network.wan.reqopts='1 3 6 15 33 42 51 121 249' 2) if obtained DHCP lease has an option 42 sysntpd service will have an instance 3) run "ifup wan" 4) although the same DHCP lease was obtained, sysntpd would be stopped Because sysntpd service is deleted when last instance is freed, its triggers will also be released. Without these triggers in place, sysntpd will not be reloaded when a new DHCP lease containing option 42 will be received. Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
* procd: add cancel_timeout on rc scripts when a runtime_timeout is specifiedJurgen Van Ham2017-02-151-1/+3
| | | | | | | Enable procd to restrict the execution time of a rc scripts during shutdown, even when a script ignores the SIGTERM signal by insisting after 10s with a SIGKILL. Signed-off-by: Jurgen Van Ham <juvanham.tc@gmail.com>
* procd: stop service using SIGKILL if SIGTERM failed to do soAlin Năstac2017-02-154-17/+57
| | | | | | | | | | SIGKILL is sent if instance process is still running after <term_timeout> seconds after SIGTERM has been sent. To prevent another daemon process being launched before old process dies, the instance is kept until SIGCHLD confirms that service has been stopped. Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
* add missing includesFelix Fietkau2017-02-113-0/+3
| | | | | | Including sys/sysmacros.h is now necessary for makedev() on glibc 2.25. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* ujail: fix signal forwardingJohn Crispin2017-02-081-1/+23
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* init: fix /tmp permissions on zramMatthias Schiffer2017-01-261-0/+6
| | | | | | | mkfs.ext4 will create the filesystem with 755, we need to chmod to 1777 explicitly. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* ujail: add basic /dev filesEtienne CHAMPETIER2017-01-101-0/+5
| | | | | | | | | | | This adds /dev/full /dev/null /dev/urandom /dev/zero in every jail (not having them only allow subtle bugs) Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>
* service: add reload_signal propertyJo-Philipp Wich2016-12-132-0/+15
| | | | | | | | | | | Introduce a new optional property "reload_signal" which - if set - instructs procd to not terminate and restart supervised processes upon changes, but to send them a kill() signal instead. This is useful for services which fully support native config reload upon receipt of a signal. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* hotplug: fix uninitialized variableJo-Philipp Wich2016-12-131-1/+1
| | | | | | | | | | | | | | | 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>
* service: add service.signal ubus callJo-Philipp Wich2016-12-131-0/+71
| | | | | | | | | | | | | Add a service.signal call to allow sending kill() signals to a service. The default signal sent to services is SIGHUP and may be overridden by a numerical signal value using the signal parameter. The optional instance argument allows restricting the signal delivery to one specific instance. If omitted, the signal is sent to all instances. Acked-by: John Crispin <john@phrozen.org> Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* trace: use the cloned environment pointerFelix Fietkau2016-12-051-2/+2
| | | | | | | Fixes an issue where it would overwrite the first environment variable with the preload one Signed-off-by: Felix Fietkau <nbd@nbd.name>
* procd: Fix memory leaks found by cppcheckRosen Penev2016-12-053-1/+6
| | | | Signed-off by: Rosen Penev <rosenp@gmail.com>
* hotplug: Check chown return valueFlorian Fainelli2016-12-041-2/+4
| | | | | | | | | 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>
* ujail: send SIGKILL to jail process if SIGTERM failsFelix Fietkau2016-12-021-2/+15
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* service: do not restart instances if data changesFelix Fietkau2016-10-191-3/+0
| | | | | | | | | | | Drop in->data from instance_config_changed() checks. So far, procd_open_data is always used in places for passing data to other services, not for triggering restarts on specific changes. With this change it is possible to use this behavior more explicitly while avoiding unnecessary restarts Signed-off-by: Felix Fietkau <nbd@nbd.name>
* service: make instance_update() void and unconditionally replace config on ↵Felix Fietkau2016-10-192-9/+5
| | | | | | update Signed-off-by: Felix Fietkau <nbd@nbd.name>
* service: add support for instances without commandFelix Fietkau2016-10-191-13/+25
| | | | | | | This can be useful for maintaining active procd data for use in other services, even when no helper process is active. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* procd: fix build when DEBUG is setZefir Kurtisi2016-10-152-2/+2
| | | | | | | | | | | | | | | | | | There is a collision between the DEBUG set in the CMake file as flag and the macro defined in log.h, resulting in build error: In file included from ./procd/initd/init.h:19:0, from ./procd/initd/init.c:33: ./procd/initd/../log.h:20:0: error: "DEBUG" redefined [-Werror] #define DEBUG(level, fmt, ...) do { \ ^ <command-line>:0:0: note: this is the location of the previous definition cc1: all warnings being treated as errors This patch fixes the issue by renaming the build flag to UDEV_DEBUG (since it is only used in udevtrigger). Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
* procd: fire events at instance respawn and failureZefir Kurtisi2016-10-151-0/+2
| | | | | | | | | In addition to the existing 'start' and 'stop', this commit adds 'respawn' and 'fail' events to allow system monitors to detect and handle unstable processes. Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
* add late variant of respawn and askconsoleJohn Crispin2016-09-282-0/+10
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* fixes a copy paste error in the service ubus bindingJohn Crispin2016-09-271-1/+1
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* procd: uClibc O_PATH backwards compatibility fixesHans Dedecker2016-08-122-0/+8
| | | | Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* trigger: rework timeout handling and command queueingFelix Fietkau2016-07-291-121/+84
| | | | | | | | | | | | | | | | Instead of queueing the full json_script, only queue actual script calls issued by it. This fixes a long standing issue where trigger events were dropped, triggered by the following scenario: - Set up a trigger with timeout and condition check in the script. - Fire an event that matches the condition. - Fire another event that does not match the condition. This series of events will fire the delay timer of the trigger, but the second event will replace the trigger event data. When the timer expires, the json_script is run, but no script call is issued Signed-off-by: Felix Fietkau <nbd@nbd.name>
* trigger: replace trigger_init() with static runqueue initializationFelix Fietkau2016-07-293-9/+1
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* trigger: remove unnecessary runqueue empty callbackFelix Fietkau2016-07-291-5/+0
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* trigger: reduce indentation level in trigger_event()Felix Fietkau2016-07-291-8/+8
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* procd: remove instance_removepid call from instance_stopJurgen Van Ham2016-07-191-1/+0
| | | | | | It is already called from instance_exit when the instance is stopped Signed-off-by: Jurgen Van Ham <juvanham.tc@gmail.com>
* system: add reboot method to system ubus objectRafał Miłecki2016-07-061-0/+10
| | | | | | | | | | | | | | | | | | | Sometimes, for various reasons, user may want to reboot a device. This is a common task and it makes sense to support it with something common like a procd. Right now both: LuCI and LuCI2 implement this feature on their own with luci-rpc-luci2-system reboot and luci-rpc-sys reboot. This leads to code duplication and situation may become even worse with more software controlling system with ubus. Othen than that procd already has support for rebooting so one may consider this ubus method even cleaner. Once we get this patch in place we may consider switching LuCI and LuCI2 to this new method. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
* system: fix localtime value in ubus info method outputRafał Miłecki2016-07-051-1/+1
| | | | | | | | | | | | | | | | | | Function mktime respects current time zone and calling it results in converting time back to the UTC. It means we were never returning a time for local zone but GMT one. The easiest solution is to use tm_gmtoff from struct tm. Unfortunately this isn't part of POSIX but it seems to be the best idea anyway. Alternative (worse?) solutions: 1) Use timegm that is nonstandard GNU extension 2) Work with TZ env (getenv & (un)setenv) that is not thread-safe 3) Use timegm (next to localtime) and implement function comparing two struct tm. This is what glibc does internally (tm_diff) when compiled without HAVE_TM_GMTOFF. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
* procd: remove pidfile after unexpected termination without respawnJurgen Van Ham2016-07-051-1/+1
| | | | | | | When procd detects a daemon halts and it is not configured to be respawned, the pidfile has to be removed. Signed-off-by: Jurgen Van Ham <juvanham.tc@gmail.com>