Commit Graph

26810 Commits

Author SHA1 Message Date
Lennart Poettering 2c5f295823 update TODO 2016-08-22 17:31:41 +02:00
Lennart Poettering 70cb8b7b16 sd-bus: add a small test case for sd_bus_track
This tests in particular that disconnecting results in the tracking object's
handlers to be called.
2016-08-22 17:31:36 +02:00
Lennart Poettering 232f367766 sd-bus: when the server-side disconnects, make sure to dispatch all tracking objects immediately
If the server side kicks us from the bus, from our view no names are on the bus
anymore, hence let's make sure to dispatch all tracking objects immediately.
2016-08-22 17:31:36 +02:00
Lennart Poettering 8b6e65ac32 sd-bus: ensure we don't dispatch track objects while we are adding names to them
In order to add a name to a bus tracking object we need to do some bus
operations: we need to check if the name already exists and add match for it.
Both are synchronous bus calls. While processing those we need to make sure
that the tracking object is not dispatched yet, as it might still be empty, but
is not going to be empty for very long.

hence, block dispatching by removing the object from the dispatch queue while
adding it, and readding it on error.
2016-08-22 16:14:21 +02:00
Lennart Poettering 217fcc7eb3 sd-bus: split out handling of reply callbacks on close into its own function
When a bus connection is closed we dispatch all reply callbacks. Do so in a new
function if its own.

No behaviour changes.
2016-08-22 16:14:21 +02:00
Lennart Poettering 390bc2b149 core: let's use set_contains() where appropriate 2016-08-22 16:14:21 +02:00
Lennart Poettering 014c4c98ba man: document the new --wait switch of systemd-run
Also, make major improvements to the an page in general.
2016-08-22 16:14:21 +02:00
Lennart Poettering 2a453c2ee3 run: optionally, wait for the service to finish and show its result 2016-08-22 16:14:21 +02:00
Lennart Poettering fe700f46ec core: cache last CPU usage counter, before destorying a cgroup
It is useful for clients to be able to read the last CPU usage counter value of
a unit even if the unit is already terminated. Hence, before destroying a
cgroup's cgroup cache the last CPU usage counter and return it if the cgroup is
gone.
2016-08-22 16:14:21 +02:00
Lennart Poettering 8b3b6f588c bus-util: make sure map_basic() returns EOPNOTSUPP if called for an unknown type
Make sure we return proper errors for types not understood yet.
2016-08-22 16:14:21 +02:00
Lennart Poettering 0b83b8a4dc bus-util: treat an empty string as a NULL
Instead of ignoring empty strings retrieved via the bus, treat them as NULL, as
it's customary in systemd.
2016-08-22 16:14:21 +02:00
Lennart Poettering bdf97b8ad8 bus-util: support mapping signed integers with bus_map_properties()
Let's make sure we can read the exit code/status properties exposed by PID 1
properly. Let's reuse the existing code for unsigned fields, as we just use it
to copy words around, and don't calculate it.
2016-08-22 16:14:21 +02:00
Lennart Poettering 05a98afd3e core: add Ref()/Unref() bus calls for units
This adds two (privileged) bus calls Ref() and Unref() to the Unit interface.
The two calls may be used by clients to pin a unit into memory, so that various
runtime properties aren't flushed out by the automatic GC. This is necessary
to permit clients to race-freely acquire runtime results (such as process exit
status/code or accumulated CPU time) on successful service termination.

Ref() and Unref() are fully recursive, hence act like the usual reference
counting concept in C. Taking a reference is a privileged operation, as this
allows pinning units into memory which consumes resources.

Transient units may also gain a reference at the time of creation, via the new
AddRef property (that is only defined for transient units at the time of
creation).
2016-08-22 16:14:21 +02:00
Lennart Poettering ecddb2b586 man: document sd_bus_track objects
And while ware at it, also drop some references to kdbus, and stop claiming
sd-bus wasn't stable yet. Also order man page references in the main sd-bus man
page alphabetically.
2016-08-22 14:17:24 +02:00
Lennart Poettering ae1a2efa8b sd-bus: add a "recursive" mode to sd_bus_track
This adds an optional "recursive" counting mode to sd_bus_track. If enabled
adding the same name multiple times to an sd_bus_track object is counted
individually, so that it also has to be removed the same number of times before
it is gone again from the tracking object.

This functionality is useful for implementing local ref counted objects that
peers make take references on.
2016-08-22 14:17:24 +02:00
Lennart Poettering 512e3bbce6 man: don't claim arguments where const that actually are not 2016-08-22 14:17:24 +02:00
Lennart Poettering 4a4485ae69 seccomp: make sure getrlimit() is among the default permitted syscalls
A lot of basic code wants to know the stack size, and it is safe if they do,
hence let's permit getrlimit() (but not setrlimit()) by default.

See: #3970
2016-08-22 14:17:23 +02:00
0xAX 05b4d3b55c mount-tool: return 0 instead of NULL in the acquire_description() (#4009)
to prevent:

src/mount/mount-tool.c: In function ‘acquire_description’:
src/mount/mount-tool.c:728:24: warning: return makes integer from pointer without a cast [-Wint-conversion]
                 return NULL;
                                         ^~~~
warning.

Additionally we don't set Description property in a case when
arg_description is NULL.
2016-08-22 02:14:23 -04:00
Peter Hutterer df35bfaa25 hwdb: provide axis ranges for the Dell XPS M1530 (#4016)
https://bugs.freedesktop.org/show_bug.cgi?id=97433
2016-08-21 19:31:25 -04:00
Zbigniew Jędrzejewski-Szmek b68d26b8cd networkd: fix typo (#4013) 2016-08-21 19:15:26 +02:00
Zbigniew Jędrzejewski-Szmek 047d91f9c8 shared/install: do not enable masked instances (#4005)
When told to enable a template unit, and the DefaultInstance specified in that
unit was masked, we would do this. Such a unit cannot be started or loaded, so
reporting successful enabling is misleading and unexpected.

$ systemctl mask getty@tty1
Created symlink /etc/systemd/system/getty@tty1.service → /dev/null.
$ systemctl --root=/ enable getty@tty1
(unchanged)
Failed to enable unit, unit /etc/systemd/system/getty@tty1.service is masked.

$ systemctl --root=/ enable getty@
(before)
Created symlink /etc/systemd/system/getty.target.wants/getty@tty1.service → /usr/lib/systemd/system/getty@.service.
(now)
Failed to enable unit, unit /etc/systemd/system/getty@tty1.service is masked.

The same error is emitted for enable and preset. And an error is emmited, not a
warning, so the failure to enable DefaultInstance is treated the same as if the
instance was specified on the command line. I think that this makes most sense,
for most template units.

Fixes #2513.
2016-08-21 15:10:51 +02:00
Zbigniew Jędrzejewski-Szmek 47d2d30d83 networkd: limit the number of routes to the kernel limit (#4007)
Fixes #3922.
2016-08-21 15:06:28 +02:00
Seraphime e3fc2b025e machinectl: print OS release in `machinectl list` (#3975) 2016-08-20 23:39:07 -04:00
Ronny Chevalier baab47d7b9 Merge pull request #4001 from clintonroy/master
systemctl: kill all units specified on the command line, not just the…
2016-08-20 11:42:24 +02:00
Zbigniew Jędrzejewski-Szmek 2056ec1927 Merge pull request #3965 from htejun/systemd-controller-on-unified 2016-08-19 19:58:01 -04:00
Clinton Roy 169d7fb684 systemctl: kill all units specified on the command line, not just the first one. 2016-08-20 08:59:02 +10:00
0xAX e6c9fa74a5 terminal-util: remove unnecessary check of result of isatty() (#4000)
After the call of the isatty() we check its result twice in the
open_terminal(). There are no sense to check result of isatty() that
it is less than zero and return -errno, because as described in
documentation:

isatty() returns 1 if fd is an open file descriptor referring to a
terminal;  otherwise 0 is returned, and errno is set to indicate the
error.

So it can't be less than zero.
2016-08-19 18:51:54 -04:00
Evgeny Vereshchagin 29272c04a7 Merge pull request #3909 from poettering/mount-tool
add a new tool for creating transient mount and automount units
2016-08-19 23:33:49 +03:00
Lennart Poettering 16d901e251 Merge pull request #3987 from keszybz/console-color-setup
Rework console color setup
2016-08-19 19:36:09 +02:00
Lennart Poettering a457bd26cc Merge pull request #3955 from keszybz/fix-preset-all
Fix preset-all
2016-08-19 19:10:30 +02:00
Lennart Poettering dc9710ae23 Merge pull request #3961 from keszybz/pr/3924
Add documentation to #3924
2016-08-19 19:08:41 +02:00
Lennart Poettering fb1bad9d51 man: document that "systemctl switch-root" tries hard to pass state across (#3995)
As suggested:

https://github.com/systemd/systemd/pull/3958#issuecomment-240410958

Let's document that we try hard to pass system state from the initrd to the
host, and even compare the systemd binary paths.
2016-08-19 12:16:28 -04:00
Zbigniew Jędrzejewski-Szmek 906e79ebf5 Merge pull request #3997 from poettering/codition-udev-fix
Trivial fixes to udev and condition tests
2016-08-19 12:13:44 -04:00
Zbigniew Jędrzejewski-Szmek acf553b04d terminal-util: use getenv_bool for $SYSTEMD_COLORS
This changes the semantics a bit: before, SYSTEMD_COLORS= would be treated as
"yes", same as SYSTEMD_COLORS=xxx and SYSTEMD_COLORS=1, and only
SYSTEMD_COLORS=0 would be treated as "no". Now, only valid booleans are treated
as "yes". This actually matches how $SYSTEMD_COLORS was announced in NEWS.
2016-08-19 11:57:37 -04:00
Zbigniew Jędrzejewski-Szmek 158fbf7661 systemd: ignore lack of tty when checking whether colors should be enabled
When started by the kernel, we are connected to the console, and we'll set TERM
properly to some value in fixup_environment(). We'll then enable or disable
colors based on the value of $SYSTEMD_COLORS and $TERM.

When reexecuting, TERM should be already set, so we can use this value.
Effectively, behaviour is the same as before affd7ed1a was reverted, but instead
of reopening the console before configuring color output, we just ignore what
stdout is connected to and decide based on the variables only.
2016-08-19 11:34:22 -04:00
Ronny Chevalier 3f94fa378e Merge pull request #3992 from poettering/hostname-fix2
some hostname fixes, triggered by #3979
2016-08-19 16:46:49 +02:00
Lennart Poettering d3fc8bf43f tests: let's stick to 8ch indenting, in perl code too 2016-08-19 16:01:17 +02:00
Lennart Poettering 4d548a7d86 test: always check whether condition allocation worked
Our tests should test for OOM too explicitly, hence fix the test accordingly
2016-08-19 16:00:51 +02:00
Zbigniew Jędrzejewski-Szmek f165171513 shared/install: properly report masked units listed in Also=
A masked unit is listed in Also=:

$ systemctl cat test1 test2
→# /etc/systemd/system/test1.service
[Unit]
Description=test service 1

[Service]
Type=oneshot
ExecStart=/usr/bin/true

[Install]
WantedBy=multi-user.target
Also=test2.service
Alias=alias1.service

→# /dev/null

$ systemctl --root=/ enable test1
(before)
Created symlink /etc/systemd/system/alias1.service → /etc/systemd/system/test1.service.
Created symlink /etc/systemd/system/multi-user.target.wants/test1.service → /etc/systemd/system/test1.service.
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.

(after)
Created symlink /etc/systemd/system/alias1.service → /etc/systemd/system/test1.service.
Created symlink /etc/systemd/system/multi-user.target.wants/test1.service → /etc/systemd/system/test1.service.
Unit /etc/systemd/system/test2.service is masked, ignoring.
2016-08-19 09:55:56 -04:00
Zbigniew Jędrzejewski-Szmek de78fa9ba0 units: install user units as real files, not symlinks to ../system/
This was causing preset-all --global to create symlinks:

$ systemctl preset-all --global --root=/var/tmp/inst1
Created symlink /var/tmp/inst1/etc/systemd/user/shutdown.target → /usr/lib/systemd/user/../system/shutdown.target.
Created symlink /var/tmp/inst1/etc/systemd/user/sockets.target → /usr/lib/systemd/user/../system/sockets.target.
Created symlink /var/tmp/inst1/etc/systemd/user/timers.target → /usr/lib/systemd/user/../system/timers.target.
Created symlink /var/tmp/inst1/etc/systemd/user/paths.target → /usr/lib/systemd/user/../system/paths.target.
Created symlink /var/tmp/inst1/etc/systemd/user/bluetooth.target → /usr/lib/systemd/user/../system/bluetooth.target.
Created symlink /var/tmp/inst1/etc/systemd/user/printer.target → /usr/lib/systemd/user/../system/printer.target.
Created symlink /var/tmp/inst1/etc/systemd/user/sound.target → /usr/lib/systemd/user/../system/sound.target.
Created symlink /var/tmp/inst1/etc/systemd/user/smartcard.target → /usr/lib/systemd/user/../system/smartcard.target.
Created symlink /var/tmp/inst1/etc/systemd/user/busnames.target → /usr/lib/systemd/user/../system/busnames.target.

It is better to create units in a state that completely matches the presets, i.e.
preset-all should do nothing when invoked immediately after installation.

I'm sure it was confusing to users too, suggesting that system and user units
may somehow alias each other.
2016-08-19 09:55:55 -04:00
Zbigniew Jędrzejewski-Szmek 0064dcc0fc units: synchronize Makefile and presets settings
Enable reboot.target and disable exit.target: the first is used on normal
machines, the second only in containers, and the more general one
should be enabled by default.

Also fix the Makefile to match what preset-all does.

With this and the previous commits, doing "make instal DESTDIR=…" followed
by "systemctl preset-all --root=…" doesn't result in any changes.
2016-08-19 09:55:55 -04:00
Zbigniew Jędrzejewski-Szmek 58a6dd1558 units: enable systemd-networkd-wait-online.service, disable all journal-remote stuff
The preset for systemd-networkd-wait-online.service should match
whatever we do for systemd-networkd.service. s-n-wait-online.service
is only pulled in when some other unit pulls in network-online.target,
otherwise it's not used. But if something pulls in network-online.target,
they should expect s-n-wait-online.service to be active iff
systemd-networkd.service is active.

OTOH, the journal-remote and journal-upload services should be disabled
by default, since they don't do anything without additional configuration.
2016-08-19 09:55:55 -04:00
Zbigniew Jędrzejewski-Szmek 25ea92778d shared/install: when creating symlinks, keep existing relative symlinks
Running preset-all on a system installed from rpms or even created
using make install would remove and recreate a lot of symlinks, changing
relative to absolute symlinks. In general relative symlinks are nicer,
so there is no reason to change them, and those spurious changes were
obscuring more interesting stuff.

$ make install DESTDIR=/var/tmp/inst1

$ systemctl preset-all --root=/var/tmp/inst1
(before)
Removed /var/tmp/inst1/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service.
Created symlink /var/tmp/inst1/etc/systemd/system/ctrl-alt-del.target → /usr/lib/systemd/system/exit.target.
Removed /var/tmp/inst1/etc/systemd/system/multi-user.target.wants/remote-fs.target.
Created symlink /var/tmp/inst1/etc/systemd/system/multi-user.target.wants/remote-fs.target → /usr/lib/systemd/system/remote-fs.target.
Created symlink /var/tmp/inst1/etc/systemd/system/multi-user.target.wants/machines.target → /usr/lib/systemd/system/machines.target.
Created symlink /var/tmp/inst1/etc/systemd/system/sockets.target.wants/systemd-journal-remote.socket → /usr/lib/systemd/system/systemd-journal-remote.socket.
Removed /var/tmp/inst1/etc/systemd/system/sockets.target.wants/systemd-networkd.socket.
Created symlink /var/tmp/inst1/etc/systemd/system/sockets.target.wants/systemd-networkd.socket → /usr/lib/systemd/system/systemd-networkd.socket.
Removed /var/tmp/inst1/etc/systemd/system/getty.target.wants/getty@tty1.service.
Created symlink /var/tmp/inst1/etc/systemd/system/getty.target.wants/getty@tty1.service → /usr/lib/systemd/system/getty@.service.
Created symlink /var/tmp/inst1/etc/systemd/system/multi-user.target.wants/systemd-journal-upload.service → /usr/lib/systemd/system/systemd-journal-upload.service.
Removed /var/tmp/inst1/etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service.
Created symlink /var/tmp/inst1/etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service → /usr/lib/systemd/system/systemd-timesyncd.service.
Removed /var/tmp/inst1/etc/systemd/system/multi-user.target.wants/systemd-resolved.service.
Created symlink /var/tmp/inst1/etc/systemd/system/multi-user.target.wants/systemd-resolved.service → /usr/lib/systemd/system/systemd-resolved.service.
Removed /var/tmp/inst1/etc/systemd/system/multi-user.target.wants/systemd-networkd.service.
Created symlink /var/tmp/inst1/etc/systemd/system/multi-user.target.wants/systemd-networkd.service → /usr/lib/systemd/system/systemd-networkd.service.

(after)
Removed /var/tmp/inst1/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service.
Created symlink /var/tmp/inst1/etc/systemd/system/ctrl-alt-del.target → /usr/lib/systemd/system/exit.target.
Created symlink /var/tmp/inst1/etc/systemd/system/multi-user.target.wants/machines.target → /usr/lib/systemd/system/machines.target.
Created symlink /var/tmp/inst1/etc/systemd/system/sockets.target.wants/systemd-journal-remote.socket → /usr/lib/systemd/system/systemd-journal-remote.socket.
Created symlink /var/tmp/inst1/etc/systemd/system/multi-user.target.wants/systemd-journal-upload.service → /usr/lib/systemd/system/systemd-journal-upload.service.
2016-08-19 09:55:54 -04:00
Zbigniew Jędrzejewski-Szmek 60bec8e403 shared/install: move root skipping into create_symlink()
No functional change intended.
2016-08-19 09:55:54 -04:00
Zbigniew Jędrzejewski-Szmek d923e42eed man: describe what symlinks to unit do, and specify that presets must use real names
The man pages didn't ever mention that symlinks to units can be created, and what
exactly this means. Fix that omission, and disallow presets on alias names.
2016-08-19 09:55:54 -04:00
Zbigniew Jędrzejewski-Szmek 11e11fd57a shared/install: ignore unit symlinks when doing preset-all
Before, when interating over unit files during preset-all, behaviour was the
following:

- if we hit the real unit name first, presets were queried for that name, and
  that unit was enabled or disabled accordingly,

- if we hit an alias first (one of the symlinks chaining to the real unit), we
  checked the presets using the symlink name, and then proceeded to enable or
  disable the real unit.

E.g. for systemd-networkd.service we have the alias dbus-org.freedesktop.network1.service
(/usr/lib/systemd/system/dbus-org.freedesktop.network1.service), but the preset
is only for the systemd-networkd.service name. The service would be enabled or
disabled pseudorandomly depending on the order of iteration.

For "preset", behaviour was analogous: preset on the alias name disabled the
service (following the default disable policy), preset on the "real" name
applied the presets.

With the patch, for "preset" and "preset-all" we silently skip symlinks. This
gives mostly the right behaviour, with the limitation that presets on aliases
are ignored.  I think that presets on aliases are not that common (at least my
preset files on Fedora don't exhibit any such usage), and should not be
necessary, since whoever installs the preset can just refer to the real unit
file. It would be possible to overcome this limitation by gathering a list of
names of a unit first, and then checking whether *any* of the names matches the
presets list. That would require a significant redesign of the code, and be
a lot slower (since we would have to fully read all unit directories to preset
one unit) to so I'm not doing that for now.

With this patch, two properties are satisfied:
- preset-all and preset are idempotent, and the second and subsequent invocations
  do not produce any changes,
- preset-all and preset for a specific name produce the same state for that unit.

Fixes #3616.
2016-08-19 09:55:54 -04:00
Zbigniew Jędrzejewski-Szmek ff56349d5a shared/install: remove unused paramater and add more comments 2016-08-19 09:55:53 -04:00
Zbigniew Jędrzejewski-Szmek 32d9493e59 systemctl: fix preset-all with missing /etc/systemd/system
If the directory is missing, we can assume that those pesky symlinks are gone too.
2016-08-19 09:55:53 -04:00
Lennart Poettering a6a8e60bd3 hwdb: let's no abbreivate HORIZONTAL as HORIZ (#3994)
I think I am developing OCD... Let's fix this before this actually gets used in
the wild.

A follow-up for #3986 (5fc9e4abb4).
2016-08-19 15:31:36 +02:00
Lennart Poettering 986cf85d94 man: minor wording fixes 2016-08-19 11:04:13 +02:00