summaryrefslogtreecommitdiff
path: root/src/core/service.c
AgeCommit message (Collapse)Author
2015-08-11 sd-bus: do not connect to dbus-1 socket when kdbus is availableKay Sievers
We should not fall back to dbus-1 and connect to the proxy when kdbus returns an error that indicates that kdbus is running but just does not accept new connections because of quota limits or something similar. Using is_kdbus_available() in libsystemd/ requires it to move from shared/ to libsystemd/. Based on a patch from David Herrmann: https://github.com/systemd/systemd/pull/886
2015-07-24core: print a nicer warning when two units have the same BusName= settingLennart Poettering
This should make issues like #609 easier to debug.
2015-07-21core: remove generic job completion messages from unit vtablesMichal Schmidt
These units' message format strings are identical to the generic strings. Since we can always rely on the fallback, these are now redundant.
2015-07-21core: correct return value from reload methodsMichal Schmidt
Return 1 from *_reload() methods to signify "we did something", just like in *_start(). This causes "Reloading foo..." messages to be logged. "Reloaded foo." messages are already logged.
2015-07-06treewide: fix typos of let'sZbigniew Jędrzejewski-Szmek
2015-06-17turn kdbus support into a runtime optionKay Sievers
./configure --enable/disable-kdbus can be used to set the default behavior regarding kdbus. If no kdbus kernel support is available, dbus-dameon will be used. With --enable-kdbus, the kernel command line option "kdbus=0" can be used to disable kdbus. With --disable-kdbus, the kernel command line option "kdbus=1" is required to enable kdbus support.
2015-06-11core: Let two more booleans survive a daemon-reloadWerner Fink
Without the boolean bus_name_good services as well as cgroup_realized for units a unit of Type=dbus and ExecReload sending SIGHUP to $MAINPID will be terminated if systemd will be daemon reloaded. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=746151 https://bugs.freedesktop.org/show_bug.cgi?id=78311 https://bugzilla.opensuse.org/show_bug.cgi?id=934077
2015-05-29util: split out signal-util.[ch] from util.[ch]Lennart Poettering
No functional changes.
2015-05-12core: drop redundant logging about notification messagesTom Gundersen
Before: May 12 17:11:22 tomegun-x2402 systemd[1]: systemd-udevd.service: Got notification message for unit. May 12 17:11:22 tomegun-x2402 systemd[1]: systemd-udevd.service: Got notification message from PID 195 (READY=1) May 12 17:11:22 tomegun-x2402 systemd[1]: systemd-udevd.service: Ggot READY=1 After: May 12 17:11:22 tomegun-x2402 systemd[1]: systemd-udevd.service: Got notification message from PID 195 (READY=1)
2015-05-11core: rename SystemdRunningAs to ManagerRunningAsLennart Poettering
It's primarily just a property of the Manager object after all, and we try to refer to PID 1 as "manager" instead of "systemd", hence let's to stick to this here too.
2015-05-11core,network: major per-object logging reworkLennart Poettering
This changes log_unit_info() (and friends) to take a real Unit* object insted of just a unit name as parameter. The call will now prefix all logged messages with the unit name, thus allowing the unit name to be dropped from the various passed romat strings, simplifying invocations drastically, and unifying log output across messages. Also, UNIT= vs. USER_UNIT= is now derived from the Manager object attached to the Unit object, instead of getpid(). This has the benefit of correcting the field for --test runs. Also contains a couple of other logging improvements: - Drops a couple of strerror() invocations in favour of using %m. - Not only .mount units now warn if a symlinks exist for the mount point already, .automount units do that too, now. - A few invocations of log_struct() that didn't actually pass any additional structured data have been replaced by simpler invocations of log_unit_info() and friends. - For structured data a new LOG_UNIT_MESSAGE() macro has been added, that works like LOG_MESSAGE() but prefixes the message with the unit name. Similar, there's now LOG_LINK_MESSAGE() and LOG_NETDEV_MESSAGE(). - For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(), LOG_NETDEV_INTERFACE() macros have been added that generate the necessary per object fields. The old log_unit_struct() call has been removed in favour of these new macros used in raw log_struct() invocations. In addition to removing one more function call this allows generated structured log messages that contain two object fields, as necessary for example for network interfaces that are joined into another network interface, and whose messages shall be indexed by both. - The LOG_ERRNO() macro has been removed, in favour of log_struct_errno(). The latter has the benefit of ensuring that %m in format strings is properly resolved to the specified error number. - A number of logging messages have been converted to use log_unit_info() instead of log_info() - The client code in sysv-generator no longer #includes core code from src/core/. - log_unit_full_errno() has been removed, log_unit_full() instead takes an errno now, too. - log_unit_info(), log_link_info(), log_netdev_info() and friends, now avoid double evaluation of their parameters
2015-05-11core: always initialize ExecParamters.bus_endpoint_fd to -1Lennart Poettering
Otherwise it might be passed in as 0, which is a valid fd, but usually does not refer to a real endpoint.
2015-04-29core: annotate event sourcesTom Gundersen
2015-04-28service: make restart logic a bit easier to understandLennart Poettering
2015-04-28exit-status: introduce common exit_status_set_test() call for testing exit ↵Lennart Poettering
status set membership
2015-04-24Revert "core: do not spawn jobs or touch other units during coldplugging"Lennart Poettering
This reverts commit 6e392c9c45643d106673c6643ac8bf4e65da13c1. We really shouldn't invent external state keeping hashmaps, if we can keep this state in the units themselves.
2015-04-24service: improve readability, by reducing line-breaksLennart Poettering
2015-04-21service: transition through SIGKILL states only when SIGKILL is enabledLennart Poettering
If there's no remaining process to kill, skip the SIGKILL states if SIGKILL is disabled. Effectively this doesn't change much since if there's nothing to kill with SIGTERM or SIGABRT then there's also nothing to kill with SIGKILL. However, this avoids confusion with the state engine jumping through SIGKILL states for no reason...
2015-04-21service: timeout on SIGABRT should also be considered an error to rememberLennart Poettering
2015-04-21service: make more use of IN_SET() macroLennart Poettering
2015-04-21service: list states always in the same orderLennart Poettering
2015-04-21service: make kill operation mapping explicitLennart Poettering
2015-04-10shared: add process-util.[ch]Ronny Chevalier
2015-04-10shared: add formats-util.hRonny Chevalier
2015-03-14service: don't add After= dependencies on .busname units if kdbus support is ↵Michael Biebl
disabled
2015-03-10add REMOTE_ADDR and REMOTE_PORT for Accept=yesShawn Landden
2015-03-07core: do not spawn jobs or touch other units during coldpluggingIvan Shapovalov
Because the order of coldplugging is not defined, we can reference a not-yet-coldplugged unit and read its state while it has not yet been set to a meaningful value. This way, already active units may get started again. We fix this by deferring such actions until all units have been at least somehow coldplugged. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=88401
2015-03-02core: expose consumed CPU time per unitLennart Poettering
This adds support for showing the accumulated consumed CPU time per-unit in the "systemctl status" output. The property is also readable via the bus.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2015-02-03util: rework strappenda(), and rename it strjoina()Lennart Poettering
After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
2015-01-28core: output unit status output strings to console, only if we actually are ↵Lennart Poettering
changing unit state Unit _start() and _stop() implementations can fail with -EAGAIN to delay execution temporarily. Thus, we should not output status messages before invoking these calls, but after, and only when we know that the invocation actually made a change.
2015-01-07service: automatically create After= dependency from services to their ↵Lennart Poettering
.busname units, if BusName= is set
2015-01-07core: implement serialization/deserialization of fd store elementsLennart Poettering
2015-01-06core: add new logic for services to store file descriptors in PID 1Lennart Poettering
With this change it is possible to send file descriptors to PID 1, via sd_pid_notify_with_fds() which PID 1 will store individually for each service, and pass via the usual fd passing logic on next invocation. This is useful for enable daemon reload schemes where daemons serialize their state to /run, push their fds into PID 1 and terminate, restoring their state on next start from the data in /run and passed in from PID 1. The fds are kept by PID 1 as long as no POLLHUP or POLLERR is seen on them, and the service they belong to are either not dead or failed, or have a job queued.
2014-12-09core: rename unit_destroy_cgroup() to unit_destroy_cgroup_if_empty() since ↵Lennart Poettering
it's not quite as destructive as it sounds nowadays
2014-11-30core: warn and ignore SysVStartPriority=Zbigniew Jędrzejewski-Szmek
Option was being parsed but not used for anything.
2014-11-28core: convert log_unit_*() to log_unit_*_errno()Michal Schmidt
Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_unit_(debug|info|notice|warning|error|emergency)\(([^"]+), "(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_unit_\1_errno(\2, \5, "\3%m"\4);/'
2014-11-28log: fix order of log_unit_struct() to match other logging callsLennart Poettering
Also, while we are at it, introduce some syntactic sugar for creating ERRNO= and MESSAGE= structured logging fields.
2014-11-27log: rearrange log function namingLennart Poettering
- Rename log_meta() → log_internal(), to follow naming scheme of most other log functions that are usually invoked through macros, but never directly. - Rename log_info_object() to log_object_info(), simply because the object should be before any other parameters, to follow OO-style programming style.
2014-11-05core: introduce new Delegate=yes/no property controlling creation of cgroup ↵Lennart Poettering
subhierarchies For priviliged units this resource control property ensures that the processes have all controllers systemd manages enabled. For unpriviliged services (those with User= set) this ensures that access rights to the service cgroup is granted to the user in question, to create further subgroups. Note that this only applies to the name=systemd hierarchy though, as access to other controllers is not safe for unpriviliged processes. Delegate=yes should be set for container scopes where a systemd instance inside the container shall manage the hierarchies below its own cgroup and have access to all controllers. Delegate=yes should also be set for user@.service, so that systemd --user can run, controlling its own cgroup tree. This commit changes machined, systemd-nspawn@.service and user@.service to set this boolean, in order to ensure that container management will just work, and the user systemd instance can run fine.
2014-10-28service: add missing state table entryLennart Poettering
2014-10-28core: send sigabrt on watchdog timeout to get the stacktraceUmut Tezduyar Lindskog
if sigabrt doesn't do the job, follow regular shutdown routine, sigterm > sigkill.
2014-10-22sd-bus: rename sd_bus_get_owner_uid(), sd_bus_get_owner_machine_id() and ↵Daniel Mack
sd_bus_get_peer_creds() Clean up the function namespace by renaming the following: sd_bus_get_owner_uid() → sd_bus_get_name_creds_uid() sd_bus_get_owner_machine_id() → sd_bus_get_name_machine_id() sd_bus_get_peer_creds() → sd_bus_get_owner_creds()
2014-10-12Set $NOTIFY_SOCKET for control procs if NotifyAccess=allBrandon L Black
2014-10-09service: enter SERVICE_STOP_SIGTERM state after getting "STOPPING=1"Michal Schmidt
SERVICE_STOP would mean we're running the ExecStop command. That's not the case with "STOPPING=1". Instead we should enter the same state as if we just told the service to stop, i.e. SERVICE_STOP_SIGTERM. This fixes a bug where voluntarily exiting services would hang around in deactivating state until timeout.
2014-09-19socket: introduce SELinuxContextFromNet optionMichal Sekletar
This makes possible to spawn service instances triggered by socket with MLS/MCS SELinux labels which are created based on information provided by connected peer. Implementation of label_get_child_mls_label derived from xinetd. Reviewed-by: Paul Moore <pmoore@redhat.com>
2014-09-08service: hook up custom endpoint logicDaniel Mack
If BusPolicy= was passed, the parser function will have created an ExecContext->bus_endpoint object, along with policy information. In that case, create a kdbus endpoint, and pass its path name to the namespace logic, to it will be mounted over the actual 'bus' node. At endpoint creation time, no policy is updloaded. That is done after fork(), through a separate call. This is necessary because we don't know the real uid of the process earlier than that.
2014-09-05exec: factor out most function arguments of exec_spawn() to ExecParametersDaniel Mack
This way, the list of arguments to that function gets more comprehensive, and we can get around passing lots of NULL and 0 arguments from socket.c, swap.c and mount.c. It also allows for splitting up the code in exec_spawn(). While at it, make ExecContext const in execute.c.
2014-08-22core: add support for a configurable system-wide start-up timeoutLennart Poettering
When this system-wide start-up timeout is hit we execute one of the failure actions already implemented for services that fail. This should not only be useful on embedded devices, but also on laptops which have the power-button reachable when the lid is closed. This devices, when in a backpack might get powered on by accident due to the easily reachable power button. We want to make sure that the system turns itself off if it starts up due this after a while. When the system manages to fully start-up logind will suspend the machine by default if the lid is closed. However, in some cases we don't even get as far as logind, and the boot hangs much earlier, for example because we ask for a LUKS password that nobody ever enters. Yeah, this is a real-life problem on my Yoga 13, which has one of those easily accessible power buttons, even if the device is closed.
2014-08-21service: allow services of Type=oneshot that specify no ExecStart= commandsLennart Poettering
This is useful for services that simply want to run something on shutdown, but not at bootup. They should only set ExecStop= but leave ExecStart= unset.