chiark / gitweb /
elogind.git
6 years agoman: Document return value of event source prepare callback (#4834)
Martin Ejdestig [Mon, 5 Dec 2016 22:42:41 +0000 (23:42 +0100)]
man: Document return value of event source prepare callback (#4834)

6 years agoModify mount_propagation_flags_from_string to return a normal int code
Zbigniew Jędrzejewski-Szmek [Sat, 3 Dec 2016 18:57:42 +0000 (13:57 -0500)]
Modify mount_propagation_flags_from_string to return a normal int code

This means that callers can distiguish an error from flags==0,
and don't have to special-case the empty string.

6 years agoutil-lib: drop unnecessary NULL check
Lennart Poettering [Fri, 2 Dec 2016 16:01:19 +0000 (17:01 +0100)]
util-lib: drop unnecessary NULL check

DEFINE_TRIVIAL_CLEANUP_FUNC() already does that check, no need to duplicate it.

6 years agocgroup: properly check for ignore-notfound paths (#4803)
Dave Reisner [Fri, 2 Dec 2016 14:23:23 +0000 (09:23 -0500)]
cgroup: properly check for ignore-notfound paths (#4803)

Follow-up to #4687 and e7330dfe14b1965f.

6 years agocore: store the invocation ID in the per-service keyring
Lennart Poettering [Fri, 2 Dec 2016 14:05:55 +0000 (15:05 +0100)]
core: store the invocation ID in the per-service keyring

Let's store the invocation ID in the per-service keyring as a root-owned key,
with strict access rights. This has the advantage over the environment-based ID
passing that it also works from SUID binaries (as they key cannot be overidden
by unprivileged code starting them), in contrast to the secure_getenv() based
mode.

The invocation ID is now passed in three different ways to a service:

- As environment variable $INVOCATION_ID. This is easy to use, but may be
  overriden by unprivileged code (which might be a bad or a good thing), which
  means it's incompatible with SUID code (see above).

- As extended attribute on the service cgroup. This cannot be overriden by
  unprivileged code, and may be queried safely from "outside" of a service.
  However, it is incompatible with containers right now, as unprivileged
  containers generally cannot set xattrs on cgroupfs.

- As "invocation_id" key in the kernel keyring. This has the benefit that the
  key cannot be changed by unprivileged service code, and thus is safe to
  access from SUID code (see above). But do note that service code can replace
  the session keyring with a fresh one that lacks the key. However in that case
  the key will not be owned by root, which is easily detectable. The keyring is
  also incompatible with containers right now, as it is not properly namespace
  aware (but this is being worked on), and thus most container managers mask
  the keyring-related system calls.

Ideally we'd only have one way to pass the invocation ID, but the different
ways all have limitations. The invocation ID hookup in journald is currently
only available on the host but not in containers, due to the mentioned
limitations.

How to verify the new invocation ID in the keyring:

 # elogind-run -t /bin/sh
 Running as unit: run-rd917366c04f847b480d486017f7239d6.service
 Press ^] three times within 1s to disconnect TTY.
 # keyctl show
 Session Keyring
  680208392 --alswrv      0     0  keyring: _ses
  250926536 ----s-rv      0     0   \_ user: invocation_id
 # keyctl request user invocation_id
 250926536
 # keyctl read 250926536
 16 bytes of data in key:
 9c96317c ac64495a a42b9cd7 4f3ff96b
 # echo $INVOCATION_ID
 9c96317cac64495aa42b9cd74f3ff96b
 # ^D

This creates a new transient service runnint a shell. Then verifies the
contents of the keyring, requests the invocation ID key, and reads its payload.
For comparison the invocation ID as passed via the environment variable is also
displayed.

6 years agocore: run each system service with a fresh session keyring
Lennart Poettering [Fri, 2 Dec 2016 00:54:41 +0000 (01:54 +0100)]
core: run each system service with a fresh session keyring

This patch ensures that each system service gets its own session kernel keyring
automatically, and implicitly. Without this a keyring is allocated for it
on-demand, but is then linked with the user's kernel keyring, which is OK
behaviour for logged in users, but not so much for system services.

With this change each service gets a session keyring that is specific to the
service and ceases to exist when the service is shut down. The session keyring
is not linked up with the user keyring and keys hence only search within the
session boundaries by default.

(This is useful in a later commit to store per-service material in the keyring,
for example the invocation ID)

(With input from David Howells)

6 years agoutil-lib: add easy helpers for temporary directories that rmdir()ed via _cleanup_
Lennart Poettering [Thu, 1 Dec 2016 22:19:31 +0000 (23:19 +0100)]
util-lib: add easy helpers for temporary directories that rmdir()ed via _cleanup_

This adds mkdtemp_malloc() that is a combination of mkdtemp() plus strdup(). It
initializes its return paremeter only if the temporary directory could be
created successfully, so that the parameter is exactly non-NULL when the
directory exists.

rmdir_and_free() and rmdir_and_freep() are also added, and the latter may be
used inside of _cleanup_ for such a directory string variable, to automatically
rmdir() the directory if it is non-NULL when the scope exits.

rmdir_and_free() is similar to the existing rm_rf_and_free() however, is only
removes a single directory and does not operate recursively.

6 years agoutil-lib: rename CHASE_NON_EXISTING → CHASE_NONEXISTENT
Lennart Poettering [Thu, 1 Dec 2016 11:49:23 +0000 (12:49 +0100)]
util-lib: rename CHASE_NON_EXISTING → CHASE_NONEXISTENT

As suggested by @keszybz

6 years agocore: rework logic to determine when we decide to add automatic deps for mounts
Lennart Poettering [Tue, 29 Nov 2016 21:50:21 +0000 (22:50 +0100)]
core: rework logic to determine when we decide to add automatic deps for mounts

This adds a concept of "extrinsic" mounts. If mounts are extrinsic we consider
them managed by something else and do not add automatic ordering against
umount.target, local-fs.target, remote-fs.target.

Extrinsic mounts are considered:

- All mounts if we are running in --user mode

- API mounts such as everything below /proc, /sys, /dev, which exist from
  earliest boot to latest shutdown.

- All mounts marked as initrd mounts, if we run on the host

- The initrd's private directory /run/initrams that should survive until last
  reboot.

This primarily merges a couple of different exclusion lists into a single
concept.

6 years agoTwo small cleanups
Zbigniew Jędrzejewski-Szmek [Tue, 29 Nov 2016 19:42:57 +0000 (14:42 -0500)]
Two small cleanups

6 years agocgroup: support prefix "-" in cgroups whitelisting entries (#4687)
Dongsu Park [Tue, 29 Nov 2016 19:16:55 +0000 (20:16 +0100)]
cgroup: support prefix "-" in cgroups whitelisting entries (#4687)

So far elogind-nspawn container has been creating files under
/run/elogind/inaccessible, no matter whether it's running in user
namespace or not. That's fine for regular files, dirs, socks, fifos.
However, it's not for block and character devices, because kernel
doesn't allow them to be created under user namespace. It results
in warnings at booting like that:

====
  Couldn't stat device /run/elogind/inaccessible/chr
  Couldn't stat device /run/elogind/inaccessible/blk
====

Thus we need to have the cgroups whitelisting handler to silently ignore
a file, when the device path is prefixed with "-". That's exactly the
same convention used in directives like ReadOnlyPaths=. Also insert the
prefix "-" to inaccessible entries.

6 years agofs-util: add new CHASE_NON_EXISTING flag to chase_symlinks()
Lennart Poettering [Tue, 29 Nov 2016 17:02:45 +0000 (18:02 +0100)]
fs-util: add new CHASE_NON_EXISTING flag to chase_symlinks()

This new flag controls whether to consider a problem if the referenced path
doesn't actually exist. If specified it's OK if the final file doesn't exist.

Note that this permits one or more final components of the path not to exist,
but these must not contain "../" for safety reasons (or, to be extra safe,
neither "./" and a couple of others, i.e. what path_is_safe() permits).

This new flag is useful when resolving paths before issuing an mkdir() or
open(O_CREAT) on a path, as it permits that the file or directory is created
later.

The return code of chase_symlinks() is changed to return 1 if the file exists,
and 0 if it doesn't. The latter is only returned in case CHASE_NON_EXISTING is
set.

6 years agofs-util: add flags parameter to chase_symlinks()
Lennart Poettering [Tue, 29 Nov 2016 15:49:30 +0000 (16:49 +0100)]
fs-util: add flags parameter to chase_symlinks()

Let's remove chase_symlinks_prefix() and instead introduce a flags parameter to
chase_symlinks(), with a flag CHASE_PREFIX_ROOT that exposes the behaviour of
chase_symlinks_prefix().

6 years agofs-util: change chase_symlinks() behaviour in regards to escaping the root dir
Lennart Poettering [Tue, 29 Nov 2016 14:54:42 +0000 (15:54 +0100)]
fs-util: change chase_symlinks() behaviour in regards to escaping the root dir

Previously, we'd generate an EINVAL error if it is attempted to escape a root
directory with relative ".." symlinks. With this commit this is changed so that
".." from the root directory is a NOP, following the kernel's own behaviour
where /.. is equivalent to /.

As suggested by @keszybz.

6 years agofs-util: add chase_symlinks_prefix() and extend comments
Lennart Poettering [Fri, 25 Nov 2016 17:59:39 +0000 (18:59 +0100)]
fs-util: add chase_symlinks_prefix() and extend comments

chase_symlinks() currently expects a fully qualified, absolute path, relative
to the host's root as first argument. Which is useful in many ways, and similar
to the paths unlink(), rename(), open(), … expect. Sometimes it's however
useful to first prefix the specified path with the specified root directory.
Add a new call chase_symlinks_prefix() for this, that is a simple wrapper.

6 years agoutil: Fine tune running_in_chroot() a bit
Lennart Poettering [Thu, 24 Nov 2016 16:42:19 +0000 (17:42 +0100)]
util: Fine tune running_in_chroot() a bit

Let's be a bit more careful when detecting chroot() environments, so that we
can discern them from namespaced environments.

Previously this would simply check if the root directory of PID 1 matches our
own root directory. With this commit, we also check whether the namespaces of
PID 1 and ourselves are the same. If not we assume we are running inside of a
namespaced environment instead of a chroot() environment.

This has the benefit that systemctl (which uses running_in_chroot()) will work
as usual when invoked in a namespaced service.

6 years agocore: keep supporting cgroup hybrid layout from v232 for live upgrades
Tejun Heo [Wed, 23 Nov 2016 17:27:32 +0000 (12:27 -0500)]
core: keep supporting cgroup hybrid layout from v232 for live upgrades

v232's cgroup hybrid mode mounted v2 on /sys/fs/cgroup/elogind, which
unfortunately broke other tools which expect v1 there.  From v233 on, hybrid
mode instead mounts and uses v2 on /sys/fs/cgroup/unified and keeps
/sys/fs/cgroup/elogind on v1 for compatibility with external tools.  However,
to keep elogind live upgrades working, v233+ should be able to recognize v232
layout and keep using it.

This patch adds v232 hybrid mode support.  If v232 layout is detected,
cg_unified(SYSTEMD_CGRouP_CONTROLLER) keeps returning %true but
cg_hybrid_unified() returns %false.  This keeps process management on cgroup v2
but turns off the parallel layout.

6 years agocore: hook up MountFlags= to the transient unit logic
Lennart Poettering [Tue, 22 Nov 2016 19:19:08 +0000 (20:19 +0100)]
core: hook up MountFlags= to the transient unit logic

This makes "elogind-run -p MountFlags=shared -t /bin/sh" work, by making
MountFlags= to the list of properties that may be accessed transiently.

6 years agosd-event: fix sd_event_source_get_priority() (#4712)
Martin Ejdestig [Tue, 22 Nov 2016 00:21:00 +0000 (01:21 +0100)]
sd-event: fix sd_event_source_get_priority() (#4712)

To properly store priority in passed in pointer and return 0 for success.
Also add a test for verifying that it works correctly.

6 years agocore: make SYSTEMD_CGROUP_CONTROLLER a special string
Tejun Heo [Mon, 21 Nov 2016 19:45:53 +0000 (14:45 -0500)]
core: make SYSTEMD_CGROUP_CONTROLLER a special string

SYSTEMD_CGROUP_CONTROLLER is currently defined as "name=elogind" which cgroup
utility functions interpret as a named cgroup hierarchy with the specified
named.  With the planned cgroup hybrid mode changes, SYSTEMD_CGROUP_CONTROLLER
would map to different hierarchy names.

This patch makes SYSTEMD_CGROUP_CONTROLLER a special string "_elogind" which is
substituted to "name=elogind" by the cgroup utility functions.  This allows the
callers to address the elogind hierarchy without actually specifying the
hierarchy name allowing the cgroup utility functions to map it to whatever is
appropriate.

Note that SYSTEMD_CGROUP_CONTROLLER was already special on full unified cgroup
hierarchy even before this patch.

6 years agocore: simplify cg_[all_]unified()
Tejun Heo [Mon, 21 Nov 2016 19:45:53 +0000 (14:45 -0500)]
core: simplify cg_[all_]unified()

cg_[all_]unified() test whether a specific controller or all controllers are on
the unified hierarchy.  While what's being asked is a simple binary question,
the callers must assume that the functions may fail any time, which
unnecessarily complicates their usages.  This complication is unnecessary.
Internally, the test result is cached anyway and there are only a few places
where the test actually needs to be performed.

This patch simplifies cg_[all_]unified().

* cg_[all_]unified() are updated to return bool.  If the result can't be
  decided, assertion failure is triggered.  Error handlings from their callers
  are dropped.

* cg_unified_flush() is updated to calculate the new result synchrnously and
  return whether it succeeded or not.  Places which need to flush the test
  result are updated to test for failure.  This ensures that all the following
  cg_[all_]unified() tests succeed.

* Places which expected possible cg_[all_]unified() failures are updated to
  call and test cg_unified_flush() before calling cg_[all_]unified().  This
  includes functions used while setting up mounts during boot and
  manager_setup_cgroup().

6 years agocore: make hybrid cgroup unified mode keep compat /sys/fs/cgroup/elogind hierarchy
Tejun Heo [Mon, 21 Nov 2016 19:45:53 +0000 (14:45 -0500)]
core: make hybrid cgroup unified mode keep compat /sys/fs/cgroup/elogind hierarchy

Currently the hybrid mode mounts cgroup v2 on /sys/fs/cgroup instead of the v1
name=elogind hierarchy.  While this works fine for elogind itself, it breaks
tools which expect cgroup v1 hierarchy on /sys/fs/cgroup/elogind.

This patch updates the hybrid mode so that it mounts v2 hierarchy on
/sys/fs/cgroup/unified and keeps v1 "name=elogind" hierarchy on
/sys/fs/cgroup/elogind for compatibility.  elogind itself doesn't depend on the
"name=elogind" hierarchy at all.  All operations take place on the v2 hierarchy
as before but the v1 hierarchy is kept in sync so that any tools which expect
it to be there can keep doing so.  This allows elogind to take advantage of
cgroup v2 process management without requiring other tools to be aware of the
hybrid mode.

The hybrid mode is implemented by mapping the special elogind controller to
/sys/fs/cgroup/unified and making the basic cgroup utility operations -
cg_attach(), cg_create(), cg_rmdir() and cg_trim() - also operate on the
/sys/fs/cgroup/elogind hierarchy whenever the cgroup2 hierarchy is updated.

While a bit messy, this will allow dropping complications from using cgroup v1
for process management a lot sooner than otherwise possible which should make
it a net gain in terms of maintainability.

v2: Fixed !cgns breakage reported by @evverx and renamed the unified mount
    point to /sys/fs/cgroup/unified as suggested by @brauner.

v3: chown the compat hierarchy too on delegation.  Suggested by @evverx.

v4: [zj]
- drop the change to default, full "legacy" is still the default.

6 years agotree-wide: stop using canonicalize_file_name(), use chase_symlinks() instead
Lennart Poettering [Fri, 18 Nov 2016 20:35:21 +0000 (21:35 +0100)]
tree-wide: stop using canonicalize_file_name(), use chase_symlinks() instead

Let's use chase_symlinks() everywhere, and stop using GNU
canonicalize_file_name() everywhere. For most cases this should not change
behaviour, however increase exposure of our function to get better tested. Most
importantly in a few cases (most notably nspawn) it can take the correct root
directory into account when chasing symlinks.

6 years agonspawn: support ephemeral boots from images
Lennart Poettering [Fri, 18 Nov 2016 17:38:06 +0000 (18:38 +0100)]
nspawn: support ephemeral boots from images

Previously --ephemeral was only supported with container trees in btrfs
subvolumes (i.e. in combination with --directory=). This adds support for
--ephemeral in conjunction with disk images (i.e. --image=) too.

As side effect this fixes that --ephemeral was accepted but ignored when using
-M on a container that turned out to be an image.

Fixes: #4664
6 years agobasic/process-util: we need to take the shorter of two strings
Zbigniew Jędrzejewski-Szmek [Fri, 18 Nov 2016 01:57:22 +0000 (20:57 -0500)]
basic/process-util: we need to take the shorter of two strings

==30496== Conditional jump or move depends on uninitialised value(s)
==30496==    at 0x489F654: memcmp (vg_replace_strmem.c:1091)
==30496==    by 0x49BF203: getenv_for_pid (process-util.c:678)
==30496==    by 0x4993ACB: detect_container (virt.c:442)
==30496==    by 0x182DFF: test_get_process_comm (test-process-util.c:98)
==30496==    by 0x185847: main (test-process-util.c:368)
==30496==

6 years agosd-id128: add new sd_id128_get_machine_app_specific() API
Lennart Poettering [Thu, 17 Nov 2016 16:07:46 +0000 (17:07 +0100)]
sd-id128: add new sd_id128_get_machine_app_specific() API

This adds an API for retrieving an app-specific machine ID to sd-id128.
Internally it calculates HMAC-SHA256 with an 128bit app-specific ID as payload
and the machine ID as key.

(An alternative would have been to use siphash for this, which is also
cryptographically strong. However, as it only generates 64bit hashes it's not
an obvious choice for generating 128bit IDs.)

Fixes: #4667
6 years agocore: add "khash" API to src/basic/ (as wrapper around kernel AF_ALG)
Lennart Poettering [Thu, 17 Nov 2016 16:03:21 +0000 (17:03 +0100)]
core: add "khash" API to src/basic/ (as wrapper around kernel AF_ALG)

Let's take inspiration from bluez's ELL library, and let's move our
cryptographic primitives away from libgcrypt and towards the kernel's AF_ALG
cryptographic userspace API.

In the long run we should try to remove the dependency on libgcrypt, in favour
of using only the kernel's own primitives, however this is unlikely to happen
anytime soon, as the kernel does not provide Elliptic Curve APIs to userspace
at this time, and we need them for the DNSSEC cryptographic.

This commit only covers hashing for now, symmetric encryption/decryption or
even asymetric encryption/decryption is not available for now.

"khash" is little more than a lightweight wrapper around the kernel's AF_ALG
socket API.

6 years agoshared: split out code for adding multiple names to sd_bus_track object
Lennart Poettering [Tue, 15 Nov 2016 18:18:36 +0000 (19:18 +0100)]
shared: split out code for adding multiple names to sd_bus_track object

Let's introduce a new call bus_track_add_name_many() that adds a string list to
a tracking object.

6 years agobus-util: print RestrictNamespaces= as a string
Djalal Harouni [Tue, 15 Nov 2016 14:15:37 +0000 (15:15 +0100)]
bus-util: print RestrictNamespaces= as a string

Allow all callers that want to print RestrictNamespaces= returned from D-Bus
as a string instead of a u64 value.

6 years agotree-wide: make invocations of extract_first_word more uniform (#4627)
Zbigniew Jędrzejewski-Szmek [Fri, 11 Nov 2016 17:58:41 +0000 (12:58 -0500)]
tree-wide: make invocations of extract_first_word more uniform (#4627)

extract_first_words deals fine with the string being NULL, so drop the upfront
check for that.

6 years agobasic/virt: fix userns check on CONFIG_USER_NS=n kernel (#4651)
Zbigniew Jędrzejewski-Szmek [Fri, 11 Nov 2016 15:54:54 +0000 (10:54 -0500)]
basic/virt: fix userns check on CONFIG_USER_NS=n kernel (#4651)

ENOENT should be treated as "false", but because of the broken errno check it
was treated as an error. So ConditionVirtualization=user-namespaces probably
returned the correct answer, but only by accident.

Fixes #4608.

6 years agocore: don't use the unified hierarchy for the elogind cgroup yet (#4628)
Martin Pitt [Thu, 10 Nov 2016 04:33:13 +0000 (05:33 +0100)]
core: don't use the unified hierarchy for the elogind cgroup yet (#4628)

Too many things don't get along with the unified hierarchy yet:

 * https://github.com/opencontainers/runc/issues/1175
 * https://github.com/docker/docker/issues/28109
 * https://github.com/lxc/lxc/issues/1280

So revert the default to the legacy hierarchy for now. Developers of the above
software can opt into the unified hierarchy with
"elogind.legacy_elogind_cgroup_controller=0".

6 years agoman/sd_watchdog_enabled: correct minor typos (#4632)
Jonathan Boulle [Wed, 9 Nov 2016 16:30:10 +0000 (17:30 +0100)]
man/sd_watchdog_enabled: correct minor typos (#4632)

6 years agoAdjust pkgconfig files to point at rootlibdir (#4584)
Mike Gilbert [Tue, 8 Nov 2016 08:36:41 +0000 (03:36 -0500)]
Adjust pkgconfig files to point at rootlibdir (#4584)

The .so symlinks got moved to rootlibdir in 082210c7.

6 years agotree-wide: drop (llu) casts for kernel's __u64
Zbigniew Jędrzejewski-Szmek [Mon, 7 Nov 2016 16:49:51 +0000 (11:49 -0500)]
tree-wide: drop (llu) casts for kernel's __u64

According to comments in <asm/types.h>, __u64 is always defined as unsigned
long long. Those casts should be superfluous.

6 years agotree-wide: add PRI_[NU]SEC, and use time format strings more
Zbigniew Jędrzejewski-Szmek [Mon, 7 Nov 2016 16:49:25 +0000 (11:49 -0500)]
tree-wide: add PRI_[NU]SEC, and use time format strings more

6 years agocore: reprint the question every 2 sec in ask_char()
Franck Bui [Mon, 7 Nov 2016 16:14:59 +0000 (17:14 +0100)]
core: reprint the question every 2 sec in ask_char()

ask_char() now reprints the question every 2sec automatically.

It prefixes its output with '\r' to to bring the cursor to the
beginning of the terminal line, and then print the message, redoing it
every 2sec.

As long as nothing interferes with out output this logic will have no
visible effect as we constantly overprint the visible text with the
exact same text.

However, if something is dumped in the middle, then our question won't
get lost, as we'll ask soon again.

This is useful if the question is asked to a terminal that is also
used to dump some other status messages/logs. For example when
confirmation messages are enabled during the boot
(elogind.confirm_spawn=1), the question can easily be lost if the
kernel logs are also enabled and both use the same console.

Idea suggested by Lennart Poettering.

6 years agoRename formats-util.h to format-util.h
Zbigniew Jędrzejewski-Szmek [Mon, 7 Nov 2016 15:14:59 +0000 (10:14 -0500)]
Rename formats-util.h to format-util.h

We don't have plural in the name of any other -util files and this
inconsistency trips me up every time I try to type this file name
from memory. "formats-util" is even hard to pronounce.

6 years agotree-wide: add SD_ID128_MAKE_STR, remove LOG_MESSAGE_ID
Zbigniew Jędrzejewski-Szmek [Sun, 6 Nov 2016 17:48:23 +0000 (12:48 -0500)]
tree-wide: add SD_ID128_MAKE_STR, remove LOG_MESSAGE_ID

Embedding sd_id128_t's in constant strings was rather cumbersome. We had
SD_ID128_CONST_STR which returned a const char[], but it had two problems:
- it wasn't possible to statically concatanate this array with a normal string
- gcc wasn't really able to optimize this, and generated code to perform the
  "conversion" at runtime.
Because of this, even our own code in coredumpctl wasn't using
SD_ID128_CONST_STR.

Add a new macro to generate a constant string: SD_ID128_MAKE_STR.
It is not as elegant as SD_ID128_CONST_STR, because it requires a repetition
of the numbers, but in practice it is more convenient to use, and allows gcc
to generate smarter code:

$ size .libs/elogind{,-logind,-journald}{.old,}
   text    data     bss     dec     hex filename
1265204  149564    4808 1419576  15a938 .libs/elogind.old
1260268  149564    4808 1414640  1595f0 .libs/elogind
 246805   13852     209  260866   3fb02 .libs/elogind-logind.old
 240973   13852     209  255034   3e43a .libs/elogind-logind
 146839    4984      34  151857   25131 .libs/elogind-journald.old
 146391    4984      34  151409   24f71 .libs/elogind-journald

It is also much easier to check if a certain binary uses a certain MESSAGE_ID:

$ strings .libs/elogind.old|grep MESSAGE_ID
MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x
MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x
MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x
MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x

$ strings .libs/elogind|grep MESSAGE_ID
MESSAGE_ID=c7a787079b354eaaa9e77b371893cd27
MESSAGE_ID=b07a249cd024414a82dd00cd181378ff
MESSAGE_ID=641257651c1b4ec9a8624d7a40a9e1e7
MESSAGE_ID=de5b426a63be47a7b6ac3eaac82e2f6f
MESSAGE_ID=d34d037fff1847e6ae669a370e694725
MESSAGE_ID=7d4958e842da4a758f6c1cdc7b36dcc5
MESSAGE_ID=1dee0369c7fc4736b7099b38ecb46ee7
MESSAGE_ID=39f53479d3a045ac8e11786248231fbf
MESSAGE_ID=be02cf6855d2428ba40df7e9d022f03d
MESSAGE_ID=7b05ebc668384222baa8881179cfda54
MESSAGE_ID=9d1aaa27d60140bd96365438aad20286

6 years agoLink: port to new ethtool ETHTOOL_xLINKSETTINGS
Susant Sahani [Fri, 4 Nov 2016 09:55:07 +0000 (15:25 +0530)]
Link: port to new ethtool ETHTOOL_xLINKSETTINGS

Link: port to new ethtool ETHTOOL_xLINKSETTINGS
This patch defines a new ETHTOOL_GLINKSETTINGS/SLINKSETTINGS API,
handled by the new get_link_ksettings/set_link_ksettings .

This is a WIP version based on this [kernel
patch](https://patchwork.kernel.org/patch/8411401/).

commit 0527f1c

http://github.com/torvalds/linux/commit/3f1ac7a700d039c61d8d8b99f28d605d489a60cfommit
35afb33

6 years agoacl-util: fix memleak
Evgeny Vereshchagin [Thu, 3 Nov 2016 22:04:40 +0000 (22:04 +0000)]
acl-util: fix memleak

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

6 years agoRevert "sd-bus: use PRIu64 instead of casting" (#4556)
Zbigniew Jędrzejewski-Szmek [Thu, 3 Nov 2016 17:16:42 +0000 (13:16 -0400)]
Revert "sd-bus: use PRIu64 instead of casting" (#4556)

This reverts commit 75ead2b753cb9586f3f208326446081baab70da1.

Follow up for #4546:
> @@ -848,8 +848,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
         if (k->src_id == KDBUS_SRC_ID_KERNEL)
                 bus_message_set_sender_driver(bus, m);
         else {
-                xsprintf(m->sender_buffer, ":1.%llu",
-                         (unsigned long long)k->src_id);
+                xsprintf(m->sender_buffer, ":1.%"PRIu64, k->src_id);

This produces:

src/libelogind/sd-bus/bus-kernel.c: In function ‘bus_kernel_make_message’:
src/libelogind/sd-bus/bus-kernel.c:851:44: warning: format ‘%lu’ expects argument of type ‘long
unsigned int’, but argument 4 has type ‘__u64 {aka long long unsigned int}’ [-Wformat=]
                 xsprintf(m->sender_buffer, ":1.%"PRIu64, k->src_id);
                                            ^

6 years agocore: monitor the inotify file descriptor not the console one in acquire_terminal()
Franck Bui [Wed, 2 Nov 2016 15:24:57 +0000 (16:24 +0100)]
core: monitor the inotify file descriptor not the console one in acquire_terminal()

When waiting for the terminal to be release in acquire_terminal(), we
were monitoring the terminal fd instead of the inotify descriptor.

Therefore any write accesses would wake up the waiting process instead
of being wake up when the tty is closed only.

6 years agoDrop FOREACH_WORD_QUOTED
Zbigniew Jędrzejewski-Szmek [Fri, 28 Oct 2016 02:44:50 +0000 (22:44 -0400)]
Drop FOREACH_WORD_QUOTED

6 years agotree-wide: drop unneded WHITESPACE param to extract_first_word
Zbigniew Jędrzejewski-Szmek [Fri, 28 Oct 2016 00:06:44 +0000 (20:06 -0400)]
tree-wide: drop unneded WHITESPACE param to extract_first_word

It's the default, and NULL is shorter.

6 years agotree-wide: drop NULL sentinel from strjoin
Zbigniew Jędrzejewski-Szmek [Sun, 23 Oct 2016 15:43:27 +0000 (11:43 -0400)]
tree-wide: drop NULL sentinel from strjoin

This makes strjoin and strjoina more similar and avoids the useless final
argument.

spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/elogind -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libelogind/sd-bus -I ./src/libelogind/sd-event -I ./src/libelogind/sd-login -I ./src/libelogind/sd-netlink -I ./src/libelogind/sd-network -I ./src/libelogind/sd-hwdb -I ./src/libelogind/sd-device -I ./src/libelogind/sd-id128 -I ./src/libelogind-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c)

git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/'

This might have missed a few cases (spatch has a really hard time dealing
with _cleanup_ macros), but that's no big issue, they can always be fixed
later.

6 years agotree-wide: use startswith return value to avoid hardcoded offset
Zbigniew Jędrzejewski-Szmek [Sat, 22 Oct 2016 20:11:41 +0000 (16:11 -0400)]
tree-wide: use startswith return value to avoid hardcoded offset

I think it's an antipattern to have to count the number of bytes in
the prefix by hand. We should do this automatically to avoid wasting
programmer time, and possible errors. I didn't any offsets that were
wrong, so this change is mostly to make future development easier.

6 years agobasic: support default and alternate values for env expansion
Ray Strode [Tue, 9 Aug 2016 14:20:22 +0000 (10:20 -0400)]
basic: support default and alternate values for env expansion

Sometimes it's useful to provide a default value during an environment
expansion, if the environment variable isn't already set.

For instance $XDG_DATA_DIRS is suppose to default to:

/usr/local/share/:/usr/share/

if it's not yet set. That means callers wishing to augment
XDG_DATA_DIRS need to manually add those two values.

This commit changes replace_env to support the following shell
compatible default value syntax:

XDG_DATA_DIRS=/foo:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share}

Likewise, it's useful to provide an alternate value during an
environment expansion, if the environment variable isn't already set.

For instance, $LD_LIBRARY_PATH will inadvertently search the current
working directory if it starts or ends with a colon, so the following
is usually wrong:

LD_LIBRARY_PATH=/foo/lib:${LD_LIBRARY_PATH}

To address that, this changes replace_env to support the following
shell compatible alternate value syntax:

LD_LIBRARY_PATH=/foo/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

[zj: gate the new syntax under REPLACE_ENV_ALLOW_EXTENDED switch, so
existing callers are not modified.]

6 years agobasic: add new merge_env_file function
Ray Strode [Thu, 4 Aug 2016 16:00:00 +0000 (12:00 -0400)]
basic: add new merge_env_file function

merge_env_file is a new function, that's like load_env_file, but takes a
pre-existing environment as an input argument. New environment entries are
merged. Variable expansion is performed.

Falling back to the process environment is supported (when a flag is set).
Alternatively this could be implemented as passing an additional fallback
environment array, but later on we're adding another flag to allow braceless
expansion, and the two flags can be combined in one arg, so there's less
stuff to pass around.

6 years agoMerge pull request #22 from elogind/dev_v232
Sven Eden [Fri, 7 Jul 2017 13:18:23 +0000 (15:18 +0200)]
Merge pull request #22 from elogind/dev_v232

Dev v232 merge to master

6 years agoVersion 232.2 (Pre) Release v232.2
Sven Eden [Fri, 7 Jul 2017 09:33:47 +0000 (11:33 +0200)]
Version 232.2 (Pre) Release

6 years agoPrep v232.2: Mask more unneeded functions
Sven Eden [Fri, 7 Jul 2017 09:33:14 +0000 (11:33 +0200)]
Prep v232.2: Mask more unneeded functions

6 years agoPrep v232.2: Remove src/mount - It is not needed.
Sven Eden [Fri, 7 Jul 2017 05:58:07 +0000 (07:58 +0200)]
Prep v232.2: Remove src/mount - It is not needed.

6 years agoPrep v232.2: cg_shift_path() : With other controllers, elogind might end up in name...
Sven Eden [Wed, 5 Jul 2017 12:53:38 +0000 (14:53 +0200)]
Prep v232.2: cg_shift_path() : With other controllers, elogind might end up in name=foo:/elogind, where cgroup and root are both /elogind.

6 years agoPrep v232.2: cg_update_unified() : Statically set 'unified_cache' to 'CGROUP_UNIFIED_...
Sven Eden [Wed, 5 Jul 2017 12:24:33 +0000 (14:24 +0200)]
Prep v232.2: cg_update_unified() : Statically set 'unified_cache' to 'CGROUP_UNIFIED_NONE'

6 years agoPrep v232.2: libelogind.sym: Rename LIBELOGIND back to LIBSYSTEMD.
Sven Eden [Wed, 5 Jul 2017 11:03:13 +0000 (13:03 +0200)]
Prep v232.2: libelogind.sym: Rename LIBELOGIND back to LIBSYSTEMD.

6 years agoPrep v232.2: Unmask sd_id128_get_invocation(), it is part of the API installed by...
Sven Eden [Wed, 5 Jul 2017 08:30:23 +0000 (10:30 +0200)]
Prep v232.2: Unmask sd_id128_get_invocation(), it is part of the API installed by elogind, and therefore must not be masked.

6 years agoVersion 232.1 Release
Sven Eden [Wed, 5 Jul 2017 06:57:32 +0000 (08:57 +0200)]
Version 232.1 Release

6 years agoPrep v232: Add libelogind.sym entries for version 232.
Sven Eden [Tue, 4 Jul 2017 16:26:15 +0000 (18:26 +0200)]
Prep v232: Add libelogind.sym entries for version 232.

6 years agoPrep v232: Do not listen to SYSTEMD_* environment variables to override things.
Sven Eden [Tue, 4 Jul 2017 16:10:40 +0000 (18:10 +0200)]
Prep v232: Do not listen to SYSTEMD_* environment variables to override things.

6 years agoPrep v232: Mask new functions that are unneeded by elogind
Sven Eden [Tue, 4 Jul 2017 15:09:23 +0000 (17:09 +0200)]
Prep v232: Mask new functions that are unneeded by elogind

6 years agoPrep v232: Add missing includes
Sven Eden [Tue, 4 Jul 2017 15:08:57 +0000 (17:08 +0200)]
Prep v232: Add missing includes

6 years agoPrep v232: Apply missing updates from upstream
Sven Eden [Tue, 4 Jul 2017 14:59:46 +0000 (16:59 +0200)]
Prep v232: Apply missing updates from upstream

6 years agoPrep v232: Update root and build files to upstream v232 tag.
Sven Eden [Fri, 30 Jun 2017 06:13:06 +0000 (08:13 +0200)]
Prep v232: Update root and build files to upstream v232 tag.

6 years agoRevert "sd-bus: use PRIu64 instead of casting" (#4556)
Zbigniew Jędrzejewski-Szmek [Thu, 3 Nov 2016 17:16:42 +0000 (13:16 -0400)]
Revert "sd-bus: use PRIu64 instead of casting" (#4556)

This reverts commit 75ead2b753cb9586f3f208326446081baab70da1.

Follow up for #4546:
> @@ -848,8 +848,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
         if (k->src_id == KDBUS_SRC_ID_KERNEL)
                 bus_message_set_sender_driver(bus, m);
         else {
-                xsprintf(m->sender_buffer, ":1.%llu",
-                         (unsigned long long)k->src_id);
+                xsprintf(m->sender_buffer, ":1.%"PRIu64, k->src_id);

This produces:

src/libelogind/sd-bus/bus-kernel.c: In function ‘bus_kernel_make_message’:
src/libelogind/sd-bus/bus-kernel.c:851:44: warning: format ‘%lu’ expects argument of type ‘long
unsigned int’, but argument 4 has type ‘__u64 {aka long long unsigned int}’ [-Wformat=]
                 xsprintf(m->sender_buffer, ":1.%"PRIu64, k->src_id);
                                            ^

6 years agosd-bus: use PRIu64 instead of casting
Zbigniew Jędrzejewski-Szmek [Thu, 3 Nov 2016 02:03:27 +0000 (22:03 -0400)]
sd-bus: use PRIu64 instead of casting

6 years agoRevert some uses of xsprintf
Zbigniew Jędrzejewski-Szmek [Thu, 3 Nov 2016 02:02:46 +0000 (22:02 -0400)]
Revert some uses of xsprintf

This reverts some changes introduced in d054f0a4d4.
xsprintf should be used in cases where we calculated the right buffer
size by hand (using DECIMAL_STRING_MAX and such), and never in cases where
we are printing externally specified strings of arbitrary length.

Fixes #4534.

6 years agoRecognise Lustre as a remote file system (#4530)
Brian J. Murrell [Tue, 1 Nov 2016 03:48:00 +0000 (23:48 -0400)]
Recognise Lustre as a remote file system (#4530)

Lustre is also a remote file system that wants the network to be up before it is mounted.

6 years agotests: clarify test_path_startswith return value (#4508)
Zbigniew Jędrzejewski-Szmek [Sun, 30 Oct 2016 14:21:29 +0000 (10:21 -0400)]
tests: clarify test_path_startswith return value (#4508)

A pendant for #4481.

6 years agoman: Fix event source priority enum names in synopsis (#4478)
Martin Ejdestig [Mon, 24 Oct 2016 22:30:26 +0000 (00:30 +0200)]
man: Fix event source priority enum names in synopsis (#4478)

6 years agoman: add a note that FDSTORE=1 requires epoll-compatible fds
Zbigniew Jędrzejewski-Szmek [Sun, 23 Oct 2016 00:32:59 +0000 (20:32 -0400)]
man: add a note that FDSTORE=1 requires epoll-compatible fds

Let's say that this was not obvious from our man page.

6 years agotree-wide: make parse_proc_cmdline() strip "rd." prefix automatically
Zbigniew Jędrzejewski-Szmek [Sat, 22 Oct 2016 19:31:14 +0000 (15:31 -0400)]
tree-wide: make parse_proc_cmdline() strip "rd." prefix automatically

This stripping is contolled by a new boolean parameter. When the parameter
is true, it means that the caller does not care about the distinction between
initrd and real root, and wants to act on both rd-dot-prefixed and unprefixed
parameters in the initramfs, and only on the unprefixed parameters in real
root. If the parameter is false, behaviour is the same as before.

Changes by caller:
log.c (elogind.log_*):      changed to accept rd-dot-prefix params
pid1:                       no change, custom logic
cryptsetup-generator:       no change, still accepts rd-dot-prefix params
debug-generator:            no change, does not accept rd-dot-prefix params
fsck:                       changed to accept rd-dot-prefix params
fstab-generator:            no change, custom logic
gpt-auto-generator:         no change, custom logic
hibernate-resume-generator: no change, does not accept rd-dot-prefix params
journald:                   changed to accept rd-dot-prefix params
modules-load:               no change, still accepts rd-dot-prefix params
quote-check:                no change, does not accept rd-dot-prefix params
udevd:                      no change, still accepts rd-dot-prefix params

I added support for "rd." params in the three cases where I think it's
useful: logging, fsck options, journald forwarding options.

6 years agotree-wide: allow state to be passed through to parse_proc_cmdline_item
Zbigniew Jędrzejewski-Szmek [Sat, 22 Oct 2016 18:24:52 +0000 (14:24 -0400)]
tree-wide: allow state to be passed through to parse_proc_cmdline_item

No functional change.

6 years agodetect-virt: add --private-users switch to check if a userns is active
Zbigniew Jędrzejewski-Szmek [Fri, 21 Oct 2016 03:41:21 +0000 (23:41 -0400)]
detect-virt: add --private-users switch to check if a userns is active

Various things don't work when we're running in a user namespace, but it's
pretty hard to reliably detect if that is true.

A function is added which looks at /proc/self/uid_map and returns false
if the default "0 0 UINT32_MAX" is found, and true if it finds anything else.
This misses the case where an 1:1 mapping with the full range was used, but
I don't know how to distinguish this case.

'elogind-detect-virt --private-users' is very similar to
'elogind-detect-virt --chroot', but we check for a user namespace instead.

6 years agoupdate-utmp: let's use STR_IN_SET() where it is pretty
Lennart Poettering [Thu, 20 Oct 2016 17:20:22 +0000 (19:20 +0200)]
update-utmp: let's use STR_IN_SET() where it is pretty

6 years agologind: don't hit assert when we try to free NULL manager object
Lennart Poettering [Thu, 20 Oct 2016 17:19:46 +0000 (19:19 +0200)]
logind: don't hit assert when we try to free NULL manager object

Fixes: #4431
6 years agobasic: fallback to the fstat if we don't have access to the /proc/self/fdinfo
Evgeny Vereshchagin [Thu, 20 Oct 2016 09:01:45 +0000 (09:01 +0000)]
basic: fallback to the fstat if we don't have access to the /proc/self/fdinfo

https://github.com/elogind/elogind/pull/4372#discussion_r83354107:
I get `open("/proc/self/fdinfo/13", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)`

327   mkdir("/proc", 0755 <unfinished ...>
327   <... mkdir resumed> )             = -1 EEXIST (File exists)
327   stat("/proc",  <unfinished ...>
327   <... stat resumed> {st_dev=makedev(8, 1), st_ino=28585, st_mode=S_IFDIR|0755, st_nlink=2, st_uid=0, st_gid=0, st_blksize=1024, st_blocks=4, st_size=1024, st_atime=2016/10/14-02:55:32, st_mtime=2016/
327   mount("proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL <unfinished ...>
327   <... mount resumed> )             = 0
327   lstat("/proc",  <unfinished ...>
327   <... lstat resumed> {st_dev=makedev(0, 34), st_ino=1, st_mode=S_IFDIR|0555, st_nlink=75, st_uid=65534, st_gid=65534, st_blksize=1024, st_blocks=0, st_size=0, st_atime=2016/10/14-03:13:35.971031263,
327   lstat("/proc/sys", {st_dev=makedev(0, 34), st_ino=4026531855, st_mode=S_IFDIR|0555, st_nlink=1, st_uid=65534, st_gid=65534, st_blksize=1024, st_blocks=0, st_size=0, st_atime=2016/10/14-03:13:39.1630
327   openat(AT_FDCWD, "/proc", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_PATH) = 11</proc>
327   name_to_handle_at(11</proc>, "sys", {handle_bytes=128}, 0x7ffe3a238604, AT_SYMLINK_FOLLOW) = -1 EOPNOTSUPP (Operation not supported)
327   name_to_handle_at(11</proc>, "", {handle_bytes=128}, 0x7ffe3a238608, AT_EMPTY_PATH) = -1 EOPNOTSUPP (Operation not supported)
327   openat(11</proc>, "sys", O_RDONLY|O_CLOEXEC|O_PATH) = 13</proc/sys>
327   open("/proc/self/fdinfo/13", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
327   close(13</proc/sys> <unfinished ...>
327   <... close resumed> )             = 0
327   close(11</proc> <unfinished ...>
327   <... close resumed> )             = 0

-bash-4.3# ls -ld /proc/
dr-xr-xr-x 76 65534 65534 0 Oct 14 02:57 /proc/

-bash-4.3# ls -ld /proc/1
dr-xr-xr-x 9 root root 0 Oct 14 02:57 /proc/1

-bash-4.3# ls -ld /proc/1/fdinfo
dr-x------ 2 65534 65534 0 Oct 14 03:00 /proc/1/fdinfo

6 years agoterminal-util: helper macro for highlighting functions
Zbigniew Jędrzejewski-Szmek [Mon, 17 Oct 2016 15:48:12 +0000 (11:48 -0400)]
terminal-util: helper macro for highlighting functions

6 years agosystemctl: use underlines to seperate unit types in listing
Zbigniew Jędrzejewski-Szmek [Mon, 17 Oct 2016 15:37:41 +0000 (11:37 -0400)]
systemctl: use underlines to seperate unit types in listing

(printf("%.*s", -1, "…") is the same as not specifying the precision at all.)

v2: also underline highlighted (failing) units

Fixes #4137.

6 years agotree-wide: introduce free_and_replace helper
Zbigniew Jędrzejewski-Szmek [Sun, 16 Oct 2016 23:23:35 +0000 (19:23 -0400)]
tree-wide: introduce free_and_replace helper

It's a common pattern, so add a helper for it. A macro is necessary
because a function that takes a pointer to a pointer would be type specific,
similarly to cleanup functions. Seems better to use a macro.

6 years agotree-wide: use mfree more
Zbigniew Jędrzejewski-Szmek [Sun, 16 Oct 2016 22:28:30 +0000 (18:28 -0400)]
tree-wide: use mfree more

6 years agologinctl: report tty in session listings
Zbigniew Jędrzejewski-Szmek [Sun, 16 Oct 2016 19:13:03 +0000 (15:13 -0400)]
loginctl: report tty in session listings

Without the tty it's really hard to tell which session is which.

New output:
$ ./loginctl
   SESSION        UID USER             SEAT             TTY
        13       1002 zbyszek          seat0            tty3
        c1         42 gdm              seat0            /dev/tty1
        11       1002 zbyszek          seat0            tty4
         3       1002 zbyszek          seat0            /dev/tty2
        17       1002 zbyszek          seat0            tty5
        18       1002 zbyszek          seat0            tty6
6 sessions listed.

6 years agologinctl: drop casts in printf
Zbigniew Jędrzejewski-Szmek [Sun, 16 Oct 2016 18:19:06 +0000 (14:19 -0400)]
loginctl: drop casts in printf

6 years agovirt: add possibility to skip the check for chroot (#4374)
Lukáš Nykrýn [Sat, 15 Oct 2016 17:54:58 +0000 (19:54 +0200)]
virt: add possibility to skip the check for chroot (#4374)

https://bugzilla.redhat.com/show_bug.cgi?id=1379852

6 years agocore: make settings for unified cgroup hierarchy supersede the ones for legacy hierar...
Tejun Heo [Sat, 15 Oct 2016 01:07:16 +0000 (21:07 -0400)]
core: make settings for unified cgroup hierarchy supersede the ones for legacy hierarchy (#4269)

There are overlapping control group resource settings for the unified and
legacy hierarchies.  To help transition, the settings are translated back and
forth.  When both versions of a given setting are present, the one matching the
cgroup hierarchy type in use is used.  Unfortunately, this is more confusing to
use and document than necessary because there is no clear static precedence.

Update the translation logic so that the settings for the unified hierarchy are
always preferred.  elogind.resource-control man page is updated to reflect the
change and reorganized so that the deprecated settings are at the end in its
own section.

6 years agonspawn: cleanup and chown the synced cgroup hierarchy (#4223)
Evgeny Vereshchagin [Thu, 13 Oct 2016 13:50:46 +0000 (16:50 +0300)]
nspawn: cleanup and chown the synced cgroup hierarchy (#4223)

Fixes: #4181
6 years agoman: typo fixes
Thomas Hindoe Paaboel Andersen [Wed, 12 Oct 2016 21:02:44 +0000 (23:02 +0200)]
man: typo fixes

A mix of fixes for typos and UK english

6 years agobasic: use for() loop instead of while()
Stefan Schweter [Wed, 12 Oct 2016 20:48:41 +0000 (22:48 +0200)]
basic: use for() loop instead of while()

6 years agoelogind-user: add pam_unix account module
Felipe Sateler [Wed, 12 Oct 2016 14:20:46 +0000 (11:20 -0300)]
elogind-user: add pam_unix account module

Otherwise elogind-user@ fails because elogind validates the account

Fixes: #4342
6 years agoAllow block and char classes in DeviceAllow bus properties (#4353)
Zbigniew Jędrzejewski-Szmek [Wed, 12 Oct 2016 09:12:11 +0000 (05:12 -0400)]
Allow block and char classes in DeviceAllow bus properties (#4353)

Allowed paths are unified betwen the configuration file parses and the bus
property checker. The biggest change is that the bus code now allows "block-"
and "char-" classes. In addition, path_startswith("/dev") was used in the bus
code, and startswith("/dev") was used in the config file code. It seems
reasonable to use path_startswith() which allows a slightly broader class of
strings.

Fixes #3935.

6 years agomissing: add a bunch of mount flags
Zbigniew Jędrzejewski-Szmek [Tue, 11 Oct 2016 21:24:03 +0000 (17:24 -0400)]
missing: add a bunch of mount flags

6 years agopager: tiny beautification
Lennart Poettering [Tue, 11 Oct 2016 15:46:59 +0000 (17:46 +0200)]
pager: tiny beautification

6 years agoman: expand the documentation of $SYSTEMD_PAGER and related environment variables
Lennart Poettering [Tue, 11 Oct 2016 15:45:49 +0000 (17:45 +0200)]
man: expand the documentation of $SYSTEMD_PAGER and related environment variables

Document the default pagers used, as well as $SYSTEMD_LESSCHARSET.

Fixes: #4143
6 years agonspawn,mount-util: add [u]mount_verbose and use it in nspawn
Zbigniew Jędrzejewski-Szmek [Mon, 10 Oct 2016 19:55:20 +0000 (15:55 -0400)]
nspawn,mount-util: add [u]mount_verbose and use it in nspawn

This makes it easier to debug failed nspawn invocations:

Mounting sysfs on /var/lib/machines/fedora-rawhide/sys (MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV "")...
Mounting tmpfs on /var/lib/machines/fedora-rawhide/dev (MS_NOSUID|MS_STRICTATIME "mode=755,uid=1450901504,gid=1450901504")...
Mounting tmpfs on /var/lib/machines/fedora-rawhide/dev/shm (MS_NOSUID|MS_NODEV|MS_STRICTATIME "mode=1777,uid=1450901504,gid=1450901504")...
Mounting tmpfs on /var/lib/machines/fedora-rawhide/run (MS_NOSUID|MS_NODEV|MS_STRICTATIME "mode=755,uid=1450901504,gid=1450901504")...
Bind-mounting /sys/fs/selinux on /var/lib/machines/fedora-rawhide/sys/fs/selinux (MS_BIND "")...
Remounting /var/lib/machines/fedora-rawhide/sys/fs/selinux (MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_BIND|MS_REMOUNT "")...
Mounting proc on /proc (MS_NOSUID|MS_NOEXEC|MS_NODEV "")...
Bind-mounting /proc/sys on /proc/sys (MS_BIND "")...
Remounting /proc/sys (MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_BIND|MS_REMOUNT "")...
Bind-mounting /proc/sysrq-trigger on /proc/sysrq-trigger (MS_BIND "")...
Remounting /proc/sysrq-trigger (MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_BIND|MS_REMOUNT "")...
Mounting tmpfs on /tmp (MS_STRICTATIME "mode=1777,uid=0,gid=0")...
Mounting tmpfs on /sys/fs/cgroup (MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME "mode=755,uid=0,gid=0")...
Mounting cgroup on /sys/fs/cgroup/elogind (MS_NOSUID|MS_NOEXEC|MS_NODEV "none,name=elogind,xattr")...
Failed to mount cgroup on /sys/fs/cgroup/elogind (MS_NOSUID|MS_NOEXEC|MS_NODEV "none,name=elogind,xattr"): No such file or directory

6 years agologin: drop fedora-specific PAM config, add note to DISTRO_PORTING (#4314)
Felipe Sateler [Mon, 10 Oct 2016 13:40:05 +0000 (10:40 -0300)]
login: drop fedora-specific PAM config, add note to DISTRO_PORTING (#4314)

It is impossible to ship a fully generic PAM configuration upstream.
Therefore, ship a minimal configuration with the elogind --user requirements,
and add a note to DISTRO_PORTING documenting this.

Fixes #4284

6 years agonetworkd: address add support to configure flags (#4201)
Susant Sahani [Sat, 8 Oct 2016 11:05:41 +0000 (16:35 +0530)]
networkd: address add support to configure flags (#4201)

This patch enables to configure

IFA_F_HOMEADDRESS
IFA_F_NODAD
IFA_F_MANAGETEMPADDR
IFA_F_NOPREFIXROUTE
IFA_F_MCAUTOJOIN

6 years agouser-util: rework maybe_setgroups() a bit
Lennart Poettering [Thu, 6 Oct 2016 15:54:12 +0000 (17:54 +0200)]
user-util: rework maybe_setgroups() a bit

Let's drop the caching of the setgroups /proc field for now. While there's a
strict regime in place when it changes states, let's better not cache it since
we cannot really be sure we follow that regime correctly.

More importantly however, this is not in performance sensitive code, and
there's no indication the cache is really beneficial, hence let's drop the
caching and make things a bit simpler.

Also, while we are at it, rework the error handling a bit, and always return
negative errno-style error codes, following our usual coding style. This has
the benefit that we can sensible hanld read_one_line_file() errors, without
having to updat errno explicitly.

6 years agosd-bus: add DNS errors to the errno translation table
Lennart Poettering [Thu, 6 Oct 2016 14:01:44 +0000 (16:01 +0200)]
sd-bus: add DNS errors to the errno translation table

We generate these, hence we should also add errno translations for them.

6 years agosd-bus: add a few missing entries to the error translation tables
Lennart Poettering [Thu, 6 Oct 2016 13:50:30 +0000 (15:50 +0200)]
sd-bus: add a few missing entries to the error translation tables

These were forgotten, let's add some useful mappings for all errors we define.

6 years agosd-device/networkd: unify code to get a socket for issuing netdev ioctls on
Lennart Poettering [Thu, 6 Oct 2016 13:48:15 +0000 (15:48 +0200)]
sd-device/networkd: unify code to get a socket for issuing netdev ioctls on

As suggested here:

https://github.com/elogind/elogind/pull/4296#issuecomment-251911349

Let's try AF_INET first as socket, but let's fall back to AF_NETLINK, so that
we can use a protocol-independent socket here if possible. This has the benefit
that our code will still work even if AF_INET/AF_INET6 is made unavailable (for
exmple via seccomp), at least on current kernels.