summaryrefslogtreecommitdiff
path: root/src/core
AgeCommit message (Collapse)Author
2015-11-30core: simplify selinux AVC initializationLennart Poettering
Let's merge access_init() and mac_selinux_access_init(), and only call mac_selinux_use() once, inside the merged function, instead of multiple times, including in the caller. See comments on: https://github.com/systemd/systemd/pull/2053
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering
GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
2015-11-27core:execute: fix fork() fail handling in exec_spawn()lc85446
If pid < 0 after fork(), 0 is always returned because r = exec_context_load_environment() has exited successfully. This will make the caller of exec_spawn() not able to handle the fork() error case and make systemd abort assert() possibly.
2015-11-27Merge pull request #1833 from utezduyar/drop-warning-on-presetLennart Poettering
drop warning if setting preset worked anyways
2015-11-27Merge pull request #2017 from haraldh/nobinddevice2Lennart Poettering
core: Do not bind a mount unit to a device, if it was from mountinfo
2015-11-27Merge pull request #1828 from fbuihuu/set-property-on-inactive-unitLennart Poettering
core: allow 'SetUnitProperties()' to run on inactive units too
2015-11-27Merge pull request #1989 from keszybz/filetriggers-v2Lennart Poettering
Return of the file triggers
2015-11-27Merge pull request #2040 from keszybz/randomized-delayLennart Poettering
core: rename Random* to RandomizedDelay*
2015-11-27core: dump rlim_cur tooEvgeny Vereshchagin
2015-11-27core: fix rlimit parsingEvgeny Vereshchagin
* refuse limits if soft > hard * print an actual value instead of (null) see https://github.com/systemd/systemd/pull/1994#issuecomment-159999123
2015-11-26core: rename Random* to RandomizedDelay*Zbigniew Jędrzejewski-Szmek
The name RandomSec is too generic: "Sec" just specifies the default unit type, and "Random" by itself is not enough. Rename to something that should give the user general idea what the setting does without looking at documentation.
2015-11-26Merge pull request #1994 from karelzak/rlimitsLennart Poettering
core: support <soft:hard> ranges for RLIMIT options
2015-11-25core: support <soft:hard> ranges for RLIMIT optionsKarel Zak
The new parser supports: <value> - specify both limits to the same value <soft:hard> - specify both limits the size or time specific suffixes are supported, for example LimitRTTIME=1sec LimitAS=4G:16G The patch introduces parse_rlimit_range() and rlim type (size, sec, usec, etc.) specific parsers. No code is duplicated now. The patch also sync docs for DefaultLimitXXX= and LimitXXX=. References: https://github.com/systemd/systemd/issues/1769
2015-11-24core: Do not bind a mount unit to a device, if it was from mountinfoHarald Hoyer
If a mount unit is bound to a device, systemd tries to umount the mount point, if it thinks the device has gone away. Due to the uevent queue and inotify of /proc/self/mountinfo being two different sources, systemd can never get the ordering reliably correct. It can happen, that in the uevent queue ADD,REMOVE,ADD is queued and an inotify of mountinfo (or libmount event) happend with the device in question. systemd cannot know, at which point of time the mount happend in the ADD,REMOVE,ADD sequence. The real ordering might have been ADD,REMOVE,ADD,mount and systemd might think ADD,mount,REMOVE,ADD and would umount the mountpoint. A test script which triggered this behaviour is: rm -f test-efi-disk.img dd if=/dev/null of=test-efi-disk.img bs=1M seek=512 count=1 parted --script test-efi-disk.img \ "mklabel gpt" \ "mkpart ESP fat32 1MiB 511MiB" \ "set 1 boot on" LOOP=$(losetup --show -f -P test-efi-disk.img) udevadm settle mkfs.vfat -F32 ${LOOP}p1 mkdir -p mnt mount ${LOOP}p1 mnt ... <dostuffwith mnt> Without the "udevadm settle" systemd unmounted mnt while the script was operating on mnt. Of course the question is, why there was a REMOVE in the first place, but this is not part of this patch.
2015-11-24core: mount flags remove FOREACH_WORD_SEPARATORSusant Sahani
FOREACH_WORD_SEPARATOR is no need here since we only apply only one mount flag. The rvalue is sufficient for this.
2015-11-23Merge pull request #1997 from fbuihuu/fix-swap-unit-ordering-depLennart Poettering
make sure all swap units are ordered before the swap target
2015-11-23Convert file trigger scripts to luaZbigniew Jędrzejewski-Szmek
At least the %filetriggerpostun script can be invoked hundreds of times during an upgrade, so it makes sense to optimize it a bit. assert(exec(...)) is used because of https://bugzilla.redhat.com/show_bug.cgi?id=1094072. Add -P (--priority) to have %filetriggerpostun run as early as possible (before any reload/stop actions), and %transfiletriggerin as late as possible (after any enable/disable/preset actions).
2015-11-23make sure all swap units are ordered before the swap targetFranck Bui
When shutting down the system, the swap devices can be disabled long time before the swap target is stopped. They're actually the first units systemd turns off on my system. This is incorrect and due to swap devices having multiple associated swap unit files. The main one is usually created by the fstab generator and is used to start the swap device. Once done, systemd creates some 'alias' units for the same swap device, one for each swap dev link. But those units are missing an ordering dependencies which was created by the fstab generator for the main swap unit. Therefore during shutdown those 'alias' units can be stopped at anytime before unmount.target target. This patch makes sure that all swap units are stopped after the swap.target target.
2015-11-22Rework file trigger scripts to fire at the right timeZbigniew Jędrzejewski-Szmek
This turns out to be more complicated than it looked initially... %transfiletriggerun is called early, while %transfiletriggerin is called late, and neither satifisfies the requirement to call daemon-reload after new unit files have been installed, but before %postun scripts in packages get to fire. It seems that the only solution is to use %filetriggerun (which is called once per package) to do the reload, and keep state in /var/lib/rpm-state/systemd/ to avoid calling the reload multiple times. https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Saving_state_between_scriptlets says that /var/lib/rpm-state/systemd/ is the right dir.
2015-11-22rpm: fix %systemd_user_post() macro.Tadej Janež
Escape "--user" and "--global" arguments with "\\" since rpm treats arguments starting with "-" as macro options which causes "Unknown option" rpm error. Use %{expand:...} to force expansion of the inner macro. Otherwise %{?*} is recursively defined as "\--user \--global {%?*}" which causes "Too many levels of recursion in macro expansion" rpm error. Thanks to Michael Mráka for helping me fix the above issues.
2015-11-22core: allow 'SetUnitProperties()' to run on inactive units tooFranck Bui
'set-property' has been primarly designed to change some properties of *active* units. However it can easily work on inactive units as well. In that case changes are only saved in a drop-in for futur uses and changes will be effective when unit will be started. Actually it already works on inactive units but that was not documented and not fully supported. Indeed the inactive units had to be known by the manager otherwise it was reported as not loaded: $ systemctl status my-test.service * my-test.service - My Testing Unit Loaded: loaded (/etc/systemd/system/my-test.service; static; vendor preset: disabled) Drop-In: /etc/systemd/system/my-test.service.d Active: inactive (dead) $ systemctl set-property my-test.service MemoryLimit=1000000 Failed to set unit properties on my-test.service: Unit my-test.service is not loaded. [ Note: that the unit load state reported by the 'status' command might be confusing since it claimed the unit as loaded but 'set-property' reported the contrary. ] One can possibily workaround this by making the unit a dependency of another active unit so the manager will keep it around: $ systemctl add-wants multi-user.target my-test.service Created symlink from /etc/systemd/system/multi-user.target.wants/my-test.service to /etc/systemd/system/my-test.service. $ systemctl set-property my-test.service MemoryLimit=1000000 $ systemctl status my-test.service * my-test.service - My Testing Unit Loaded: loaded (/etc/systemd/system/my-test.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/my-test.service.d `-50-MemoryLimit.conf Active: inactive (dead) This patch simply forces 'SetUnitProperties()' to load the unit if it's not already the case. It also documents the fact that 'set-property' can be used on inactive units.
2015-11-22Introduce bus_unit_check_load_state() helperFranck Bui
This function is used to check that a previous unit load succeed and returns 0 in this case. In the case the load failed, the function setup a bus error accordingly and returns -errno.
2015-11-19Merge pull request #1947 from phomes/sort-includes2Lennart Poettering
tree-wide: sort includes in *.h
2015-11-18tree-wide: sort includes in *.hThomas Hindoe Paaboel Andersen
This is a continuation of the previous include sort patch, which only sorted for .c files.
2015-11-18core: add new RandomSec= setting for time unitsLennart Poettering
This allows configuration of a random time on top of the elapse events, in order to spread time events in a network evenly across a range.
2015-11-18Merge pull request #1889 from ssahani/socket-protoLennart Poettering
socket: Add support for socket protcol
2015-11-18Socket: socket protocol add to dbus propertiesSusant Sahani
2015-11-18socket: Add support for socket protcolSusant Sahani
Now we don't support the socket protocol like sctp and udplite . This patch add a new config param SocketProtocol: udplite/sctp With this now we can configure the protocol as udplite = IPPROTO_UDPLITE sctp = IPPROTO_SCTP Tested with nspawn:
2015-11-17core: add RemainAfterElapse= setting to timer unitsLennart Poettering
Previously, after a timer unit elapsed we'd leave it around for good, which has the nice benefit that starting a timer that shall trigger at a specific point in time multiple times will only result in one trigger instead of possibly many. With this change a new option RemainAfterElapse= is added. It defaults to "true", to mimic the old behaviour. If set to "false" timer units will be unloaded after they elapsed. This is specifically useful for transient timer units.
2015-11-17core: Minor cleaning up of unit/log status and log logicLennart Poettering
We only reorder a few things and modernize some constructs. No functional changes. - Move some if checks from the caller to the callee of a few functions. - Use IN_SE() where we can - Move status printing functions together
2015-11-17core: make unit_make_transient() more thoroughLennart Poettering
Let's reset more stuff that does not apply to transient units. Also, let's readd the unito to all queues, because it's identity now changed.
2015-11-17core: dispatch load queue each time we set up a transient unitsLennart Poettering
manager_load_unit() will dispatch the load queue anyway, but let's make sure we also dispatch it immediately, after truning a unit into a transient one and loading the properties from the message. That way the know about the validity of the unit before we begin processing the next auxiliary unit.
2015-11-17core: move check whether a unit is suitable to become transient into unit.cLennart Poettering
Lets introduce unit_is_pristine() that verifies whether a unit is suitable to become a transient unit, by checking that it is no referenced yet and has no data on disk assigned.
2015-11-17core: generate nice error messages for auxiliary transient units, tooLennart Poettering
Let's move the validation checks into the loop that sets up the main and auxiliary transient units, so that we can generate pretty error messages for all units a transient unit transaction generates, not just for the main unit.
2015-11-17Merge pull request #1909 from keszybz/filetriggers-v2Lennart Poettering
Move daemon-reload from package %post scripts to file triggers
2015-11-17Merge pull request #1926 from phomes/include-order-libudevDaniel Mack
tree-wide: group include of libudev.h with sd-*
2015-11-17tree-wide: group include of libudev.h with sd-*Thomas Hindoe Paaboel Andersen
2015-11-17core: don't generate warnings when write access to the cgroup fs fails in ↵Lennart Poettering
--user due to EACCES After all, in the classic hierarchy that's pretty much the default case.
2015-11-16tree-wide: sort includesThomas Hindoe Paaboel Andersen
Sort the includes accoding to the new coding style.
2015-11-16core: enable TasksMax= for all services by default, and set it to 512Lennart Poettering
Also, enable TasksAccounting= for all services by default, too. See: http://lists.freedesktop.org/archives/systemd-devel/2015-November/035006.html
2015-11-16downgrade warning if setting preset failedUmut Tezduyar Lindskog
2015-11-15Move daemon-reload from package %post scripts to file triggersZbigniew Jędrzejewski-Szmek
This uses new functionality added in rpm 4.13. Instead of doing one daemon-reload per packages, we do just one or two (When both installing and uninstalling packages, we do two. Unfortunately this also includes the common case of upgrades. When only installing or when only installing, we do just one.) New file triggers.systemd can be built, but the contents have to be copied into the rpm spec file by hand. Using %{load} does not seem to work. It can serve as documentation.
2015-11-13core: now that .snapshot unit are gone, we don't need the per-type .no_gc ↵Lennart Poettering
bool anymore
2015-11-13core: simplify scope unit GC checking code a bitLennart Poettering
2015-11-13core: enable transient unit support for slice unitsLennart Poettering
2015-11-13core: add new DefaultTasksMax= setting for system.confLennart Poettering
This allows initializing the TasksMax= setting of all units by default to some fixed value, instead of leaving it at infinity as before.
2015-11-13core: make sure DefaultLimitCPU= and DefaultLimitRTTIME= understand time ↵Lennart Poettering
units, too We added this for the per-unit setting, hence let's enable this for the global default settings too.
2015-11-13Merge pull request #1869 from poettering/kill-overridableMichal Schmidt
Remove support for RequiresOverridable= and RequisiteOverridable=
2015-11-12Merge pull request #1870 from evverx/clarify_set_priorityLennart Poettering
core: use SD_EVENT_PRIORITY_NORMAL-n instead on -n
2015-11-12core: use SD_EVENT_PRIORITY_NORMAL-n instead on -nEvgeny Vereshchagin