summaryrefslogtreecommitdiff
path: root/src/core
AgeCommit message (Collapse)Author
2016-01-25core: normalize error handling a bit, in setup_pam()Lennart Poettering
Assign errno-style errors to a variable called "r" when they happen, the same way we do this in most other calls. It's bad enough that the error handling part of the function deals with two different error variables (pam_code and r) now, but before this fix it was even three!
2016-01-22Merge pull request #2412 from fbuihuu/device-fixesLennart Poettering
Device fixes
2016-01-22device: make sure to not ignore re-plugged deviceFranck Bui
systemd automatically mounts device unless 'noauto' is part of the mount options. This can happen during boot if the device is plugged at that time or later when the system is already running (the latter case is not documented AFAICS). After the systemd booted, I plugged my USB device which had an entry in /etc/fstab with the default options and systemd automatically mounted it. However I noticed that if I unplugged and re-plugged the device the automatic mounting of the device didn't work anymore: systemd didn't notice that the device was re-plugged. This was due to the device unit which was not recycled by the GC during the unplug event because in the case of automounting, the mount unit still referenced it. When the device was re-plugged, the old device unit was reused but it still had the old sysfs path (amongst other useful information). Systemd was confused by the stalled sysfs path and decided to ignore the plug event. This patch fixes this issue by simply not doing the sanity checking on the sysfs path if the device is in unplugged state.
2016-01-22Merge pull request #2080 from ↵Daniel Mack
chaloulo/split-mode-host-remove-port-from-journal-filename journal-remote: split-mode=host, remove port from journal filename
2016-01-21Merge pull request #2371 from evverx/add-valgrind-helper-for-daemon-reexecDaniel Mack
core: add valgrind helper for daemon-reexec
2016-01-21Merge pull request #2391 from keszybz/coverityDaniel Mack
Coverity inspired fixes
2016-01-21core: add valgrind helper for daemon-reexecEvgeny Vereshchagin
Inspired by https://github.com/systemd/systemd/issues/2187#issuecomment-165587140
2016-01-20systemd: remove dead codeZbigniew Jędrzejewski-Szmek
We only go to fail label if pam_pid <= 0. CID #1306746.
2016-01-20Merge pull request #2085 from fbuihuu/more-use-of-check-load-stateLennart Poettering
core: use bus_unit_check_load_state() in transaction_add_job_and_depe…
2016-01-19Merge pull request #2357 from keszybz/warnings-2Lennart Poettering
Remove gcc warnings v2
2016-01-18core/dbus-execute: do not needlessly compare strings againZbigniew Jędrzejewski-Szmek
gcc complains that dirs might be unitialized. It cannot, but we just checked that name has one of three values above, so no need to check again.
2016-01-18Merge pull request #2347 from aroig/gh/fix-udev-user-wantsDaniel Mack
Fix broken SYSTEMD_USER_WANTS in udev rules.
2016-01-18core: fix memory leak on failed preset-allEvgeny Vereshchagin
How to reproduce $ systemctl set-default multi-user # https://github.com/systemd/systemd/issues/2298 $ systemctl preset-all Failed to execute operation: Too many levels of symbolic links $ systemctl poweroff Fixes: ==1== ==1== HEAP SUMMARY: ==1== in use at exit: 65,645 bytes in 7 blocks ==1== total heap usage: 40,539 allocs, 40,532 frees, 30,147,547 bytes allocated ==1== ==1== 109 (24 direct, 85 indirect) bytes in 1 blocks are definitely lost in loss record 2 of 7 ==1== at 0x4C2BBCF: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1== by 0x4C2DE2F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1== by 0x23DA71: unit_file_changes_add (install.c:233) ==1== by 0x23E45D: remove_marked_symlinks_fd (install.c:453) ==1== by 0x23E267: remove_marked_symlinks_fd (install.c:405) ==1== by 0x23E641: remove_marked_symlinks (install.c:494) ==1== by 0x243A91: execute_preset (install.c:2190) ==1== by 0x244343: unit_file_preset_all (install.c:2351) ==1== by 0x18AAA2: method_preset_all_unit_files (dbus-manager.c:1846) ==1== by 0x1D8157: method_callbacks_run (bus-objects.c:420) ==1== by 0x1DA9E9: object_find_and_run (bus-objects.c:1257) ==1== by 0x1DB02B: bus_process_object (bus-objects.c:1373) ==1== ==1== LEAK SUMMARY: ==1== definitely lost: 24 bytes in 1 blocks ==1== indirectly lost: 85 bytes in 1 blocks ==1== possibly lost: 0 bytes in 0 blocks ==1== still reachable: 65,536 bytes in 5 blocks ==1== suppressed: 0 bytes in 0 blocks ==1== Reachable blocks (those to which a pointer was found) are not shown. ==1== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==1== ==1== For counts of detected and suppressed errors, rerun with: -v ==1== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
2016-01-17Fix broken SYSTEMD_USER_WANTS in udev rules.Abdo Roig-Maranges
The functionality of SYSTEMD_USER_WANTS that attaches dependencies to device units from udev rules was broken since commit b2c23da8. I guess it was due to a mass replace s/SYSTEMD_USER/MANAGER_USER/.
2016-01-17core: fix memory leak on set-default, enable, disable etcEvgeny Vereshchagin
Fixes: ==1== by 0x23E44C: remove_marked_symlinks_fd (install.c:453) ==1== by 0x23E256: remove_marked_symlinks_fd (install.c:405) ==1== by 0x23E630: remove_marked_symlinks (install.c:494) ==1== by 0x2427A0: unit_file_disable (install.c:1876) ==1== by 0x18A633: method_disable_unit_files_generic (dbus-manager.c:1760) ==1== by 0x18A6CA: method_disable_unit_files (dbus-manager.c:1768) ==1== by 0x1D8146: method_callbacks_run (bus-objects.c:420) ==1== by 0x1DA9D8: object_find_and_run (bus-objects.c:1257) ==1== by 0x1DB01A: bus_process_object (bus-objects.c:1373) ==1== ==1== 228 (48 direct, 180 indirect) bytes in 2 blocks are definitely lost in loss record 8 of 14 ==1== at 0x4C2BBCF: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1== by 0x4C2DE2F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1== by 0x23DA60: unit_file_changes_add (install.c:233) ==1== by 0x23DDB2: create_symlink (install.c:298) ==1== by 0x240C5C: install_info_symlink_wants (install.c:1328) ==1== by 0x240FC8: install_info_apply (install.c:1384) ==1== by 0x241211: install_context_apply (install.c:1439) ==1== by 0x242563: unit_file_enable (install.c:1830) ==1== by 0x18A06E: method_enable_unit_files_generic (dbus-manager.c:1650) ==1== by 0x18A141: method_enable_unit_files (dbus-manager.c:1660) ==1== by 0x1D8146: method_callbacks_run (bus-objects.c:420) ==1== by 0x1DA9D8: object_find_and_run (bus-objects.c:1257) ==1== ==1== 467 (144 direct, 323 indirect) bytes in 3 blocks are definitely lost in loss record 9 of 14 ==1== at 0x4C2DD9F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1== by 0x23DA60: unit_file_changes_add (install.c:233) ==1== by 0x23DE97: create_symlink (install.c:320) ==1== by 0x242CFC: unit_file_set_default (install.c:1951) ==1== by 0x18A881: method_set_default_target (dbus-manager.c:1802) ==1== by 0x1D8146: method_callbacks_run (bus-objects.c:420) ==1== by 0x1DA9D8: object_find_and_run (bus-objects.c:1257) ==1== by 0x1DB01A: bus_process_object (bus-objects.c:1373) ==1== by 0x259143: process_message (sd-bus.c:2567) ==1== by 0x259326: process_running (sd-bus.c:2609) ==1== by 0x259BDC: bus_process_internal (sd-bus.c:2798) ==1== by 0x259CAD: sd_bus_process (sd-bus.c:2817) ==1== ==1== LEAK SUMMARY: ==1== definitely lost: 216 bytes in 6 blocks ==1== indirectly lost: 560 bytes in 14 blocks ==1== possibly lost: 0 bytes in 0 blocks ==1== still reachable: 65,536 bytes in 5 blocks ==1== suppressed: 0 bytes in 0 blocks ==1== Reachable blocks (those to which a pointer was found) are not shown. ==1== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==1==
2016-01-15Merge pull request #2328 from evverx/fix-transient-units-memeory-leakDaniel Mack
Fix transient units memory leak
2016-01-15core: fix memory leak in transient unitsEvgeny Vereshchagin
Fixes: ==1== HEAP SUMMARY: ==1== in use at exit: 67,182 bytes in 91 blocks ==1== total heap usage: 70,485 allocs, 70,394 frees, 42,184,635 bytes allocated ==1== ==1== 5,742 (696 direct, 5,046 indirect) bytes in 29 blocks are definitely lost in loss record 4 of 7 ==1== at 0x4C2DD9F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==1== by 0x21ADDD: realloc_multiply (alloc-util.h:67) ==1== by 0x21BFB0: strv_push (strv.c:448) ==1== by 0x21C245: strv_consume (strv.c:520) ==1== by 0x21C33C: strv_extend (strv.c:559) ==1== by 0x278AD7: unit_write_drop_in (unit.c:3352) ==1== by 0x278EEB: unit_write_drop_in_private (unit.c:3403) ==1== by 0x190C21: bus_service_set_transient_property (dbus-service.c:254) ==1== by 0x190DBC: bus_service_set_property (dbus-service.c:284) ==1== by 0x18F00E: bus_unit_set_properties (dbus-unit.c:1226) ==1== by 0x186F6A: transient_unit_from_message (dbus-manager.c:683) ==1== by 0x1872B7: method_start_transient_unit (dbus-manager.c:763) ==1== ==1== LEAK SUMMARY: ==1== definitely lost: 696 bytes in 29 blocks ==1== indirectly lost: 5,046 bytes in 58 blocks ==1== possibly lost: 0 bytes in 0 blocks ==1== still reachable: 61,440 bytes in 4 blocks ==1== suppressed: 0 bytes in 0 blocks
2016-01-14transaction: downgrade warnings about wanted unit which are not foundFranck Bui
If a unit was pulled by a Wants= dependency but its unit file was not present then we logged this as an error. However Wants= might be used to configure a soft/optional dependency on another unit, ie. start an optional service only if it's installed otherwise simply skip it. In this case emitting an error doesn't look appropriate. But it's still an error if the optional dependency exists but its activation fails for any reasons.
2016-01-14core: fix memory leak on reloadEvgeny Vereshchagin
==1== HEAP SUMMARY: ==1== in use at exit: 61,728 bytes in 22 blocks ==1== total heap usage: 258,122 allocs, 258,100 frees, 78,219,628 bytes allocated ==1== ==1== 16 bytes in 1 blocks are definitely lost in loss record 1 of 6 ==1== at 0x4C2BBCF: malloc (vg_replace_malloc.c:299) ==1== by 0x1E350E: memdup (alloc-util.c:34) ==1== by 0x135AFB: memdup_multiply (alloc-util.h:74) ==1== by 0x140F97: manager_set_default_rlimits (manager.c:2929) ==1== by 0x1303DA: manager_set_defaults (main.c:737) ==1== by 0x133A02: main (main.c:1718) ==1== ==1== 272 bytes in 17 blocks are definitely lost in loss record 2 of 6 ==1== at 0x4C2BBCF: malloc (vg_replace_malloc.c:299) ==1== by 0x1E350E: memdup (alloc-util.c:34) ==1== by 0x135AFB: memdup_multiply (alloc-util.h:74) ==1== by 0x140F97: manager_set_default_rlimits (manager.c:2929) ==1== by 0x1303DA: manager_set_defaults (main.c:737) ==1== by 0x13480D: main (main.c:1828) ==1== ==1== LEAK SUMMARY: ==1== definitely lost: 288 bytes in 18 blocks ==1== indirectly lost: 0 bytes in 0 blocks ==1== possibly lost: 0 bytes in 0 blocks ==1== still reachable: 61,440 bytes in 4 blocks ==1== suppressed: 0 bytes in 0 blocks ==1== Reachable blocks (those to which a pointer was found) are not shown. ==1== To see them, rerun with: --leak-check=full --show-leak-kinds=all
2016-01-13tree-wide: check if errno is greater than zero (2)Zbigniew Jędrzejewski-Szmek
Compare errno with zero in a way that tells gcc that (if the condition is true) errno is positive.
2016-01-13tree-wide: check if errno is greater then zeroZbigniew Jędrzejewski-Szmek
gcc is confused by the common idiom of return errno ? -errno : -ESOMETHING and thinks a positive value may be returned. Replace this condition with errno > 0 to help gcc and avoid many spurious warnings. I filed a gcc rfe a long time ago, but it hard to say if it will ever be implemented [1]. Both conventions were used in the codebase, this change makes things more consistent. This is a follow up to bcb161b0230f. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61846
2016-01-12Merge pull request #490 from pyssling/masterLennart Poettering
Add machine-id setting
2016-01-12core: Add machine-id settingNils Carlson
Allow for overriding all other machine-ids which may be present on the system using a kernel command line systemd.machine_id or --machine-id= option. This is especially useful for network booted systems where the machine-id needs to be static, or for containers where a specific machine-id is wanted.
2016-01-12tree-wide: use xsprintf() where applicableDaniel Mack
Also add a coccinelle receipt to help with such transitions.
2016-01-12capabilities: added support for ambient capabilities.Ismo Puustinen
This patch adds support for ambient capabilities in service files. The idea with ambient capabilities is that the execed processes can run with non-root user and get some inherited capabilities, without having any need to add the capabilities to the executable file. You need at least Linux 4.3 to use ambient capabilities. SecureBit keep-caps is automatically added when you use ambient capabilities and wish to change the user. An example system service file might look like this: [Unit] Description=Service for testing caps [Service] ExecStart=/usr/bin/sleep 10000 User=nobody AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW After starting the service it has these capabilities: CapInh: 0000000000003000 CapPrm: 0000000000003000 CapEff: 0000000000003000 CapBnd: 0000003fffffffff CapAmb: 0000000000003000
2016-01-12capabilities: keep bounding set in non-inverted format.Ismo Puustinen
Change the capability bounding set parser and logic so that the bounding set is kept as a positive set internally. This means that the set reflects those capabilities that we want to keep instead of drop.
2016-01-11Merge pull request #2262 from pohly/smack-networkLennart Poettering
smack: Handling network
2016-01-11smack: Handling networkCasey Schaufler
- Set Smack ambient to match run label - Set Smack netlabel host rules Set Smack ambient to match run label ------------------------------------ Set the Smack networking ambient label to match the run label of systemd. System services may expect to communicate with external services over IP. Setting the ambient label assigns that label to IP packets that do not include CIPSO headers. This allows systemd and the services it spawns access to unlabeled IP packets, and hence external services. A system may choose to restrict network access to particular services later in the startup process. This is easily done by resetting the ambient label elsewhere. Set Smack netlabel host rules ----------------------------- If SMACK_RUN_LABEL is defined set all other hosts to be single label hosts at the specified label. Set the loopback address to be a CIPSO host. If any netlabel host rules are defined in /etc/smack/netlabel.d install them into the smackfs netlabel interface. [Patrick Ohly: copied from https://review.tizen.org/git/?p=platform/upstream/systemd.git;a=commit;h=db4f6c9a074644aa2bf] [Patrick Ohly: adapt to write_string_file() change in "fileio: consolidate write_string_file*()"] [Patrick Ohly: create write_netlabel_rules() based on the original write_rules() that was removed in "smack: support smack access change-rule"] [Patrick Ohly: adapted to upstream code review feedback: error logging, string constants]
2016-01-10tree-wide: unify argument lists of IN_SET()Daniel Mack
The new implementation will not allow passing the same values more than once, so clean up first.
2016-01-05mount-setup.c: fix handling of symlink Smack labelling in cgroup setupPatrick Ohly
The code introduced in f8c1a81c51 (= systemd 227) failed for me with: Failed to copy smack label from net_cls to /sys/fs/cgroup/net_cls: No such file or directory There is no need for a symlink in this case because source and target are identical. The symlink() call is allowed to fail when the target already exists. When that happens, copying the Smack label must be skipped. But the code also failed when there is a symlink, like "cpu -> cpu,cpuacct", because mac_smack_copy() got called with src="cpu,cpuacct" which fails to find the entry because the current directory is not inside /sys/fs/cgroup. The absolute path to the existing entry must be used instead.
2016-01-04core: don't enable special signals in test modeEvgeny Vereshchagin
Fixes: $ systemd-analyze verify ... Failed to open /dev/tty0: Permission denied
2016-01-04core: revert "manager: do not set up signals in test mode"Evgeny Vereshchagin
This reverts commit 5aa1054521596c3d268db5f4aff9f2b69647ffc9. Fixes test-execute $ sudo make check TESTS=test-execute ... $ cat test-execute.log + test /tmp/test-exec_workingdirectory = /tmp/test-exec_workingdirectory Test timeout when testing exec-workingdirectory.service exec-workingdirectory.service UMask: 0022 WorkingDirectory: /tmp/test-exec_workingdirectory RootDirectory: / NonBlocking: no PrivateTmp: no PrivateNetwork: no PrivateDevices: no ProtectHome: no ProtectSystem: no IgnoreSIGPIPE: yes RuntimeDirectoryMode: 0755 StandardInput: null StandardOutput: inherit StandardError: inherit FAIL test-execute (exit status: 1)
2015-12-31core: socket options fix SCTP_NODELAYSusant Sahani
SCTP_NODELAY is diffrent to TCP_NODELAY. Apply proper options in case of SCTP.
2015-12-26Merge pull request #2224 from keszybz/analyze-verify-warningLennart Poettering
manager: do not set up signals in test mode
2015-12-25manager: do not set up signals in test modeZbigniew Jędrzejewski-Szmek
When we are running in test mode, we don't expect any signals. In fact ^C should end the program. This also avoids permission issues when running systemd-analyze verify.
2015-12-24Merge pull request #2216 from zonque/nameownerchangedLennart Poettering
core: re-sync bus name list after deserializing during daemon-reload
2015-12-23core: re-sync bus name list after deserializing during daemon-reloadDaniel Mack
When the daemon reloads, it doesn not actually give up its DBus connection, as wrongly stated in an earlier commit. However, even though the bus connection stays open, the daemon flushes out all its internal state. Hence, if there is a NameOwnerChanged signal after the flush and before the deserialization, it cannot be matched against any pending unit. To fix this, rename bus_list_names() to manager_sync_bus_names() and call it explicitly at the end of the daemon reload operation.
2015-12-22socket: nullify pointers after freeDaniel Mack
A socket shouldn't be used after socket_done() returns, but follow the general guideline here and avoid dangling pointers anyway.
2015-12-22socket: free fdname memberDaniel Mack
Plug a small memory leak.
2015-12-21core: fix bus name synchronization after daemon-reloadDaniel Mack
During daemon-reload, PID1 temporarly loses its DBus connection, so there's a small window in which all signals sent by dbus-daemon are lost. This is a problem, since we rely on the NameOwnerChanged signals in order to consider a service with Type=dbus fully started or terminated, respectively. In order to fix this, a rewrite of bus_list_names() is necessary. We used to walk the current list of names on the bus, and blindly triggered the bus_name_owner_change() callback on each service, providing the actual name as current owner. This implementation has a number of problems: * We cannot detect if the the name was moved from one owner to the other while we were reloading * We don't notify services which missed the name loss signal * Providing the actual name as current owner is a hack, as the comment also admits. To fix this, this patch carries the following changes: * Track the name of the current bus name owner, and (de-)serialize it during reload. This way, we can detect changes. * In bus_list_names(), walk the list of bus names we're interested in first, and then see if the name is active on the bus. If it is, check it it's still the same as it used to be, and synthesize NameOwnerChanged signals for the name add and/or loss. This should fully synchronize the current name list with the internal state of all services.
2015-12-15Merge pull request #2157 from keszybz/manager-statusDaniel Mack
Manager status
2015-12-13manager: log log level changes uniformlyZbigniew Jędrzejewski-Szmek
Output the same message when a request to change the log level is received over dbus and through a signal. From the user point of view those two operations are very similar and it's easy to think that the dbus operation didn't work when the expected message is not emitted. Also "downgrade" the message level to info, since this is a normal user initiated action.
2015-12-13manager: move status output change debug messages to set functionZbigniew Jędrzejewski-Szmek
This way we can only print the debug message when the status actually changes. We also means we don't print anything when running in --user mode, where status output is always disabled.
2015-12-10Merge pull request #2076 from keszybz/downgrade-masked-unit-messageLennart Poettering
core: do not warn about Wants depencencies on masked units
2015-12-10Merge pull request #2056 from evverx/expose-soft-limits-on-the-busLennart Poettering
Expose soft limits on the bus
2015-12-02core: use bus_unit_check_load_state() in transaction_add_job_and_dependencies()Franck Bui
2015-12-01journal-remote: split-mode=host, remove port from journal filenameKlearchos Chaloulos
When constructing the journal filename to store logs from a remote host, remove the port of the tcp connection, as the port will change with every reboot/connection loss between sender/reveiver machines. Having the port in the filename will cause a new journal file to be created for every reboot or connection loss. For the implementation, a new argument "bool include_port" is added to the getpeername_pretty() function. This is passed to the sockaddr_pretty() function. The value of the include_port argument is set to true in all calls of getpeername_pretty(), except for 2 calls in journal-remote.c, where it is set to false.
2015-11-30core: do not warn about Wants depencencies on masked unitsZbigniew Jędrzejewski-Szmek
When masking is used to prevent a unit from being loaded, every transaction with dependent units would generate a warning. Downgrade this warning to debug level. transaction_add_job_and_dependencies only generated a few return values found in the table in bus_common_errors.c, and EADDRNOTAVAIL is not one of them, so do not try to suppress EADDRNOTAVAIL. https://bugzilla.redhat.com/show_bug.cgi?id=1278264
2015-11-30core: dump soft limits tooEvgeny Vereshchagin
2015-11-30core: expose soft limits on the busEvgeny Vereshchagin
This is a follow-up for https://github.com/systemd/systemd/pull/1994 See https://github.com/systemd/systemd/pull/1994#issuecomment-160087219