summaryrefslogtreecommitdiff
path: root/src/core
AgeCommit message (Collapse)Author
2017-04-29Merge pull request #5809 from keszybz/glob-safeMartin Pitt
Implement `safe_glob` that ignores "." and ".."
2017-04-29Merge pull request #5164 from Werkov/ordering-for-_netdev-devicesLennart Poettering
Ordering for _netdev devices
2017-04-28tree-wide: remove unused variablesThomas Hindoe Paaboel Andersen
2017-04-27execute: filter out "." for ".." in EnvironmentFile= globs tooZbigniew Jędrzejewski-Szmek
This doesn't really matter much, only in case somebody would use something strange like EnvironmentFile=/etc/something/.* Make sure that "." and ".." is not returned by that glob. This makes all our globbing patterns behave the same.
2017-04-26main: improve RLIMIT_NOFILE handling (#5795)Christian Brauner
This has systemd look at /proc/sys/fs/nr_open to find the current maximum of open files compiled into the kernel and tries to set the RLIMIT_NOFILE max to it. This has the advantage the value chosen as limit is less arbitrary and also improves the behavior of systemd in containers that have an rlimit set: When systemd currently starts in a container that has RLIMIT_NOFILE set to e.g. 100000 systemd will lower it to 65536. With this patch systemd will try to set the nofile limit to the allowed kernel maximum. If this fails, it will compute the minimum of the current set value (the limit that is set on the container) and the maximum value as soft limit and the currently set maximum value as the maximum value. This way it retains the limit set on the container.
2017-04-25core/device: Use JobRunningTimeoutSec= for device unitsMichal Koutný
Device job timeouts should respect possible device job dependencies so we set JobRunningTimeoutSec= by default.
2017-04-25job: add JobRunningTimeoutSec for JOB_RUNNING stateMichal Koutný
Unit.JobTimeoutSec starts when a job is enqueued in a transaction. The introduced distinct Unit.JobRunningTimeoutSec starts only when the job starts running (e.g. it groups all Exec* commands of a service or spans waiting for a device period.) Unit.JobRunningTimeoutSec is intended to be used by default instead of Unit.JobTimeoutSec for device units where such behavior causes less confusion (consider a job for a _netdev mount device, with this change the timeout will start ticking only after the network is ready).
2017-04-25Merge pull request #5704 from keszybz/mesonEvgeny Vereshchagin
meson: build systemd using meson
2017-04-25meson: also indent scripts with 8 spacesZbigniew Jędrzejewski-Szmek
2017-04-25load-fragment: don't print error about incorrect syntax when IPv6 is ↵Michal Sekletar
disabled (#5791)
2017-04-24Merge pull request #5354 from msekletar/issue-518Lennart Poettering
service: serialize information about currently executing command
2017-04-24load-fragment: resolve specifiers in BindPaths/BindReadOnlyPaths (#5687)Danielle Church
2017-04-23meson: reindent all files with 8 spacesZbigniew Jędrzejewski-Szmek
The indentation for emacs'es meson-mode is added .dir-locals. All files are reindented automatically, using the lasest meson-mode from git. Indentation should now be fairly consistent.
2017-04-23meson: use join_paths consistentlyMichael Biebl
With -Dsplit-usr=true, we set rootprefix to /. This leads to //lib/systemd or //lib/udev for various dir variables. Using join_paths() avoids this.
2017-04-23meson: properly conditionalize polkit installationZbigniew Jędrzejewski-Szmek
... including pkla installation on Debian. v2: - fix polkit-gobject-1 pkgconfig name
2017-04-23meson: create dirs and touch /usrZbigniew Jędrzejewski-Szmek
This is the equivalent of $(INSTALL_DIRS) and install-touch-usr-hook. I did not bother to create the directories into which we install files, since they will be created anyway. v2: - remove bashism
2017-04-23meson: create a static version of libshared and link libcore and some tests ↵Zbigniew Jędrzejewski-Szmek
to it This is what autoconf-based build does, and it makes test-bus-error and test-engine able to access the bus error mapping table. OTOH, this is a heavy price to pay: it would be excellent to link libcore.a to libsystemd-shared-NNN.so. Otherwise we duplicate the same code in 'systemd' and 'libsystemd-shared-NNN.so'. -rwxrwxr-x. 1 4075544 Apr 6 20:30 systemd* <-- libcore linked against libsystemd-shared.so -rwxrwxr-x. 1 5596504 Apr 9 14:07 systemd* <-- libcore linked against libsystemd-shared.a v2: - update for 6b5cf3ea621a5bfd218cd2249e066a52c0e73657
2017-04-23meson: build systemd using mesonZbigniew Jędrzejewski-Szmek
It's crucial that we can build systemd using VS2010! ... er, wait, no, that's not the official reason. We need to shed old systems by requring python 3! Oh, no, it's something else. Maybe we need to throw out 345 years of knowlege accumulated in autotools? Whatever, this new thing is cool and shiny, let's use it. This is not complete, I'm throwing it out here for your amusement and critique. - rules for sd-boot are missing. Those might be quite complicated. - rules for tests are missing too. Those are probably quite simple and repetitive, but there's lots of them. - it's likely that I didn't get all the conditions right, I only tested "full" compilation where most deps are provided and nothing is disabled. - busname.target and all .busname units are skipped on purpose. Otherwise, installation into $DESTDIR has the same list of files and the autoconf install, except for .la files. It'd be great if people had a careful look at all the library linking options. I added stuff until things compiled, and in the end there's much less linking then in the old system. But it seems that there's still a lot of unnecessary deps. meson has a `shared_module` statement, which sounds like something appropriate for our nss and pam modules. Unfortunately, I couldn't get it to work. For the nss modules, we need an .so version of '2', but `shared_module` disallows the version argument. For the pam module, it also didn't work, I forgot the reason. The handling of .m4 and .in and .m4.in files is rather awkward. It's likely that this could be simplified. If make support is ever dropped, I think it'd make sense to switch to a different templating system so that two different languages and not required, which would make everything simpler yet. v2: - use get_pkgconfig_variable - use sh not bash - use add_project_arguments v3: - drop required:true and fix progs/prog typo v4: - use find_library('bz2') - add TTY_GID definition - define __SANE_USERSPACE_TYPES__ - use join_paths(prefix, ...) is used on all paths to make them all absolute v5: - replace all declare_dependency's with [] - add more conf.get guards around optional components v6: - drop -pipe, -Wall which are the default in meson - use compiler.has_function() and compiler.has_header_symbol instead of the hand-rolled checks. - fix duplication in 'liblibsystemd' library name - use the right .sym file for pam_systemd - rename 'compiler' to 'cc': shorter, and more idiomatic. v7: - use ENABLE_ENVIRONMENT_D not HAVE_ENVIRONMENT_D - rename prefix to prefixdir, rootprefix to rootprefixdir ("prefix" is too common of a name and too easy to overwrite by mistake) - wrap more stuff with conf.get('ENABLE...') == 1 - use rootprefix=='/' and rootbindir as install_dir, to fix paths under split-usr==true. v8: - use .split() also for src/coredump. Now everything is consistent ;) - add rootlibdir option and use it on the libraries that require it v9: - indentation v10: - fix check for qrencode and libaudit v11: - unify handling of executable paths, provide options for all progs This makes the meson build behave slightly differently than the autoconf-based one, because we always first try to find the executable in the filesystem, and fall back to the default. I think different handling of loadkeys, setfont, and telinit was just a historical accident. In addition to checking in $PATH, also check /usr/sbin/, /sbin for programs. In Fedora $PATH includes /usr/sbin, (and /sbin is is a symlink to /usr/sbin), but in Debian, those directories are not included in the path. C.f. https://github.com/mesonbuild/meson/issues/1576. - call all the options 'xxx-path' for clarity. - sort man/rules/meson.build properly so it's stable
2017-04-23Merge pull request #5774 from keszybz/printf-annotationsDjalal Harouni
Printf annotation improvements
2017-04-21tree-wide: mark log_struct with _printf_ and fix falloutZbigniew Jędrzejewski-Szmek
log_struct takes multiple format strings, each one followed by arguments. The _printf_ annotation is not sufficiently flexible to express this, but we can still annotate the first format string, though not its arguments (because their number is unknown). With the annotation, the places which specified the message id or similar as the first pattern cause a warning from -Wformat-nonliteral. This can be trivially fixed by putting the MESSAGE= first. This change will help find issues where a non-literal is erroneously used as the pattern.
2017-04-21core: move checking default_dependencies into ↵iplayinsun
target_add_default_dependencies. (#5762) Almost units check default_dependencies within [unit]_add_default_dependencies except target unit.
2017-04-21ima: Ensure policy exists before asking the kernel to load it (#5777)Benjamin Gilbert
e8e42b31c5a950a7b43d64f4a531ec59750e823e added support for having the kernel load the IMA policy directly, but didn't check that the policy file exists. If not, this produced a kernel message: IMA: policy update failed
2017-04-20basic/log: fix _printf_ annotation on log_object_internalvZbigniew Jędrzejewski-Szmek
Fixup for 4b58153dd22172d817055d2a09a0cdf3f4bd9db3. I saw this because of a clang warning. With gcc the -Wformat-nonliteral warning doesn't seem to work as expected. In two places, a string constructed with strjoina is used as the pattern. This is safe, because we're taking a pattern which was already marked with _printf_ and prepending a known value to it. Those places are marked with #pragma to silence the warning.
2017-04-12Merge pull request #5690 from yuwata/fix-5621Djalal Harouni
core: downgrade error message if command is prefixed with `-` and the…
2017-04-11service: serialize information about currently executing commandMichal Sekletar
Stored information will help us to resume execution after the daemon-reload. This commit implements following scheme, * On serialization: - we count rank of the currently executing command - we store command type, its rank and command line arguments * On deserialization: - configuration is parsed and loaded - we deserialize stored data, command type, rank and arguments - we look at the given rank in the list and if command there has same arguments then we restore execution at that point - otherwise we search respective command list and we look for command that has the same arguments - if both methods fail we do not do not resume execution at all To better illustrate how does above scheme works, please consider following cases (<<< denotes position where we resume execution after reload) ; Original unit file [Service] ExecStart=/bin/true <<< ExecStart=/bin/false ; Swapped commands ; Second command is not going to be executed [Service] ExecStart=/bin/false ExecStart=/bin/true <<< ; Commands added before ; Same commands are problematic and execution could be restarted at wrong place [Service] ExecStart=/bin/foo ExecStart=/bin/bar ExecStart=/bin/true <<< ExecStart=/bin/false ; Commands added after ; Same commands are not an issue in this case [Service] ExecStart=/bin/true <<< ExecStart=/bin/false ExecStart=/bin/foo ExecStart=/bin/bar ; New commands interleaved with old commands ; Some new commands will be executed while others won't ExecStart=/bin/foo ExecStart=/bin/true <<< ExecStart=/bin/bar ExecStart=/bin/false As you can see, above scheme has some drawbacks. However, in most cases (we assume that in most common case unit file command list is not changed while some other command is running for the same unit) it should cause that systemd does the right thing, which is restoring execution exactly at the point we were before daemon-reload. Fixes #518
2017-04-10core: fix values of BindPaths and BindReadOnlyPaths properties on 32-bit ↵Evgeny Vereshchagin
platforms (#5713) $ busctl get-property \ org.freedesktop.systemd1 \ /org/freedesktop/systemd1/unit/run_2dr471de87550554a6dbb165501c33c5dab_2eservice \ org.freedesktop.systemd1.Service BindReadOnlyPaths a(ssbt) 1 "/etc" "/etc" false 9228635523571007488 The correct values are 0 and 16384
2017-04-10core: downgrade legit error logs (#5705)umuttl
manager_sync_bus_names() function retrieves the dbus names and compares it with unit bus names. It could be right after the list is retrieved, the dbus peer is disconnected. In this case it is really not an ERROR print if sd_bus_get_name_creds() or sd_bus_creds_get_unique_name() fail.
2017-04-03core: downgrade error message if command is prefixed with `-` and the ↵Yu Watanabe
command is not found Fixes #5621
2017-03-14Never call unmap with MAP_FAILED. (#5590)Tobias Stoeckmann
When mmap is called, the code in correctly checks for p == MAP_FAILED. But the resource cleanup at the end of busname_peek_message checks for p == NULL, and if that's not true, munmap is called. Therefore in error case, munmap is called with a MAP_FAILED argument which can result in unexpected behaviour depending on sz's value. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2017-03-02Avoid strict DM interface version dependencies (#5519)Michael Biebl
Compiling against the dm-ioctl.h header as provided by the Linux kernel will embed the DM interface version number. Running an older kernel can result in an error like this on shutdown: Could not detach DM dm-11: ioctl mismatch, kernel(4.34.4), user(4.35.4) Work around this by shipping a local copy of dm-ioctl.h. We need at least the version from 3.13 for DM_DEFERRED_REMOVE [1], so bump the requirements in README accordingly. [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2c140a246dc0bc085b98eddde978060fcec1080c Fixes: #5492
2017-03-01core: when a unit's SourcePath points to API VFS pretend we are never ↵Lennart Poettering
out-of-date (#5487) If the unit's SourcePath is below /proc then it's a unit genreated from a kernel resource (such as a .mount or .swap unit). And those we watch anyway, and hence should never be out-of-date. Fixes: #5461
2017-02-28Merge pull request #5494 from poettering/run-fixesZbigniew Jędrzejewski-Szmek
systemd-run --user fixes.
2017-02-28automount: if an automount unit is masked, don't react to activation anymore ↵Lennart Poettering
(#5445) Otherwise we'll hit an assert sooner or later. This requires us to initialize ->where even if we come back in "masked" mode, as otherwise we don't know how to operate on the automount and detach it. Fixes: #5441
2017-02-28core: always consider clients that pinned a unit to be subscribersLennart Poettering
If a client pins a unit, then it makes sense to also implicitly make it a subscriber. This is useful for clients that just want to watch one specific unit: they can pin it and receive its messages.
2017-02-28service: refuse using PID 1 as MAINPID for a serviceLennart Poettering
2017-02-28service: make use of log_unit_warning_errno()'s return valueLennart Poettering
2017-02-28core: use PID_FMT where appropriateLennart Poettering
2017-02-24Merge pull request #5444 from poettering/cgroups-revert-no-errorZbigniew Jędrzejewski-Szmek
Revert "core: simplify cg_[all_]unified()" and more.
2017-02-24Fix missing space in comments (#5439)AsciiWolf
2017-02-24cgroup: rename cg_unified() → cg_unified_controller()Lennart Poettering
cg_unified() is a bit generic a name, let's make clear that it checks whether a specified controller is in unified mode.
2017-02-24cgroup: change cg_unified() to possibly return errors againLennart Poettering
We use our cgroup APIs in various contexts, including from our libraries sd-login, sd-bus. As we don#t control those environments we can't rely that the unified cgroup setup logic succeeds, and hence really shouldn't assert on it. This more or less reverts 415fc41ceaeada2e32639f24f134b1c248b9e43f.
2017-02-23Merge pull request #4670 from htejun/systemd-controller-on-unified-v2Lennart Poettering
Systemd controller on unified v2
2017-02-22core/mount-setup: if unified hierarchy is not supported, fall back to legacyZbigniew Jędrzejewski-Szmek
We need this to gracefully support older or strangely configured kernels. v2: - do not install a callback handler, just embed the right conditions into cg_is_*_wanted() v3: - fix bug in cg_is_legacy_wanted()
2017-02-22Rename cg_is_unified_systemd_controller_wanted to cg_is_hybrid_wantedZbigniew Jędrzejewski-Szmek
Less typing and doesn't make the table so incredibly wide.
2017-02-21log: never log into foreign fd #2 in PID 1 or its pre-execve() childrenLennart Poettering
Fixes: #5401
2017-02-21Merge pull request #5131 from keszybz/environment-generatorsLennart Poettering
Environment generators
2017-02-20manager: run environment generatorsZbigniew Jędrzejewski-Szmek
Environment file generators are a lot like unit file generators, but not exactly: 1. environment file generators are run for each manager instance, and their output is (or at least can be) individualized. The generators themselves are system-wide, the same for all users. 2. environment file generators are run sequentially, in priority order. Thus, the lifetime of those files is tied to lifecycle of the manager instance. Because generators are run sequentially, later generators can use or modify the output of earlier generators. Each generator is run with no arguments, and the whole state is stored in the environment variables. The generator can echo a set of variable assignments to standard output: VAR_A=something VAR_B=something else This output is parsed, and the next and subsequent generators run with those updated variables in the environment. After the last generator is done, the environment that the manager itself exports is updated. Each generator must return 0, otherwise the output is ignored. The generators in */user-env-generator are for the user session managers, including root, and the ones in */system-env-generator are for pid1.
2017-02-20core/manager: move environment serialization out to basic/env-util.cZbigniew Jędrzejewski-Szmek
This protocol is generally useful, we might just as well reuse it for the env. generators. The implementation is changed a bit: instead of making a new strv and freeing the old one, just mutate the original. This is much faster with larger arrays, while in fact atomicity is preserved, since we only either insert the new entry or not, without being in inconsistent state. v2: - fix confusion with return value
2017-02-20core/manager: fix grammar in commentZbigniew Jędrzejewski-Szmek
2017-02-20basic/exec-util: add support for synchronous (ordered) executionZbigniew Jędrzejewski-Szmek
The output of processes can be gathered, and passed back to the callee. (This commit just implements the basic functionality and tests.) After the preparation in previous commits, the change in functionality is relatively simple. For coding convenience, alarm is prepared *before* any children are executed, and not before. This shouldn't matter usually, since just forking of the children should be pretty quick. One could also argue that this is more correct, because we will also catch the case when (for whatever reason), forking itself is slow. Three callback functions and three levels of serialization are used: - from individual generator processes to the generator forker - from the forker back to the main process - deserialization in the main process v2: - replace an structure with an indexed array of callbacks