summaryrefslogtreecommitdiff
path: root/src/shared
Commit message (Collapse)AuthorAge
* Prep v231.2: Make elogind musl-libc-compatible again.Sven Eden2017-06-19
|
* acl-util: fix memleakEvgeny Vereshchagin2017-06-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: $ ./libtool --mode execute valgrind --leak-check=full ./journalctl >/dev/null ==22309== Memcheck, a memory error detector ==22309== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==22309== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==22309== Command: /home/vagrant/elogind/.libs/lt-journalctl ==22309== Hint: You are currently not seeing messages from other users and the system. Users in groups 'adm', 'elogind-journal', 'wheel' can see all messages. Pass -q to turn off this notice. ==22309== ==22309== HEAP SUMMARY: ==22309== in use at exit: 8,680 bytes in 4 blocks ==22309== total heap usage: 5,543 allocs, 5,539 frees, 9,045,618 bytes allocated ==22309== ==22309== 488 (56 direct, 432 indirect) bytes in 1 blocks are definitely lost in loss record 2 of 4 ==22309== at 0x4C2BBAD: malloc (vg_replace_malloc.c:299) ==22309== by 0x6F37A0A: __new_var_obj_p (__libobj.c:36) ==22309== by 0x6F362F7: __acl_init_obj (acl_init.c:28) ==22309== by 0x6F37731: __acl_from_xattr (__acl_from_xattr.c:54) ==22309== by 0x6F36087: acl_get_file (acl_get_file.c:69) ==22309== by 0x4F15752: acl_search_groups (acl-util.c:172) ==22309== by 0x113A1E: access_check_var_log_journal (journalctl.c:1836) ==22309== by 0x113D8D: access_check (journalctl.c:1889) ==22309== by 0x115681: main (journalctl.c:2236) ==22309== ==22309== LEAK SUMMARY: ==22309== definitely lost: 56 bytes in 1 blocks ==22309== indirectly lost: 432 bytes in 1 blocks ==22309== possibly lost: 0 bytes in 0 blocks ==22309== still reachable: 8,192 bytes in 2 blocks ==22309== suppressed: 0 bytes in 0 blocks (cherry picked from commit 29d87223d54fc13e16f444677f0a94ed0755bd88)
* Prep v231: Move can_sleep() back to src/shared/sleep-config.cSven Eden2017-06-16
|
* Prep v231: Apply missing fixes from upstream (5/6) src/sharedSven Eden2017-06-16
|
* Use "return log_error_errno" in more places"Zbigniew Jędrzejewski-Szmek2017-06-16
|
* conf-parser: minor coding style improvementsLennart Poettering2017-06-16
|
* sd-bus: make sure bus_map_all_properties() handle booleans rightLennart Poettering2017-06-16
| | | | | | | | | | sd-bus generally exposes bools as "int" instead of "bool" in the public API. This is relevant when unmarshaling booleans, as the relevant functions expect an int* pointer and no bool* pointer. Since sizeof(bool) is not necessarily the same as sizeof(int) this is problematic and might result in memory corruption. Let's fix this, and make sure bus_map_all_properties() handles booleans as ints, as the rest of sd-bus, and make all users of it expect the right thing.
* bus_util: add support to map double (#3479)Susant Sahani2017-06-16
| | | | | | Now we don't support parsing double at map_basic. when trying to use bus_message_map_all_properties with a double this fails. Let's add it.
* pager: don't start pager if the terminal is explicitly set to TERM=dumbLennart Poettering2017-06-16
| | | | | | | | | As suggested here: https://bugs.freedesktop.org/show_bug.cgi?id=64737#c8 This adds a new call terminal_is_dumb() and makes use of this where appropriate.
* Prep v229.5: Make musl-libc utmp/wtmp stubs visible.Sven Eden2017-06-16
|
* Prep v229.5: Move parse-printf-format.? back to src/basic it is needed there.Sven Eden2017-06-16
|
* Prep v230: Add utmp support to make wall message to work properly.Sven Eden2017-06-16
|
* Prep v230: Move musl_missing and parse-printf-format to libshared.Sven Eden2017-06-16
|
* Prep v230: Apply missing upstream fixes and updates (7/8) src/shared.Sven Eden2017-06-16
|
* Prep v230: Apply missing upstream fixes and updates (1/8) root build files.Sven Eden2017-06-16
|
* core: introduce CGroupIOLimitType enumsTejun Heo2017-06-16
| | | | | | | | | | | Currently, there are two cgroup IO limits, bandwidth max for read and write, and they are hard-coded in various places. This is fine for two limits but IO is expected to grow more limits - low, high and max limits for bandwidth and IOPS - and hard-coding each limit won't make sense. This patch replaces hard-coded limits with an array indexed by CGroupIOLimitType and accompanying string and default value tables so that new limits can be added trivially.
* tree-wide: rename draw_special_char to special_glyphZbigniew Jędrzejewski-Szmek2017-06-16
| | | | | | | | | That function doesn't draw anything on it's own, just returns a string, which sometimes is more than one character. Also remove "DRAW_" prefix from character names, TREE_* and ARROW and BLACK_CIRCLE are unambigous on their own, don't draw anything, and are always used as an argument to special_glyph(). Rename "DASH" to "MDASH", as there's more than one type of dash.
* core: add io controller support on the unified hierarchyTejun Heo2017-06-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On the unified hierarchy, blkio controller is renamed to io and the interface is changed significantly. * blkio.weight and blkio.weight_device are consolidated into io.weight which uses the standardized weight range [1, 10000] with 100 as the default value. * blkio.throttle.{read|write}_{bps|iops}_device are consolidated into io.max. Expansion of throttling features is being worked on to support work-conserving absolute limits (io.low and io.high). * All stats are consolidated into io.stats. This patchset adds support for the new interface. As the interface has been revamped and new features are expected to be added, it seems best to treat it as a separate controller rather than trying to expand the blkio settings although we might add automatic translation if only blkio settings are specified. * io.weight handling is mostly identical to blkio.weight[_device] handling except that the weight range is different. * Both read and write bandwidth settings are consolidated into CGroupIODeviceLimit which describes all limits applicable to the device. This makes it less painful to add new limits. * "max" can be used to specify the maximum limit which is equivalent to no config for max limits and treated as such. If a given CGroupIODeviceLimit doesn't contain any non-default configs, the config struct is discarded once the no limit config is applied to cgroup. * lookup_blkio_device() is renamed to lookup_block_device(). Signed-off-by: Tejun Heo <htejun@fb.com>
* shared: move unit-specific code from bus-util.h to bus-unit-util.hLennart Poettering2017-06-16
| | | | | | | Previously we'd have generally useful sd-bus utilities in bust-util.h, intermixed with code that is specifically for writing clients for PID 1, wrapping job and unit handling. Let's split the latter out and move it into bus-unit-util.c, to make the sources a bit short and easier to grok.
* core,systemctl: add bus API to retrieve processes of a unitLennart Poettering2017-06-16
| | | | | | | | | | | | | | | This adds a new GetProcesses() bus call to the Unit object which returns an array consisting of all PIDs, their process names, as well as their full cgroup paths. This is then used by "systemctl status" to show the per-unit process tree. This has the benefit that the client-side no longer needs to access the cgroupfs directly to show the process tree of a unit. Instead, it now uses this new API, which means it also works if -H or -M are used correctly, as the information from the specific host is used, and not the one from the local system. Fixes: #2945
* conf-parser: Set EXTRACT_RETAIN_ESCAPE when extracting words (#2917)Dan Nicholson2017-06-16
| | | | | | | | | | | | | | | | | | | | | | If you reference another unit with an escaped name, the escaped characters should remain in the extracted word. This used to work correctly prior to commit 34f253f0. The problem can be seen when units with escaped names are referenced. $ cat "/usr/lib/elogind/system/dev-disk-by\x2dlabel-eos\x2dswap.swap" [Swap] What=/dev/disk/by-label/eos-swap [Install] WantedBy=dev-disk-by\x2dlabel-eos\x2dswap.device $ systemctl enable "dev-disk-by\x2dlabel-eos\x2dswap.swap" Created symlink /etc/elogind/system/dev-disk-byx2dlabel-eosx2dswap.device.wants/dev-disk-by\x2dlabel-eos\x2dswap.swap, pointing to /usr/lib/elogind/system/dev-disk-by\x2dlabel-eos\x2dswap.swap. The wants directory should be created with the x2ds escaped with \.
* shared/install,systemctl,core: report offending file on installation errorZbigniew Jędrzejewski-Szmek2017-06-16
| | | | | | | | | | | | | | | | | | | | | Fixes #2191: $ systemctl --root=/ enable sddm Created symlink /etc/elogind/system/display-manager.service, pointing to /usr/lib/elogind/system/sddm.service. $ sudo build/systemctl --root=/ enable gdm Failed to enable unit, file /etc/elogind/system/display-manager.service already exists and is a symlink to /usr/lib/elogind/system/sddm.service. $ sudo build/systemctl --root= enable sddm $ sudo build/systemctl --root= enable gdm Failed to enable unit: File /etc/elogind/system/display-manager.service already exists and is a symlink to /usr/lib/elogind/system/sddm.service. (I tried a few different approaches to pass the error information back to the caller. Adding a new parameter to hold the error results in a gigantic patch and a lot of hassle to pass the args arounds. Adding this information to the changes array is straightforward and can be more easily extended in the future.) In case local installation is performed, the full set of errors can be reported and we do that. When running over dbus, only the first error is reported.
* systemctl/core: ignore masked units in preset-allZbigniew Jędrzejewski-Szmek2017-06-16
| | | | | | | | | | | | | | | With any masked unit that would that would be enabled by presets, we'd get: test@rawhide $ sudo systemctl preset-all Failed to execute operation: Unit file is masked. test@rawhide $ sudo systemctl --root=/ preset-all Operation failed: Cannot send after transport endpoint shutdown Simply ignore those units: test@rawhide $ sudo systemctl preset-all Unit xxx.service is masked, ignoring.
* tree-wide: remove useless NULLs from strjoinaZbigniew Jędrzejewski-Szmek2017-06-16
| | | | The coccinelle patch didn't work in some places, I have no idea why.
* polkit: don't start polkit agent when running as rootMartin Pitt2017-06-16
| | | | | | | | | On the server side we already bypass the polkit checks if the caller is root (see the sd_bus_query_sender_privilege() call in bus_verify_polkit_async()). So there is no reason to invoke polkit when running systemctl/machinectl/loginctl/timedatectl as root. Fixes #2748
* bus-util: Fix reading uint32 propertiesMartin Pitt2017-06-16
| | | | | | | | Fix copy&paste bug in map_basic() to use the correct data type for SD_BUS_TYPE_UINT32. Before we were copying the wrong 32 bits into the destination pointer, resulting in complete garbage on big-endian systems. Fixes #2927
* shared: fix a misspelling of "journalctl"Biao Lu2017-06-16
|
* Ignore BOM in config filesZbigniew Jędrzejewski-Szmek2017-06-16
| | | | | | Fixes #2823. Also remove unnecessary feof check.
* tree-wide: minor formatting inconsistency cleanupsVito Caputo2017-06-16
|
* tree-wide: make ++/-- usage consistent WRT spacingVito Caputo2017-06-16
| | | | | | Throughout the tree there's spurious use of spaces separating ++ and -- operators from their respective operands. Make ++ and -- operator consistent with the majority of existing uses; discard the spaces.
* tree-wide: merge pager_open_if_enabled() to the pager_open()Alexander Kuleshov2017-06-16
| | | | | | | | | Many subsystems define own pager_open_if_enabled() function which checks '--no-pager' command line argument and open pager depends on its value. All implementations of pager_open_if_enabled() are the same. Let's merger this function with pager_open() from the shared/pager.c and remove pager_open_if_enabled() from all subsytems to prevent code duplication.
* systemctl: fix style to avoid modification of array passed by callerZbigniew Jędrzejewski-Szmek2017-06-16
| | | | Followup for 4524439edb7d.
* systemctl: include -M or -H arguments in the hintZbigniew Jędrzejewski-Szmek2017-06-16
| | | | | | | | | | | | | | | | https://github.com/elogind/elogind/issues/2431 Some newlines are added, but the output will still exceed 80 columns in many cases. The fallback for oom conditions is changed from "n/a" to something "<service>", and a similar pattern is used for the new code. This way we have a realistic fallback for oom, which seems nicer than making the whole function return an error code which would then have to be propagated. $ systemctl -M fedora-rawhide restart elogind-networkd.service Job for elogind-networkd.service failed because start of the service was attempted too often. See "systemctl -M fedora-rawhide status elogind-networkd.service" and "journalctl -M fedora-rawhide -xe" for details. To force a start use "systemctl -M fedora-rawhide reset-failed elogind-networkd.service" followed by "systemctl -M fedora-rawhide start elogind-networkd.service" again.
* Prep v229: Consolidate system sleep functions.Sven Eden2017-05-22
| | | | | | Move sleep relevant functions from shared/sleep-config.* and login/logind-action.* into login/logind-sleep.* - they aren't used outside of elogind anyway.
* Prep v229: elogind should honor its Sleep configuration.Sven Eden2017-05-19
|
* Prep v229: Remove orphaned filesSven Eden2017-05-17
| | | | | | | The files - src/shared/output-mode.h and - src/test/test-signal-util.c are not used anywhere anymore.
* Prep v229: Remove remaining emacs settings [5/6] src/sharedSven Eden2017-05-17
|
* Prep v229: Add missing fixes from upstream [5/6] src/sharedSven Eden2017-05-17
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2017-05-17
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* core: rework unit timeout handling, and add new setting RuntimeMaxSec=Lennart Poettering2017-05-17
| | | | | | | | | | | | | | | | | | | | | | This clean-ups timeout handling in PID 1. Specifically, instead of storing 0 in internal timeout variables as indication for a disabled timeout, use USEC_INFINITY which is in-line with how we do this in the rest of our code (following the logic that 0 means "no", and USEC_INFINITY means "never"). This also replace all usec_t additions with invocations to usec_add(), so that USEC_INFINITY is properly propagated, and sd-event considers it has indication for turning off the event source. This also alters the deserialization of the units to restart timeouts from the time they were originally started from. Before this patch timeouts would be restarted beginning with the time of the deserialization, which could lead to artificially prolonged timeouts if a daemon reload took place. Finally, a new RuntimeMaxSec= setting is introduced for service units, that specifies a maximum runtime after which a specific service is forcibly terminated. This is useful to put time limits on time-intensive processing jobs. This also simplifies the various xyz_spawn() calls of the various types in that explicit distruction of the timers is removed, as that is done anyway by the state change handlers, and a state change is always done when the xyz_spawn() calls fail. Fixes: #2249
* core: fix support for transient resource limit propertiesLennart Poettering2017-05-17
| | | | | | | | | | | | | Make sure we can properly process resource limit properties. Specifically, allow transient configuration of both the soft and hard limit, the same way from the unit files. Previously, only the the hard rlimits could be configured but they'd implicitly spill into the soft hard rlimits. This also updates the client-side code to be able to parse hard/soft resource limit specifications. Since we need to serialize two properties in bus_append_unit_property_assignment() now, the marshalling of the container around it is now moved into the function itself. This has the benefit of shortening the calling code. As a side effect this now beefs up the rlimit parser of "systemctl set-property" to understand time and disk sizes where that's appropriate.
* shared: simplify parsing of bus properties a bitLennart Poettering2017-05-17
| | | | Let's write the property name and value in one call, when that's possible, shorthing our code a bit.
* core: fix handling of AccuracyUSec and RandomDelayUSec bus propertiesLennart Poettering2017-05-17
| | | | | | | | | | | Clear up some confusion regarding the USec and Sec suffixes we use. In configuration files we usually use the Sec suffix, to indicate the implied time unit if none is specified. The respective bus properties however use the USec property, since they expose 64bit unsigned integers containing time in µs. Before this patch timer units exposed a bus property AccuracyUSec (which hence is the correct name) but when parsing transient property data would look for AccuracySec instead (which is incorrect). This patch ensures we look for AccuracySec correctly, but keeps the code for AccuracyUSec in place for compatibility, but adds a warning to ensure that apps are updated to use the right property.
* systemctl: improve message when a job fails with a JOB_INVALID stateLennart Poettering2017-05-17
| | | | This result can only happen if the job was a reload job for an inactive unit. Make the error message actually say that.
* bus-util: print "systemctl --user" on user service managerWaLyong Cho2017-05-17
| | | | | | When a unit was started with "systemctl --user" and it failed, error messages is printed as "systemctl status". But it should be "systemctl --user status".
* shared: include what we useThomas Hindoe Paaboel Andersen2017-05-17
| | | | | The next step of a general cleanup of our includes. This one mostly adds missing includes but there are a few removals as well.
* acl-util: only set the mask if not presentZbigniew Jędrzejewski-Szmek2017-05-17
| | | | | | | | | | | | | | | | | When we have non-owner user or group entries, we need the mask for the acl to be valid. But acl_calc_mask() calculates the mask to include all permissions, even those that were masked before. Apparently this happens when we inherit *:r-x permissions from a parent directory — the kernel sets *:r-x, mask:r--, effectively masking the executable bit. acl_calc_mask() would set the mask:r-x, effectively enabling the bit. To avoid this, be more conservative when to add the mask entry: first iterate over all entries, and do nothing if a mask. This returns the code closer to J.A.Steffens' original version in v204-90-g23ad4dd884. Should fix https://github.com/elogind/elogind/issues/1977.
* core: expose soft limits on the busEvgeny Vereshchagin2017-05-17
| | | | | | This is a follow-up for https://github.com/elogind/elogind/pull/1994 See https://github.com/elogind/elogind/pull/1994#issuecomment-160087219
* core: rename Random* to RandomizedDelay*Zbigniew Jędrzejewski-Szmek2017-05-17
| | | | | | | 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.
* tree-wide: sort includes in *.hThomas Hindoe Paaboel Andersen2017-05-17
| | | | | This is a continuation of the previous include sort patch, which only sorted for .c files.