summaryrefslogtreecommitdiff
path: root/src/core
AgeCommit message (Collapse)Author
2015-08-07core: s/reexection/reexecution/ typo fixJan Pokorný
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2015-08-07load-fragment: fix segv on parse errorZbigniew Jędrzejewski-Szmek
https://bugzilla.redhat.com/show_bug.cgi?id=1251334
2015-08-06Merge pull request #896 from poettering/runtimedir-execTom Gundersen
execute: don't fail if we create the runtime directory from two proce…
2015-08-06execute: don't fail if we create the runtime directory from two processes ↵Lennart Poettering
simultaneously If a service has both ExecStart= and ExecStartPost= set with Type=simple, then it might happen that we have two children create the runtime directory of a service (as configured with RuntimeDirectory=) at the same time. Previously we did this with mkdir_safe() which will create the dir only if it is missing, but if it already exists will at least verify the access mode and ownership to match the right values. This is problematic in this case, since it creates and then adjusts the settings, thus it might happen that one child creates the directory with root owner, another one then verifies it, and only afterwards the directory ownership is fixed by the original child, while the second child already failed. With this change we'll now always adjust the access mode, so that we know that it is right. In the worst case this means we adjust the mode/ownership even though its unnecessary, but this should have no negative effect. https://bugzilla.redhat.com/show_bug.cgi?id=1226509
2015-08-06core: unit: remove bus slot after calling unit_done()Daniel Mack
The ->done callback in the unit's vtable might call into unit_unwatch_bus_name() and corrupt memory by that. Move the call down, and clean up the bus slot in case it hasn't been done yet.
2015-08-06core: dbus: track bus names per unitDaniel Mack
Currently, PID1 installs an unfiltered NameOwnerChanged signal match, and dispatches the signals itself. This does not scale, as right now, PID1 wakes up every time a bus client connects. To fix this, install individual matches once they are requested by unit_watch_bus_name(), and remove the watches again through their slot in unit_unwatch_bus_name(). If the bus is not available during unit_watch_bus_name(), just store name in the 'watch_bus' hashmap, and let bus_setup_api() do the installing later.
2015-08-06tree-wide: fix indentationThomas Hindoe Paaboel Andersen
2015-08-04core: set default process label only exec label is noneWaLyong Cho
When command path has access label and no SmackProcessLabel= is not set, default process label will be set. But if the default process label has no rule for the access label of the command path then smack access error will be occurred. So, if the command path has execute label then the child have to set its label to the same of execute label of command path instead of default process label.
2015-08-04smack-util: revise smack-util apis and add read smack attr apisWaLyong Cho
- Add smack xattr lookup table - Unify all of mac_smack_apply_xxx{_fd}() to mac_smack_apply() and mac_smack_apply_fd(). - Add smack xattr read apis similar with apply apis as mac_smack_read{_fd}().
2015-07-31tree-wide: introduce mfree()David Herrmann
Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar);
2015-07-29tree-wide: port everything over to fflush_and_check()Lennart Poettering
Some places invoked fflush() directly with their own manual error checking, let's unify all that by using fflush_and_check(). This also unifies the general error paths of fflush()+rename() file writers.
2015-07-28mount: remove obsolete -nKarel Zak
It seems that systemd still uses legacy -n option. The option has been originally designed to avoid write to /etc/mtab during boot when root FS is not ready or read-only. This is not necessary for long time, because /etc/mtab is not a real file (it's symlink) and write to the file is impossible. All utils should be able to detect the symlink and ignore mtab. This concept is supported for very long time before systemd. The userspase mount options are currently maintained by libmount (mount(8) and mount.nfs) in /run/mount) which is tmpfs initialized during early boot.
2015-07-28Merge pull request #362 from d-hatayama/fix_selinux_unit_check_v2Lennart Poettering
selinux: fix missing SELinux unit access check
2015-07-24automount: handle state changes of the corresponding mount unit correctlyMichael Olbrich
The expire timeout must be started/stopped if the corresponding mount unit changes its state, e.g. it is started via local-fs.target or stopped by a manual umount.
2015-07-24automount: don't try to umount if it already happenedMichael Olbrich
Return the token immediately instead. Otherwise the token is never returned to the kernel, because the umount job is a noop and will not trigger a state change.
2015-07-24automount: do not start expiration timer for TimeoutIdleSec=0Daniel Mack
The timer value for automount unit specified with TimeoutIdleSec= is rounded up to one second if that directive is set to 0. Fix this by bailing early in automount_enter_runnning() in case no timeout is requested.
2015-07-24Merge pull request #696 from poettering/automount-expiry-freqDaniel Mack
automount: lower the idle polling frequency a bit
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-24automount: lower the idle polling frequency a bitLennart Poettering
The autofs kernel idle logic requires us to poll the kernel for idleness. This is of course suboptimal, but cannot be fixed without kernel change. Currently the polling frequency is set to 1/10 of the idle timeout. This is quite high, as seen in #571. Let's lower this to 1/3.
2015-07-21core: adjust job completion message log levelsMichal Schmidt
We do not print all non-OK job completion status messages to the console in red, because not all of them are plain errors. We do however log the same messages as LOG_ERR. Differentiate the log levels by deducing them from the job result in a way that more or less matches the color of the console message.
2015-07-21core: small refactor of job completion loggingMichal Schmidt
Joins three log_struct() calls into one.
2015-07-21core: log completion of remaining job typesMichal Schmidt
JOB_RESTART and failed JOB_VERIFY_ACTIVE completions were printed to console but not to the log.
2015-07-21core: do not log done failed-condition jobs as if unit startedMichal Schmidt
It is misleading to see "Started foo." in the log when the unit's condition was false.
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: try harder to get job completion messages tooMichal Schmidt
This is similar to "core: always try harder to get unit status message format string", but for job completion status messages. It makes generic status messages applicable for printing to the console. And it rewrites the functions in a more table-based style.
2015-07-21core: unit_get_status_message_format() never returns NULLMichal Schmidt
unit_get_status_message_format() is used only with one of JOB_START, JOB_STOP, JOB_RELOAD, all of which have fallback message strings defined, so the function may never return NULL.
2015-07-21core: always try harder to get unit status message format stringMichal Schmidt
The starting/stopping messages are printed to the console only if the corresponding format string is defined in the unit's vtable. To avoid excessive messages on the console, the unit types whose start/stop jobs are instantaneous had the format strings intentionally undefined. When logging the same event to the journal, a fallback to generic Starting/Stopping/Reloading messages is used. The problem of excessive console messages with instantaneous jobs is already resolved in a nicer way ("core: fix confusing logging of instantaneous jobs"), so there's no longer a need to have two ways of getting the format strings. Let's fold them into one function with the fallback to generic message strings.
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-21core: fix confusing logging of instantaneous jobsMichal Schmidt
For instantaneous jobs (e.g. starting of targets, sockets, slices, or Type=simple services) the log shows the job completion before starting: systemd[1]: Created slice -.slice. systemd[1]: Starting -.slice. systemd[1]: Created slice System Slice. systemd[1]: Starting System Slice. systemd[1]: Listening on Journal Audit Socket. systemd[1]: Starting Journal Audit Socket. systemd[1]: Reached target Timers. systemd[1]: Starting Timers. ... The reason is that the job completes before the ->start() method returns and only then does unit_start() print the "Starting ..." message. The same thing happens when stopping units. Rather than fixing the order of the messages, let's just not emit the Starting/Stopping message at all when the job completes instantaneously. The job completion message is sufficient in this case.
2015-07-10Merge pull request #548 from vcaputo/fix_path_state_debug_msgDaniel Mack
core: include unit in path state transition debug logging.
2015-07-10core: include unit in path state transition debug logging.Vito Caputo
2015-07-09Reload manager defaults at daemon-reloadThomas Blume
"systemctl daemon-reload" should also update the manager defaults from /etc/systemd/system.conf. For details, see: http://lists.freedesktop.org/archives/systemd-devel/2015-June/033062.html Amended to use manager_set_defaults() as common function.
2015-07-08Merge pull request #500 from zonque/fileioLennart Poettering
fileio: consolidate write_string_file*()
2015-07-06treewide: fix typos of let'sZbigniew Jędrzejewski-Szmek
2015-07-06tree-wide: fix write_string_file() user that should not create filesDaniel Mack
The latest consolidation cleanup of write_string_file() revealed some users of that helper which should have used write_string_file_no_create() in the past but didn't. Basically, all existing users that write to files in /sys and /proc should not expect to write to a file which is not yet existant.
2015-07-06fileio: consolidate write_string_file*()Daniel Mack
Merge write_string_file(), write_string_file_no_create() and write_string_file_atomic() into write_string_file() and provide a flags mask that allows combinations of atomic writing, newline appending and automatic file creation. Change all users accordingly.
2015-07-05core: fix missing bus-util.h includeDavid Herrmann
Whoopsy, forgot to 'git add' this, sorry.
2015-07-05core: don't mount kdbusfs if not wantedDavid Herrmann
Just like we conditionalize loading kdbus.ko, we should conditionalize mounting kdbusfs. Otherwise, we might run with kdbus if it is builtin, even though the user didn't want this.
2015-07-04core: fix coding style in agent-handlingDavid Herrmann
Avoid late bail-out based on a condition. This makes code hard to read. Instead, reverse the forwarding-condition.
2015-07-04core: harden cgroups-agent forwardingDavid Herrmann
On dbus1, we receive systemd1.Agent signals via the private socket, hence it's trusted. However, on kdbus we receive it on the system bus. We must make sure it's sent by UID=0, otherwise unprivileged users can fake it. Furthermore, never forward broadcasts we sent ourself. This might happen on kdbus, as we forward the message on the same bus we received it on, thus ending up in an endless loop.
2015-07-01Merge pull request #459 from ctrochalakis/reuse-port-before-bindDaniel Mack
socket: Set SO_REUSEPORT before bind()
2015-07-01socket: Set SO_REUSEPORT before bind()Christos Trochalakis
bind() fails if it is called before setting SO_REUSEPORT and another process is already binded to the same addess. A new reuse_port option has been introduced to socket_address_listen() to set the option as part of socket initialization.
2015-07-01Revert "kmod-setup: don't print warning on -ENOSYS"David Herrmann
This partially reverts commit 78d298bbc57e412574ea35e6e66f562d97fd9ebc. The changed coding-style is kept, but the ENOENT->ENOSYS conversion is reverted. kmod was fixed upstream to no longer return ENOSYS. Also see: https://git.kernel.org/cgit/utils/kernel/kmod/kmod.git/commit/?id=114ec87c85c35a2bd3682f9f891e494127be6fb5 The kmod fix is marked for backport, so no reason to bump the kmod version we depend on.
2015-06-30core: handle --log-target=null when calling systemd-shutdownIago López Galeiras
When shutting down, if systemd was started with --log-target=null, systemd-shutdown was being called with --log-target=console.
2015-06-25selinux: fix missing SELinux unit access checkHATAYAMA Daisuke
Currently, SELinux unit access check is not performed if a given unit file has not been registered in a hash table. This is because function manager_get_unit() only tries to pick up a Unit object from a Unit hash table. Instead, we use function manager_load_unit() searching Unit file pathes for the given Unit file.
2015-06-23core: fix reversed dependency check in unit_check_unneededAbdo Roig-Maranges
This was introduced by commit be7d9ff730cb88d7c6a8 and breaks StopWhenUnneeded=true in the presence of a Requisite dependency.
2015-06-22smack: add default smack process label configWaLyong Cho
Similar to SmackProcessLabel=, if this configuration is set, systemd executes processes with given SMACK label. If unit has SmackProcessLabel=, this config is overwritten. But, do NOT be confused with SMACK64EXEC of execute file. This default execute process label(and also label which is set by SmackProcessLabel=) is set fork-ed process SMACK subject label and used to access the execute file. If the execution file has also SMACK64EXEC, finally executed process has SMACK64EXEC subject. While if the execution file has no SMACK64EXEC, the executed process has label of this config(or label which is set by SmackProcessLabel=). Because if execution file has no SMACK64EXEC then excuted process inherits label from caller process(in this case, the caller is systemd).
2015-06-22smack: support smack access change-ruleWaLyong Cho
Smack is also able to have modification rules of existing rules. In this case, the rule has additional argument to modify previous rule. /sys/fs/smackfs/load2 node can only take three arguments: subject object access. So if modification rules are written to /sys/fs/smackfs/load2, EINVAL error is happen. Those modification rules have to be written to /sys/fs/smackfs/change-rule. To distinguish access with operation of cipso2, split write_rules() for each operation. And, in write access rules, parse the rule and if the rule has four argument then write into /sys/fs/smackfs/change-rule. https://lwn.net/Articles/532340/ fwrite() or fputs() are fancy functions to write byte stream such like regular file. But special files on linux such like proc, sysfs are not stream of bytes. Those special files on linux have to be written with specific size. By this reason, in some of many case, fputs() was failed to write buffer to smack load2 node. The write operation for the smack nodes should be performed with write().
2015-06-17load-fragment: reset the list on an ExecStart= containing only whitespaceFilipe Brandenburger
This is consistent with how an empty string works in an ExecStart= statement. We should not differentiate between an empty string and whitespace only (since they look the same.) Update the test case with whitespace only to reflect that the list is reset. Tested that `test-unit-file` passes and other test cases are not affected. Installed the patched systemd binaries on a machine, booted it, looked for out of the usual behavior but did not find any.
2015-06-17load-fragment: use unquote_first_word in config_parse_execFilipe Brandenburger
Convert config_parse_exec() from using FOREACH_WORD_QUOTED into a loop of unquote_first_word. Loop through the arguments only once (the FOREACH_WORD_QUOTED implementation did it twice, once to count them and another time to process and store them.) Use newly introduced flag UNQUOTE_UNESCAPE_RELAX to preserve unrecognized escape sequences such as regexps matches such as "\w", "\d", etc. (Valid escape sequences such as "\s" or "\b" still need an extra backslash if literals are desired for regexps.) Differences in behavior: - Handle ; (command separator) in special, so that only ; on its own is valid for that purpose, an quoted semicolon ";" or ';' will now behave as a literal semicolon. This is probably what was initially intended. - Handle \; (to introduce a literal semicolon) in special, so that only \; is turned into a semicolon but not \\; or "\\;" or "\;" which are kept as a literal \; in the output. This is probably what was initially intended. Known issues: - Using an empty string (for example, ExecStartPre=<empty>) will empty the list and remove the existing commands, but using whitespace only (for example, ExecStartPre=<spaces>) will not. This is a pre-existing issue and will be dealt with in a follow up commit. Tested: - Unit tests passing. Also `make distcheck` still works as expected. - Installed it on a local machine and booted with it, checked console output, systemctl and journalctl output, did not notice any issues running the patched systemd binaries. Relevant bug: https://bugs.freedesktop.org/show_bug.cgi?id=90794