summaryrefslogtreecommitdiff
path: root/src/shared
AgeCommit message (Collapse)Author
2016-05-03Merge pull request #3183 from crawford/preset-arrayZbigniew Jędrzejewski-Szmek
install: cache the presets before evaluating
2016-05-03install: cache the presets before evaluatingAlex Crawford
The previous implementation traversed the various config directories, walking the preset files and parsing each line to determine if a service should be enabled or disabled. It did this for every service which resulted in many more file operations than neccessary. This approach parses each of the preset entries into an array which is then used to check if each service should be enabled or disabled.
2016-05-02Merge pull request #3162 from keszybz/alias-refusalLennart Poettering
Refuse Alias, DefaultInstance, templated units in install (as appropriate)
2016-05-02machined: support non-btrfs file systems with "machinectl clone"Lennart Poettering
Fall back to a normal copy operation when the backing file system isn't btrfs, and hence doesn't support cheap snapshotting. Of course, this will be slow, but given that the execution is asynchronous now, this should be OK. Fixes: #1308
2016-05-02tree-wide: fix invocations of chattr_path()Lennart Poettering
chattr_path() takes two bitmasks, and no booleans. Fix the various invocations to do this properly.
2016-05-02image: enable btrfs quotas on the clone destination, not the sourceLennart Poettering
2016-05-01shared/install: refuse template files for non-templateable unitsZbigniew Jędrzejewski-Szmek
$ systemctl --root=/ enable templated@bar.mount Unit type mount cannot be templated. Failed to enable: Invalid argument.
2016-05-01shared/install: warn about DefaultInstance in non-template unitsZbigniew Jędrzejewski-Szmek
[/etc/systemd/system/mnt-test.mount:6] DefaultInstance only makes sense for template units, ignoring.
2016-05-01Move no_instances information to shared/Zbigniew Jędrzejewski-Szmek
This way it can be used in install.c in subsequent commit.
2016-05-01shared/install: ignore Alias in [Install] of units which don't allow aliasesZbigniew Jędrzejewski-Szmek
A downside is that a warning about missing [Install] is printed: $ systemctl --root=/ enable mnt-test.mount [/etc/systemd/system/mnt-test.mount:5] Aliases are not allowed for mount units, ignoring. The unit files have no installation config (WantedBy, RequiredBy, Also, Alias settings in the [Install] section, and DefaultInstance for template units). This means they are not meant to be enabled using systemctl. Possible reasons for having this kind of units are: 1) A unit may be statically enabled by being symlinked from another unit's .wants/ or .requires/ directory. 2) A unit's purpose may be to act as a helper for some other unit which has a requirement dependency on it. 3) A unit may be started when needed via activation (socket, path, timer, D-Bus, udev, scripted systemctl call, ...). 4) In case of template units, the unit is meant to be enabled with some instance name specified. That's a bit misleading, but I don't see an easy way to fix this. But the situation is similar for many other parsing errors, so maybe that's OK.
2016-05-01Move no_alias information to shared/Zbigniew Jędrzejewski-Szmek
This way it can be used in install.c in subsequent commit.
2016-04-30core: bus_append_unit_property_assignment() was using the wrong parse functionTejun Heo
It was incorrectly using cg_cpu_weight_parse() to parse BlockIOWeight. Update it to use cg_blkio_weight_parse() instead. Signed-off-by: Tejun Heo <htejun@fb.com>
2016-04-29core: Filter by unit name behind the D-Bus, instead on the client side (#3142)kayrus
This commit improves systemd performance on the systems which have thousands of units.
2016-04-28install: upgrade message to a warningAlex Crawford
2016-04-28tree-wide: rename hidden_file to hidden_or_backup_file and optimizeZbigniew Jędrzejewski-Szmek
In standard linux parlance, "hidden" usually means that the file name starts with ".", and nothing else. Rename the function to convey what the function does better to casual readers. Stop exposing hidden_file_allow_backup which is rather ugly and rewrite hidden_file to extract the suffix first. Note that hidden_file_allow_backup excluded files with "~" at the end, which is quite confusing. Let's get rid of it before it gets used in the wrong place.
2016-04-26journal: when dumping journal contents, react nicer to lines we can't readLennart Poettering
If journal files are not cleanly closed it might happen that intermediaery journal entries cannot be read. Handle this nicely, skip over the unreadable entries, and log a debug message about it; after all we generally follow the logic that we try to make the best of corrupted files.
2016-04-25core: fix description of "resources" service error (#3119)Lennart Poettering
The "resources" error is really just the generic error we return when we hit some kind of error and we have no more appropriate error for the case to return, for example because of some OS error. Hence, reword the explanation and don't claim any relation to resource limits. Admittedly, the "resources" service error is a bit of a misnomer, but I figure it's kind of API now. Fixes: #2716
2016-04-22journalctl: add --no-hostname switchLennart Poettering
This suppresses output of the hostname for messages from the local system. Fixes: #2342
2016-04-22journalctl: add output mode where time is shown in seconds since 1st Jan ↵Lennart Poettering
1970 UTC aka "UNIX time". Fixes: #2120
2016-04-22shared: move output_mode_to_string() into output-mode.cLennart Poettering
After all, the enum definition is in output-mode.h
2016-04-22path-lookup: optimize a common strv copy operation awayLennart Poettering
Follow-up for: https://github.com/systemd/systemd/pull/3033#discussion_r59689398
2016-04-22shared: move unit-specific code from bus-util.h to bus-unit-util.hLennart Poettering
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.
2016-04-22shared: drop kernel_thread bool from cgroups show codeLennart Poettering
Make this an output flag instead, so that our function prototypes can lose one parameter
2016-04-22core,systemctl: add bus API to retrieve processes of a unitLennart Poettering
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
2016-04-22shared: fix minor memory leak in log display codeLennart Poettering
2016-04-22treewide: fix typos (#3092)Torstein Husebø
2016-04-22Merge pull request #3084 from keszybz/preset-fixesLennart Poettering
Nicer error message is symlinking chokes on an existing file
2016-04-21shared/install: always overwrite symlinks in .wants and .requiresZbigniew Jędrzejewski-Szmek
Before: $ systemctl preset getty@.service Failed to preset unit, file /etc/systemd/system/getty.target.wants/getty@tty1.service already exists and is a symlink to ../../../../usr/lib/systemd/system/getty@.service. After: $ systemctl preset getty@.service Created symlink /etc/systemd/system/getty.target.wants/getty@tty1.service, pointing to /usr/lib/systemd/system/getty@.service. We don't really care where the symlink points to. For example, it might point to /usr/lib or /etc, and systemd will always load the unit from /etc in preference to /usr/lib. In fact, if we make a symlink like /etc/systemd/system/multi-user.target.wants/b.service -> ../a.service, pid1 will still start b.service. The name of the symlink is the only thing that matters, as far as systemd is concerned. For humans it's confusing when the symlinks points to anything else than the actual unit file. At the very least, the symlink is supposed to point to a file with the same name in some other directory. Since we don't care where the symlink points, we can always replace an existing symlink. Another option I considered would be to simply leave an existing symlink in place. That would work too, but replacing the symlink with the expected value seems more intuitive. Of course those considerations only apply to .wants and .requires. Symlinks created with "link" and "alias" are a separate matter. Fixes #3056.
2016-04-21shared/install: rewrite unit_file_changes_add()Zbigniew Jędrzejewski-Szmek
path_kill_slashes was applied to the wrong arg...
2016-04-21shared/install: nicer error message is symlinking chokes on an existing fileZbigniew Jędrzejewski-Szmek
Fixes #1892. Previously: Failed to enable unit: Invalid argument Now: Failed to enable unit, file /etc/systemd/system/ssh.service already exists. It would be nice to include the unit name in the message too. I looked into this, but it would require major surgery on the whole installation logic, because we first create a list of things to change, and then try to apply them in a loop. To transfer the knowledge which unit was the source of each change, the data structures would have to be extended to carry the unit name over into the second loop. So I'm skipping this for now.
2016-04-21Merge pull request #3005 from keszybz/kill-user-procesesLennart Poettering
Kill user session scope by default
2016-04-21shared/logs-show: fix memleak in add_matches_for_unitZbigniew Jędrzejewski-Szmek
2016-04-19Merge pull request #3055 from keszybz/preset-fixesLennart Poettering
Another bunch of improvements to the installation code
2016-04-19systemctl: warning about missing install info for template unitsZbigniew Jędrzejewski-Szmek
The advice string didn't talk about template units at all. Extend it and print when trying to enable a template unit without install info. Fixes #2345.
2016-04-19shared/install: change value of _UNIT_FILE_CHANGE_TYPE_INVALIDZbigniew Jędrzejewski-Szmek
-1 could be confused with -EPERM. But we still need a negative enum value to force gcc to use int for the enum type, even though it is unused. Otherwise we get warnings.
2016-04-19shared/install,systemctl,core: report offending file on installation errorZbigniew Jędrzejewski-Szmek
Fixes #2191: $ systemctl --root=/ enable sddm Created symlink /etc/systemd/system/display-manager.service, pointing to /usr/lib/systemd/system/sddm.service. $ sudo build/systemctl --root=/ enable gdm Failed to enable unit, file /etc/systemd/system/display-manager.service already exists and is a symlink to /usr/lib/systemd/system/sddm.service. $ sudo build/systemctl --root= enable sddm $ sudo build/systemctl --root= enable gdm Failed to enable unit: File /etc/systemd/system/display-manager.service already exists and is a symlink to /usr/lib/systemd/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.
2016-04-19sleep: Add debug feature to bypass hibernation memory checks. (#3064)Vittorio G (VittGam)
This new feature bypasses checking if a swap partition is mounted or if there is enough swap space available for hibernation to succeed. This can be useful when a system with a Solid State Disk (SSD) has no normal swap partition or file configured, and a custom systemd unit is used to mount a swap file just before hibernating and unmount it just after resuming. Signed-off-by: Vittorio Gambaletta <git-systemd@vittgam.net>
2016-04-18shared/install: add helper function unit_file_changes_have_modification()Zbigniew Jędrzejewski-Szmek
As suggested in review of #3049.
2016-04-18Various formatting and style fixesZbigniew Jędrzejewski-Szmek
2016-04-17conf-parser: Set EXTRACT_RETAIN_ESCAPE when extracting words (#2917)Dan Nicholson
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/systemd/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/systemd/system/dev-disk-byx2dlabel-eosx2dswap.device.wants/dev-disk-by\x2dlabel-eos\x2dswap.swap, pointing to /usr/lib/systemd/system/dev-disk-by\x2dlabel-eos\x2dswap.swap. The wants directory should be created with the x2ds escaped with \.
2016-04-16install: allow paths like LookupPath.generator to be NULLZbigniew Jędrzejewski-Szmek
Fixes #3047.
2016-04-16systemctl/core: ignore masked units in preset-allZbigniew Jędrzejewski-Szmek
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.
2016-04-16tree-wide: use ERFKILL instead of ESHUTDOWN for "unit masked"Zbigniew Jędrzejewski-Szmek
If the error code ever leaks (we print the strerror error instead of providing our own), the message for ESHUTDOWN is "Cannot send after transport endpoint shutdown", which can be misleading. In particular it suggest that some mishandling of the dbus connection occured. Let's change that to ERFKILL which has the advantage that a) it sounds implausible as actual error, b) has the connotation of disabling something manually.
2016-04-13shared/path-lookup: fix leakZbigniew Jędrzejewski-Szmek
CID #1354671: char **l would be leaked. Also rename l to paths, to make the code easier to read, and do strv deduplication immediately when extending. No need to allocate strings to remove them a few lines down.
2016-04-13tree-wide: remove useless NULLs from strjoinaZbigniew Jędrzejewski-Szmek
The coccinelle patch didn't work in some places, I have no idea why.
2016-04-12machinectl: add new "machinectl clean" commandLennart Poettering
This new command removes all, or all hidden container images that have been downloaded.
2016-04-12tests: override XDG_RUNTIME_DIR where we use the user runtime dirLennart Poettering
We don#t really support systems where XDG_RUNTIME_DIR is not supported for systemd --user. Hence, let's always set our own XDG_RUNTIME_DIR for tests that involve systemd --user, so that we know it is set, and that it doesn't polute the user's actual runtime dir.
2016-04-12core,systemctl: add new "systemctl revert" commandLennart Poettering
This allows dropping all user configuration and reverting back to the vendor default of a unit file. It basically undoes what "systemctl edit", "systemctl set-property" and "systemctl mask" do.
2016-04-12install: fix errno handlingLennart Poettering
2016-04-12install: simplify skip_root() a bitLennart Poettering
Exit early, so that we can get rid of the large if block.