chiark / gitweb /
elogind.git
5 years agotree-wide: remove unused variables (#8612)
Yu Watanabe [Thu, 29 Mar 2018 10:50:50 +0000 (19:50 +0900)]
tree-wide: remove unused variables (#8612)

5 years agoRename suspend-to-hibernate to suspend-then-hibernate
Mario Limonciello [Wed, 28 Mar 2018 16:00:06 +0000 (11:00 -0500)]
Rename suspend-to-hibernate to suspend-then-hibernate

Per some discussion with Gnome folks, they would prefer this name
as it's more descriptive of what's happening.

5 years agomachine-image,mount-setup: minor coding style fixes
Lennart Poettering [Wed, 28 Mar 2018 15:07:42 +0000 (17:07 +0200)]
machine-image,mount-setup: minor coding style fixes

5 years agoinhibit: make use of EXIT_SUCCESS where appropriate
Lennart Poettering [Tue, 27 Mar 2018 12:58:21 +0000 (14:58 +0200)]
inhibit: make use of EXIT_SUCCESS where appropriate

5 years agoutil: check for overflows in xbsearch_r()
Lennart Poettering [Tue, 27 Mar 2018 12:56:04 +0000 (14:56 +0200)]
util: check for overflows in xbsearch_r()

5 years agoupdate TODO
Lennart Poettering [Tue, 20 Mar 2018 19:26:15 +0000 (20:26 +0100)]
update TODO

5 years agodoc: merge docs/ dir → doc/
Lennart Poettering [Wed, 28 Mar 2018 14:58:37 +0000 (16:58 +0200)]
doc: merge docs/ dir → doc/

It's weird having two subdirs for documentation, let's unify this in
one.

5 years agobus-util: add flags for bus_map_all_properties() (#8546)
Yu Watanabe [Wed, 28 Mar 2018 11:37:27 +0000 (20:37 +0900)]
bus-util: add flags for bus_map_all_properties() (#8546)

This adds flags BUS_MAP_STRDUP and BUS_MAP_BOOLEAN_AS_BOOL.
If BUS_MAP_STRDUP is set, then each "s" message is duplicated.
If BUS_MAP_BOOLEAN_AS_BOOL is set, then each "b" message is
written to a bool pointer.

Follow-up for #8488.
See https://github.com/systemd/systemd/pull/8488#discussion_r175816270.

5 years agocore: dont't remount /sys/fs/cgroup for relabel if not needed (#8595)
Krzysztof Nowicki [Wed, 28 Mar 2018 11:36:33 +0000 (13:36 +0200)]
core: dont't remount /sys/fs/cgroup for relabel if not needed (#8595)

The initial fix for relabelling the cgroup filesystem for
SELinux delivered in commit 8739f23e3 was based on the assumption that
the cgroup filesystem is already populated once mount_setup() is
executed, which was true for my system. What I wasn't aware is that this
is the case only when another instance of systemd was running before
this one, which can happen if systemd is used in the initrd (for ex. by
dracut).

In case of a clean systemd start-up the cgroup filesystem is actually
being populated after mount_setup() and does not need relabelling as at
that moment the SELinux policy is already loaded. Since however the root
cgroup filesystem was remounted read-only in the meantime this operation
will now fail.

To fix this check for the filesystem mount flags before relabelling and
only remount ro->rw->ro if necessary and leave the filesystem read-write
otherwise.

Fixes #7901.

5 years agoNEWS: Warn about predictable network naming changes
Stuart Hayes [Wed, 14 Feb 2018 20:44:47 +0000 (15:44 -0500)]
NEWS: Warn about predictable network naming changes

5 years agoFix compilation w/o smack (#8593)
Zbigniew Jędrzejewski-Szmek [Wed, 28 Mar 2018 10:54:26 +0000 (12:54 +0200)]
Fix compilation w/o smack (#8593)

5 years agotree-wide: add bsearch_safe and use where appropriate
Zbigniew Jędrzejewski-Szmek [Sun, 25 Mar 2018 20:43:43 +0000 (22:43 +0200)]
tree-wide: add bsearch_safe and use where appropriate

Should fix #8557.

5 years agofuzz-unit-file: add __has_feature(memory_sanitizer) when skipping ListenNetlink=
Zbigniew Jędrzejewski-Szmek [Sun, 25 Mar 2018 20:26:13 +0000 (22:26 +0200)]
fuzz-unit-file: add __has_feature(memory_sanitizer) when skipping ListenNetlink=

https://clang.llvm.org/docs/MemorySanitizer.html#id5 documents this
check as the way to detect MemorySanitizer at compilation time. We
only need to skip the test if MemorySanitizer is used.

Also, use this condition in cg_slice_to_path(). There, the code that is
conditionalized is not harmful in any way (it's just unnecessary), so remove
the FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION condition.

Fixes #8482.

5 years agolabel: rework label_fix() implementations (#8583)
Lennart Poettering [Tue, 27 Mar 2018 05:38:26 +0000 (07:38 +0200)]
label: rework label_fix() implementations (#8583)

This reworks the SELinux and SMACK label fixing calls in a number of
ways:

1. The two separate boolean arguments of these functions are converted
   into a flags type LabelFixFlags.

2. The operations are now implemented based on O_PATH. This should
   resolve TTOCTTOU races between determining the label for the file
   system object and applying it, as it it allows to pin the object
   while we are operating on it.

3. When changing a label fails we'll query the label previously set, and
   if matches what we want to set anyway we'll suppress the error.

Also, all calls to label_fix() are now (void)ified, when we ignore the
return values.

Fixes: #8566
5 years agofs-util: add new CHASE_TRAIL_SLASH flag for chase_symlinks()
Lennart Poettering [Thu, 22 Mar 2018 18:54:24 +0000 (19:54 +0100)]
fs-util: add new CHASE_TRAIL_SLASH flag for chase_symlinks()

This rearranges chase_symlinks() a bit: if no special flags are
specified it will now revert to behaviour before
b12d25a8d631af00b200e7aa9dbba6ba4a4a59ff. However, if the new
CHASE_TRAIL_SLASH flag is specified it will follow the behaviour
introduced by that commit.

I wasn't sure which one to make the beaviour that requires specification
of a flag to enable. I opted to make the "append trailing slash"
behaviour the one to enable by a flag, following the thinking that the
function should primarily be used to generate a normalized path, and I
am pretty sure a path without trailing slash is the more "normalized"
one, as the trailing slash is not really a part of it, but merely a
"decorator" that tells various system calls to generate ENOTDIR if the
path doesn't refer to a path.

Or to say this differently: if the slash was part of normalization then
we really should add it in all cases when the final path is a directory,
not just when the user originally specified it.

Fixes: #8544
Replaces: #8545

5 years agoman: add a note about $XDG_SEAT and $XDG_VTNR to pam_systemd(8)
Zbigniew Jędrzejewski-Szmek [Fri, 23 Mar 2018 12:15:19 +0000 (13:15 +0100)]
man: add a note about $XDG_SEAT and $XDG_VTNR to pam_systemd(8)

Issue #6499 requests that a mention that those varibles can be set in the
environment is added. But the man page already says that. There isn't much
detail, but a man page does not need to and in this case should not include
all the details. Instead a note is added that those vars can be derived from
$DISPLAY.

Closes #6499.

5 years agoman: add missing headers to glib-event-glue.c
Zbigniew Jędrzejewski-Szmek [Wed, 21 Mar 2018 15:38:51 +0000 (16:38 +0100)]
man: add missing headers to glib-event-glue.c

5 years agoman: drop license header in glib-event-glue.c
Zbigniew Jędrzejewski-Szmek [Wed, 21 Mar 2018 19:02:49 +0000 (20:02 +0100)]
man: drop license header in glib-event-glue.c

We're moving towards just SPDX license identifiers, and the boilerplate
is especially annoying in a man page. Also adjust to the smaller indentation
to make the code fit better on a page.

5 years agotree-wide: warn when a directory path already exists but has bad mode/owner/type
Zbigniew Jędrzejewski-Szmek [Thu, 22 Mar 2018 12:03:41 +0000 (13:03 +0100)]
tree-wide: warn when a directory path already exists but has bad mode/owner/type

When we are attempting to create directory somewhere in the bowels of /var/lib
and get an error that it already exists, it can be quite hard to diagnose what
is wrong (especially for a user who is not aware that the directory must have
the specified owner, and permissions not looser than what was requested). Let's
print a warning in most cases. A warning is appropriate, because such state is
usually a sign of borked installation and needs to be resolved by the adminstrator.

$ build/test-fs-util

Path "/tmp/test-readlink_and_make_absolute" already exists and is not a directory, refusing.
   (or)
Directory "/tmp/test-readlink_and_make_absolute" already exists, but has mode 0775 that is too permissive (0755 was requested), refusing.
   (or)
Directory "/tmp/test-readlink_and_make_absolute" already exists, but is owned by 1001:1000 (1000:1000 was requested), refusing.

Assertion 'mkdir_safe(tempdir, 0755, getuid(), getgid(), MKDIR_WARN_MODE) >= 0' failed at ../src/test/test-fs-util.c:320, function test_readlink_and_make_absolute(). Aborting.

No functional change except for the new log lines.

5 years agobasic/mkdir: convert bool flag to enum
Zbigniew Jędrzejewski-Szmek [Thu, 22 Mar 2018 11:38:01 +0000 (12:38 +0100)]
basic/mkdir: convert bool flag to enum

In preparation for subsequent changes...

5 years agotests: skip udev-test when perl is not installed
Zbigniew Jędrzejewski-Szmek [Thu, 22 Mar 2018 07:34:21 +0000 (08:34 +0100)]
tests: skip udev-test when perl is not installed

5 years agotree-wide: tabs suck (#8527)
Lennart Poettering [Fri, 23 Mar 2018 14:21:35 +0000 (15:21 +0100)]
tree-wide: tabs suck (#8527)

5 years agologind: drop obsolete comment
Lennart Poettering [Wed, 21 Mar 2018 18:06:59 +0000 (19:06 +0100)]
logind: drop obsolete comment

The code matching this comment was removed in
a50df72b37ce2a7caf7775c70d18c3f9504b9e80 in 2014, let's drop the comment
too.

5 years agologind: use manager_get_user_by_pid() where appropriate
Lennart Poettering [Wed, 21 Mar 2018 18:06:21 +0000 (19:06 +0100)]
logind: use manager_get_user_by_pid() where appropriate

The current code reimplemented something like the
manager_get_user_by_pid() logic on its own, manually. Let's unify this.

5 years agologind: rework manager_get_{user|session}_by_pid() a bit
Lennart Poettering [Wed, 21 Mar 2018 18:04:45 +0000 (19:04 +0100)]
logind: rework manager_get_{user|session}_by_pid() a bit

Let's make sure we always initialize the return value if we return
non-negative.

Just a matter of coding style: we should always initialize our return
values when we return >= 0, and leave them unclobbered if we return < 0.

5 years agoconf-parse: small prettification
Lennart Poettering [Fri, 23 Feb 2018 19:50:22 +0000 (20:50 +0100)]
conf-parse: small prettification

Let's use first_word() instead of startswith(), it's more explanatory
and a bit more correct. Also, let's use the return value instead of
adding +9 when looking for the second part of the directive.

5 years agoconf-parser: let's explicitly deprecate .include in unit files
Lennart Poettering [Fri, 23 Feb 2018 19:46:38 +0000 (20:46 +0100)]
conf-parser: let's explicitly deprecate .include in unit files

.include lines are already deprecated somewhat, and for example
explicitly not mentioned in the documentation for this reason. Let's get
one step further and generatea warning when we encounter them (but still
process them).

Why are they deprecated? Because they are semantically awful — they
complicate stat() based mtime checks for configuration files and they
allow arbitrary loops we currently have zero protection against and
really shouldn't have to have.

5 years agoparse-util: similar to safe_atou16_full() add safe_atou_full()
Lennart Poettering [Wed, 21 Mar 2018 21:31:40 +0000 (22:31 +0100)]
parse-util: similar to safe_atou16_full() add safe_atou_full()

What's good for uint16_t is also good for unsigned.

This is preparation for: #8140

5 years agoparse-util: introduce safe_atou16_full()
Lennart Poettering [Wed, 21 Mar 2018 21:27:19 +0000 (22:27 +0100)]
parse-util: introduce safe_atou16_full()

safe_atou16_full() is like safe_atou16() but also takes a base
parameter. safe_atou16() is then implemented as inline function on top
of it, passing 0 as base. Similar safe_atoux16() is reworked as inline
function too, with 16 as base.

5 years agomacro: introduce new TAKE_FD() macro
Lennart Poettering [Thu, 22 Mar 2018 16:04:29 +0000 (17:04 +0100)]
macro: introduce new TAKE_FD() macro

This is similar to TAKE_PTR() but operates on file descriptors, and thus
assigns -1 to the fd parameter after returning it.

Removes 60 lines from our codebase. Pretty good too I think.

5 years agosleep-config: replace USE() macro with TAKE_PTR() usage
Lennart Poettering [Thu, 22 Mar 2018 15:59:46 +0000 (16:59 +0100)]
sleep-config: replace USE() macro with TAKE_PTR() usage

let's use the new generic macor instead of the locally defined, specific
one.

5 years agomacro: introduce TAKE_PTR() macro
Lennart Poettering [Thu, 22 Mar 2018 15:53:26 +0000 (16:53 +0100)]
macro: introduce TAKE_PTR() macro

This macro will read a pointer of any type, return it, and set the
pointer to NULL. This is useful as an explicit concept of passing
ownership of a memory area between pointers.

This takes inspiration from Rust:

https://doc.rust-lang.org/std/option/enum.Option.html#method.take

and was suggested by Alan Jenkins (@sourcejedi).

It drops ~160 lines of code from our codebase, which makes me like it.
Also, I think it clarifies passing of ownership, and thus helps
readability a bit (at least for the initiated who know the new macro)

5 years agoWhen mangling names, optionally emit a warning (#8400)
Zbigniew Jędrzejewski-Szmek [Wed, 21 Mar 2018 14:26:47 +0000 (15:26 +0100)]
When mangling names, optionally emit a warning (#8400)

The warning is not emitted for absolute paths like /dev/sda or /home, which are
converted to .device and .mount unit names without any fuss.

Most of the time it's unlikely that users use invalid unit names on purpose,
so let's warn them. Warnings are silenced when --quiet is used.

$ build/systemctl show -p Id hello@foo-bar/baz
Invalid unit name "hello@foo-bar/baz" was escaped as "hello@foo-bar-baz" (maybe you should use systemd-escape?)
Id=hello@foo-bar-baz.service

$ build/systemd-run --user --slice foo-bar/baz --unit foo-bar/foo true
Invalid unit name "foo-bar/foo" was escaped as "foo-bar-foo" (maybe you should use systemd-escape?)
Invalid unit name "foo-bar/baz" was escaped as "foo-bar-baz" (maybe you should use systemd-escape?)
Running as unit: foo-bar-foo.service

Fixes #8302.

5 years agoshared/conf-parser: fix outdated comment
Zbigniew Jędrzejewski-Szmek [Wed, 21 Mar 2018 12:15:01 +0000 (13:15 +0100)]
shared/conf-parser: fix outdated comment

5 years agouser-util: add new wrappers for reading/writing {passwd,shadow,gshadow} database...
Franck Bui [Wed, 21 Mar 2018 14:26:02 +0000 (15:26 +0100)]
user-util: add new wrappers for reading/writing {passwd,shadow,gshadow} database files (#8521)

The API povided by the glibc is too error-prone as one has to deal directly
with errno in order to detect if errors occured.

Suggested by Zbigniew.

5 years agococcinelle: always use fcntl(fd, FD_DUPFD, 3) instead of dup(fd)
Lennart Poettering [Tue, 20 Mar 2018 19:57:37 +0000 (20:57 +0100)]
coccinelle: always use fcntl(fd, FD_DUPFD, 3) instead of dup(fd)

Let's avoid fds 0…2 for safety reasons.

5 years agococcinelle: make use of DIV_ROUND_UP() wherever appropriate
Lennart Poettering [Tue, 20 Mar 2018 19:36:09 +0000 (20:36 +0100)]
coccinelle: make use of DIV_ROUND_UP() wherever appropriate

Let's use our macros where we can

5 years agotime-sync-wait: add service (#8494)
Peter A. Bigot [Wed, 21 Mar 2018 11:42:04 +0000 (06:42 -0500)]
time-sync-wait: add service (#8494)

This one-shot service waits until the kernel time has been set to
synchronized.

5 years agodissect: add dissect_image_and_warn() that unifies error message generation for disse...
Lennart Poettering [Wed, 21 Mar 2018 11:10:01 +0000 (12:10 +0100)]
dissect: add dissect_image_and_warn() that unifies error message generation for dissect_image() (#8517)

5 years agodoc: update TODO
Yu Watanabe [Thu, 8 Mar 2018 03:53:43 +0000 (12:53 +0900)]
doc: update TODO

5 years agodissect: add dissect_image_and_warn() that unifies error message generation for disse...
Lennart Poettering [Wed, 21 Mar 2018 11:10:01 +0000 (12:10 +0100)]
dissect: add dissect_image_and_warn() that unifies error message generation for dissect_image() (#8517)

5 years agodoc: update TODO
Yu Watanabe [Thu, 8 Mar 2018 03:53:43 +0000 (12:53 +0900)]
doc: update TODO

5 years agomeson.build: Fix wron mask ending and some missing trailing whitespaces on mask blocks.
Sven Eden [Fri, 29 Jun 2018 05:37:43 +0000 (07:37 +0200)]
meson.build: Fix wron mask ending and some missing trailing whitespaces on mask blocks.

5 years agojournal: make the compression threshold tunable
Alex Gartrell [Tue, 27 Feb 2018 17:37:23 +0000 (09:37 -0800)]
journal: make the compression threshold tunable

Allow a user to set a number of bytes as Compress to use as the compression
threshold.

5 years agodissect: add dissect_image_and_warn() that unifies error message generation for disse...
Lennart Poettering [Wed, 21 Mar 2018 11:10:01 +0000 (12:10 +0100)]
dissect: add dissect_image_and_warn() that unifies error message generation for dissect_image() (#8517)

5 years agodoc: update TODO
Yu Watanabe [Thu, 8 Mar 2018 03:53:43 +0000 (12:53 +0900)]
doc: update TODO

5 years agodissect: add dissect_image_and_warn() that unifies error message generation for disse...
Lennart Poettering [Wed, 21 Mar 2018 11:10:01 +0000 (12:10 +0100)]
dissect: add dissect_image_and_warn() that unifies error message generation for dissect_image() (#8517)

5 years agofileio: port parse_env_file_internal() to use _cleanup_free_ (#8511)
Lennart Poettering [Wed, 21 Mar 2018 10:59:56 +0000 (11:59 +0100)]
fileio: port parse_env_file_internal() to use _cleanup_free_ (#8511)

5 years agoVersion 238.1 Release
Sven Eden [Mon, 25 Jun 2018 14:41:00 +0000 (16:41 +0200)]
Version 238.1 Release

5 years agoFix include mask in API header sd-event.h to be C90 conformant. (Closes #69)
Sven Eden [Thu, 21 Jun 2018 17:40:15 +0000 (19:40 +0200)]
Fix include mask in API header sd-event.h to be C90 conformant. (Closes #69)

5 years agoFix foul typo in f281944
Sven Eden [Thu, 21 Jun 2018 14:18:49 +0000 (16:18 +0200)]
Fix foul typo in f281944

5 years agoPrep v238: Regenerate (and secure) lost man rules (See issue #68)
Sven Eden [Thu, 21 Jun 2018 07:15:15 +0000 (09:15 +0200)]
Prep v238: Regenerate (and secure) lost man rules (See issue #68)

5 years agoFix cgroup directory mounting:
Sven Eden [Wed, 20 Jun 2018 17:13:05 +0000 (19:13 +0200)]
Fix cgroup directory mounting:

A little misunderstanding has been fixed, and elogind now mounts the following
directories, if (and only if) it has to act as its own cgroups controller.

  * -Ddefault-hierarchy=legacy  : /sys/fs/cgroup         as tmpfs
                                  /sys/fs/cgroup/elogind as cgroup

  * -Ddefault-hierarchy=hybrid  : The same as with 'legacy', plus
                                  /sys/fs/cgroup/unified as cgroup2

  * -Ddefault-hierarchy=unified : /sys/fs/cgroup2        as cgroup2

5 years agoFix accidental dbus closing in update_utmp() (#50)
Sven Eden [Tue, 19 Jun 2018 21:32:59 +0000 (23:32 +0200)]
Fix accidental dbus closing in update_utmp() (#50)

When updating utmp on reboot and poweroff, the managers dbus
connection was copied and then closed and invalidated.

As the utmp update in elogind does not need a dbus connection at all,
the copying and the closing was removed.

This fixes elogind to become unresponsive when calling for poweroff,
halt or reboot.

Closes: #50
5 years agoPrep v238: fix forking of the poweroff programs in run_helper()
Sven Eden [Tue, 19 Jun 2018 21:29:56 +0000 (23:29 +0200)]
Prep v238: fix forking of the poweroff programs in run_helper()

5 years agopwx_local: Remove obsolete backup
Sven Eden [Mon, 18 Jun 2018 15:39:12 +0000 (17:39 +0200)]
pwx_local: Remove obsolete backup

5 years agoFix elogind debug mode:
Sven Eden [Mon, 18 Jun 2018 15:33:08 +0000 (17:33 +0200)]
Fix elogind debug mode:

When switched from autotools to meson, config.h changed fundamentally.

Although enabled values are still
  #define HAVE_FOO 1
the disabled values are nolonger undef, but now
  #define HAVE_FOO 0

Therefore all instances of
  #ifdef ENABLE_DEBUG_ELOGIND
have been changed to
  #if ENABLE_DEBUG_ELOGIND

5 years agoPrep v238: Disallow killing of lingering user processes even if forced.
Sven Eden [Mon, 18 Jun 2018 07:23:46 +0000 (09:23 +0200)]
Prep v238: Disallow killing of lingering user processes even if forced.

5 years agoREADME: Update information about mesonconf versus 'meson configure'
Sven Eden [Mon, 18 Jun 2018 07:11:03 +0000 (09:11 +0200)]
README: Update information about mesonconf versus 'meson configure'

5 years agotools: Fix executable bit on scripts that ost it somehow.
Sven Eden [Mon, 18 Jun 2018 06:49:46 +0000 (08:49 +0200)]
tools: Fix executable bit on scripts that ost it somehow.

5 years agoPrep v238: Do not kill user processes if not forced and the user is lingering.
Sven Eden [Mon, 18 Jun 2018 06:43:58 +0000 (08:43 +0200)]
Prep v238: Do not kill user processes if not forced and the user is lingering.

5 years agoCleaned up includes in elogind-dbus.c
Sven Eden [Wed, 13 Jun 2018 16:04:31 +0000 (18:04 +0200)]
Cleaned up includes in elogind-dbus.c

5 years agomanager_inhibit_timeout_handler() can be static again.
Sven Eden [Wed, 13 Jun 2018 15:52:53 +0000 (17:52 +0200)]
manager_inhibit_timeout_handler() can be static again.

5 years agoMove method_do_shutdown_or_sleep() and its callers back to logind-sbus.c
Sven Eden [Wed, 13 Jun 2018 15:51:18 +0000 (17:51 +0200)]
Move method_do_shutdown_or_sleep() and its callers back to logind-sbus.c

5 years agoMove bus_manager_shutdown_or_sleep_now_or_later() back to logind-dbus.c
Sven Eden [Wed, 13 Jun 2018 15:37:19 +0000 (17:37 +0200)]
Move bus_manager_shutdown_or_sleep_now_or_later() back to logind-dbus.c

5 years agoMove delay_shutdown_or_sleep() back to logind-dbus.c
Sven Eden [Wed, 13 Jun 2018 06:13:23 +0000 (08:13 +0200)]
Move delay_shutdown_or_sleep() back to logind-dbus.c

5 years agoMove manager_dispatch_delayed() back to logind-dbus.c
Sven Eden [Wed, 13 Jun 2018 06:08:10 +0000 (08:08 +0200)]
Move manager_dispatch_delayed() back to logind-dbus.c

5 years agologin/elogind-dbus.c: Sync the following methods from systemctl.c:
Sven Eden [Wed, 13 Jun 2018 16:03:08 +0000 (18:03 +0200)]
login/elogind-dbus.c: Sync the following methods from systemctl.c:

 * manager_scheduled_shutdown_handler()

5 years agologin/eloginctl.c: Sync the following methods from systemctl.c:
Sven Eden [Tue, 12 Jun 2018 17:41:52 +0000 (19:41 +0200)]
login/eloginctl.c: Sync the following methods from systemctl.c:

 * check_inhibitors()          => logind_check_inhibitors()
 * elogind_reboot()            => logind_reboot()
 * elogind_schedule_shutdown() => logind_schedule_shutdown()
 * elogind_set_wall_message()  => logind_set_wall_message()

Further introduce both -q/--quiet and --dry-run.

5 years agoAdd dry_run support to manager_scheduled_shutdown_handler()
Sven Eden [Wed, 13 Jun 2018 05:58:05 +0000 (07:58 +0200)]
Add dry_run support to manager_scheduled_shutdown_handler()

5 years agoPrep v238: Make a real distinction between 'halt' and 'poweroff'.
Sven Eden [Tue, 12 Jun 2018 06:03:27 +0000 (08:03 +0200)]
Prep v238: Make a real distinction between 'halt' and 'poweroff'.

5 years agoPrep v238: Remove getnameinfo_pretty(), it is no longer used.
Sven Eden [Wed, 6 Jun 2018 06:34:34 +0000 (08:34 +0200)]
Prep v238: Remove getnameinfo_pretty(), it is no longer used.

5 years agoPrep v238: Mask cg_trim() call in manager_shutdown_cgroup() as elogind is not init.
Sven Eden [Wed, 6 Jun 2018 05:37:14 +0000 (07:37 +0200)]
Prep v238: Mask cg_trim() call in manager_shutdown_cgroup() as elogind is not init.

5 years agosrc/last_mutual_commits.csv: Migrated to current upstream branch.
Sven Eden [Tue, 5 Jun 2018 17:22:25 +0000 (19:22 +0200)]
src/last_mutual_commits.csv: Migrated to current upstream branch.

5 years agobasic/fs-util: skip fsync_directory_of_file() if /proc/self/fd/ is not available...
Zbigniew Jędrzejewski-Szmek [Tue, 20 Mar 2018 17:20:01 +0000 (18:20 +0100)]
basic/fs-util: skip fsync_directory_of_file() if /proc/self/fd/ is not available (#8386)

When systemd is running under lorax (in Fedora compose process), it'd think that
it failed to write /etc/machine-id, even though the write succeeded, because
fsync_directory_of_file() would fail, because /proc/self/fd/ is not available.
fsync_directory_of_file() is mostly an additional safety net, so I think it's best
to just silently ignore the error.

Strace of pid1:
35791 stat("/etc", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
35791 openat(AT_FDCWD, "/etc/machine-id", O_RDWR|O_CREAT|O_NOCTTY|O_CLOEXEC, 0444) = 3
35791 umask(022)                        = 000
35791 read(3, "", 38)                   = 0
35791 openat(AT_FDCWD, "/var/lib/dbus/machine-id", O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC) = -1 ENOENT (No such file o
r directory)
35791 openat(AT_FDCWD, "/sys/class/dmi/id/product_name", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 openat(AT_FDCWD, "/sys/class/dmi/id/sys_vendor", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 openat(AT_FDCWD, "/sys/class/dmi/id/board_vendor", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 openat(AT_FDCWD, "/sys/class/dmi/id/bios_vendor", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 access("/proc/xen", F_OK)         = -1 ENOENT (No such file or directory)
35791 openat(AT_FDCWD, "/sys/hypervisor/type", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 openat(AT_FDCWD, "/proc/cpuinfo", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
35791 getrandom("\xb8\x82\xed\xd4\x35\x11\xd0\xeb\xa6\x79\xd7\x31\x6e\x7b\x99\xce", 16, GRND_NONBLOCK) = 16
35791 writev(2, [{iov_base="Initializing machine ID from random generator.", iov_len=46}, {iov_base="\n", iov_len=1}],
 2) = 47
35791 lseek(3, 0, SEEK_SET)             = 0
35791 ftruncate(3, 0)                   = 0
35791 write(3, "b882edd4351140eba679d7316e7b99ce\n", 33) = 33
35791 fsync(3)                          = 0
35791 fstat(3, {st_mode=S_IFREG|0444, st_size=33, ...}) = 0
35791 readlinkat(AT_FDCWD, "/proc/self/fd/3", 0x564df8c694c0, 99) = -1 ENOENT (No such file or directory)
35791 close(3)                          = 0
35791 umask(022)                        = 022
35791 openat(AT_FDCWD, "/run/machine-id", O_WRONLY|O_CREAT|O_NOCTTY|O_TRUNC|O_CLOEXEC, 0444) = 3
35791 write(3, "b882edd4351140eba679d7316e7b99ce\n", 33) = 33
35791 close(3)                          = 0
35791 umask(022)                        = 022
35791 mount("/run/machine-id", "/etc/machine-id", NULL, MS_BIND, NULL) = 0
35791 writev(2, [{iov_base="Installed transient /etc/machine-id file.", iov_len=41}, {iov_base="\n", iov_len=1}], 2) = 42
35791 mount(NULL, "/etc/machine-id", NULL, MS_RDONLY|MS_REMOUNT|MS_BIND, NULL) = 0

https://bugzilla.redhat.com/show_bug.cgi?id=1552843
(cherry picked from commit 3ceae1bc14d2da3fc1fe4753d6657759012256dc)

5 years agocore: dont't remount /sys/fs/cgroup for relabel if not needed (#8595)
Krzysztof Nowicki [Wed, 28 Mar 2018 11:36:33 +0000 (13:36 +0200)]
core: dont't remount /sys/fs/cgroup for relabel if not needed (#8595)

The initial fix for relabelling the cgroup filesystem for
SELinux delivered in commit 8739f23e3 was based on the assumption that
the cgroup filesystem is already populated once mount_setup() is
executed, which was true for my system. What I wasn't aware is that this
is the case only when another instance of systemd was running before
this one, which can happen if systemd is used in the initrd (for ex. by
dracut).

In case of a clean systemd start-up the cgroup filesystem is actually
being populated after mount_setup() and does not need relabelling as at
that moment the SELinux policy is already loaded. Since however the root
cgroup filesystem was remounted read-only in the meantime this operation
will now fail.

To fix this check for the filesystem mount flags before relabelling and
only remount ro->rw->ro if necessary and leave the filesystem read-write
otherwise.

Fixes #7901.

(cherry picked from commit 6f7729c1767998110c4460c85c94435c5782a613)

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

5 years agoconf-parser: accept trailing backslash at the end of the file (#8941)
Filipe Brandenburger [Thu, 10 May 2018 01:10:07 +0000 (18:10 -0700)]
conf-parser: accept trailing backslash at the end of the file (#8941)

This makes it behave the same whether there is a blank line or not at
the end of the file.  This is also consistent with the behavior of the
shell on a shell script that ends on a trailing backslash at the last
line.

Added tests to test_config_parse(), which only pass if the corresponding
change to config_parse() is included.

(cherry picked from commit 4f29e0db127dce9e1a28af4d7bf88c124ba257b7)

5 years agologin: do not wall message on cancelling shutdown when Manager.enable_wall_messages...
Yu Watanabe [Mon, 7 May 2018 01:16:04 +0000 (10:16 +0900)]
login: do not wall message on cancelling shutdown when Manager.enable_wall_messages is false

Fixes #8904.

(cherry picked from commit 6e78fa4afd474dae984f3ee4a8477c623296a519)

5 years agovirt: if we detect Xen by DMI, trust that over CPUID
Lennart Poettering [Mon, 30 Apr 2018 10:23:03 +0000 (12:23 +0200)]
virt: if we detect Xen by DMI, trust that over CPUID

Apparently Xen sometimes lies about its identity when queried via CPUID.
Let's hence prefer DMI tests for CPUID

Fixes: #8844
(cherry picked from commit f2fe2865cd19cd4318b82d01b9b62d22b1697b3a)

5 years agomeson: drop 'name' argument in cc.has_argument() (#8878)
Yu Watanabe [Wed, 2 May 2018 08:05:51 +0000 (17:05 +0900)]
meson: drop 'name' argument in cc.has_argument() (#8878)

(cherry picked from commit b0903bb585d2158f78a4cf603fde4aed5474e2b9)

5 years agoadd __nr_statx defines for extra architectures (#8872)
Adam Duskett [Wed, 2 May 2018 08:04:50 +0000 (04:04 -0400)]
add __nr_statx defines for extra architectures (#8872)

This includes:
 - arm
 - arm64
 - alpha
 - powerpc64
 - sparc

Taken from kernel 4.16.6

(cherry picked from commit 773c84349d80c7a6f818f5909a160ddb7337987f)

5 years agobasic/log: always ignore errno from the enviornment (#8841)
Zbigniew Jędrzejewski-Szmek [Fri, 27 Apr 2018 16:00:58 +0000 (18:00 +0200)]
basic/log: always ignore errno from the enviornment (#8841)

This extends the change done in b29f6480ec to other logging functions.

This actually fixes some bugs in callers of log_struct(), for example
config_parse_alias() called 'return log_syntax(..., 0, ...)' which could result
in a bogus non-zero return value.

Calls to log_object() and log_format_iovec() — which is only used by
server_driver_message() — appear correct.

(cherry picked from commit d1a1f0aaf0d2f08c60d1e0d32e646439d99f58dc)

5 years agocgroup-util: fix enabling of controllers (#8816)
Antique [Thu, 26 Apr 2018 10:37:35 +0000 (12:37 +0200)]
cgroup-util: fix enabling of controllers (#8816)

If enabling controller for some reason fails we need to clear error
for the FILE stream.  Enabling remaining controllers would otherwise
fail because write_string_stream_ts() checks for ferror(f) and returns
-EIO if there is one.

Broken by commit <77fa610b22>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 96aa6591d1103b8cca9a4db80ba478a18bdf3e9a)

5 years agomeson: drop 'name' argument in cc.has_argument() (#8823)
Yu Watanabe [Thu, 26 Apr 2018 08:53:10 +0000 (17:53 +0900)]
meson: drop 'name' argument in cc.has_argument() (#8823)

This fixes the following warning with clang and meson-0.46.0,
```
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
Compiler for C supports arguments -Wno-typedef-redefinition: YES
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
Compiler for C supports arguments -Wno-gnu-variable-sized-type-not-at-end: YES
```

(cherry picked from commit 8ac42236b09d2f21f962bf72fcbeee24502f959f)

5 years agoman: fix description of --value option for loginctl (#8820)
Yu Watanabe [Thu, 26 Apr 2018 07:51:11 +0000 (16:51 +0900)]
man: fix description of --value option for loginctl (#8820)

(cherry picked from commit ad628501b95b83ac6c0b42bb69db7e1b38c0ff13)

5 years agofileio.c: fix incorrect mtime
Chris Lesiak [Tue, 24 Apr 2018 14:50:42 +0000 (09:50 -0500)]
fileio.c: fix incorrect mtime

A regression was introduced that caused the mtime of /etc/.updated
and /var/.updated to be the current time when systemd-update-done
ran instead of being copied from /usr.

This was nearly fixed, but due to fflush being called after mtime
was carefully set, it was overwritten with the current time.

Regression introduced in 872c40396384f9fa89b01baf4e739d28ed590299

A fix was just missed in 39c38d773fbe2b4f76ff29ecd3344640efb9a86c

Fixes #8806

(cherry picked from commit be83711c7eb6a09e0d0c529c427cebcae87c0c1f)

5 years agobasic/log: do not use global errno in log_*_errno()
Zbigniew Jędrzejewski-Szmek [Tue, 24 Apr 2018 11:57:38 +0000 (13:57 +0200)]
basic/log: do not use global errno in log_*_errno()

Quoting https://github.com/systemd/systemd/pull/8760#discussion_r183321060:

> When we originally added the errno patching we went for a "best of both
> worlds" approach, i.e. that we override errno if an error is specified, but
> if no error is specified (i.e. 0 is passed as error code) then we use the
> previously set errno, similar in style how plain `printf()` would do it. In
> retrospect I think we almost never purposefully made use of the second,
> i.e. the plain `printf()` logic, but we multiple times ran into this case
> accidentally and introduced a bug. Hence yes, it probably makes sense to
> switch this over, and consistently ignore the `errno` already set and always
> override it with the error passed in. The only problem I see with that is: I
> wonder if there might be a case or two lurking somewhere where we actually
> made use of the "best of both worlds" approach, and if so, if we can detect
> where... (But then again, even if there is, and we fail to find those cases,
> maybe that's not all bad, as it's just a few new bugs against probably fixing
> many more old and future bugs, if you follow what I mean).

I scanned our codebase, and found some bugs in the value passed to log_*_errno,
but no intentional cases of error=0 being passed.

(cherry picked from commit b29f6480eca0550ba65d30fbece8dd4d4bfe666d)

5 years agobasic/audit-util: always log the reason when disabling audit logs
Zbigniew Jędrzejewski-Szmek [Tue, 24 Apr 2018 11:46:58 +0000 (13:46 +0200)]
basic/audit-util: always log the reason when disabling audit logs

This state is cached, and it's seems OK to log at least once.

(cherry picked from commit 13bb68bbe37f0b39cd45234b09fb1a1da8302020)

5 years agoISO-C compatibility: Remove empty initializer (#8713)
Leonard [Thu, 12 Apr 2018 19:31:19 +0000 (21:31 +0200)]
ISO-C compatibility: Remove empty initializer (#8713)

ISO-C doesn't allow empty initializers, so replace it by explicitly
initializing to zero.

Also add braces because x is a union and we initialize a subobject, so
a compiler might warn about suggesting braces.  Shut that up.

(cherry picked from commit d579a56c397a1aeaa490032a9f7aabd82124f1c8)

5 years agotmpfiles: add a new return code for "operational failure" when processing
Zbigniew Jędrzejewski-Szmek [Thu, 29 Mar 2018 14:19:33 +0000 (16:19 +0200)]
tmpfiles: add a new return code for "operational failure" when processing

Things can fail, and we have no control over it:
- file system issues (immutable bits, file system errors, MAC refusals, etc)
- kernel refusing certain arguments when writing to /proc/sys or /sys
Let's add a new code for the case where we parsed configuration but failed
to execute it because of external errors.

(cherry picked from commit bb9947be2fa308d198b63b30e494ade5d68e5109)

5 years agocore: skip the removal of cgroups in the TEST_RUN_MINIMAL mode (#8622)
Evgeny Vereshchagin [Tue, 3 Apr 2018 13:04:22 +0000 (16:04 +0300)]
core: skip the removal of cgroups in the TEST_RUN_MINIMAL mode (#8622)

When `systemd` is run in the TEST_RUN_MINIMAL mode, it doesn't really
set up cgroups, so it shouldn't try to remove anything.

Closes https://github.com/systemd/systemd/issues/8474.

(cherry picked from commit f6c63f6fc90040f0017a7cc37f3a05d5b86226d7)

5 years agosystemd-inhibit: ignore signal interrupt from keyboard (#8569)
Christian Hesse [Wed, 28 Mar 2018 19:58:10 +0000 (21:58 +0200)]
systemd-inhibit: ignore signal interrupt from keyboard (#8569)

By default both processes, systemd-inhibit and the forked one, receive
the signals. Pressing Ctrl+C on the keyboard results in SIGINT being
sent to the processes, followed by SIGTERM being sent to the forked
process when systemd-inhibit exits. This can cause trouble when the
forked process does not clean up properly but exit immediately.

Instead make systemd-inhibit ignore SIGINT, leaving it to the forked
process to clean up and exit.

(cherry picked from commit 106f12a08fcacef713438fc055872592399deeed)

5 years agostat-util: fix fd_is_network_ns()
Lennart Poettering [Fri, 23 Mar 2018 08:47:04 +0000 (09:47 +0100)]
stat-util: fix fd_is_network_ns()

This was broken in 77f9fa3b8ea46c27e5a5e9270f71bf1b4000c3e0. My fault.

Fixes: #8543
(cherry picked from commit 29f74559d4dc6ea41232233d32f1a92bcee43626)

5 years agosd-bus: drop fd_nonblock() calls that are implied by rearrange_stdio() (#8514)
Lennart Poettering [Wed, 21 Mar 2018 10:46:49 +0000 (11:46 +0100)]
sd-bus: drop fd_nonblock() calls that are implied by rearrange_stdio() (#8514)

(cherry picked from commit 68b525d1d1e8153cbc2e2354fa650aa165f7a434)

5 years agomeson: add note about coreutils version with ln --relative
Zbigniew Jędrzejewski-Szmek [Fri, 9 Mar 2018 07:56:23 +0000 (08:56 +0100)]
meson: add note about coreutils version with ln --relative

https://bugs.freedesktop.org/show_bug.cgi?id=90799
(cherry picked from commit cd001016a166bb849c454e7b5cdb58053f34935b)

5 years agobasic/macros: rename noreturn into _noreturn_ (#8456)
Franck Bui [Thu, 15 Mar 2018 05:23:46 +0000 (06:23 +0100)]
basic/macros: rename noreturn into _noreturn_ (#8456)

"noreturn" is reserved and can be used in other header files we include:

  [   16s] In file included from /usr/include/gcrypt.h:30:0,
  [   16s]                  from ../src/journal/journal-file.h:26,
  [   16s]                  from ../src/journal/journal-vacuum.c:31:
  [   16s] /usr/include/gpg-error.h:1544:46: error: expected ‘,’ or ‘;’ before ‘)’ token
  [   16s]  void gpgrt_log_bug (const char *fmt, ...)    GPGRT_ATTR_NR_PRINTF(1,2);

Here we include grcrypt.h (which in turns include gpg-error.h) *after* we
"noreturn" was defined in macro.h.

(cherry picked from commit 848e863acc51ecfb0f3955c498874588201d9130)

5 years agotests: make / private after creating a mount namespace
Evegeny Vereshchagin [Fri, 9 Mar 2018 01:10:42 +0000 (01:10 +0000)]
tests: make / private after creating a mount namespace

so that the test never affects the root namespace.

(cherry picked from commit c58fd466a313a1f93df1792822e358c67990bcdf)

5 years agocore: ignore errors from cg_create_and_attach() in test mode (#8401)
Michal Sekletar [Fri, 9 Mar 2018 22:30:32 +0000 (23:30 +0100)]
core: ignore errors from cg_create_and_attach() in test mode (#8401)

Reproducer:

$ meson build && cd build
$ ninja
$ sudo useradd test
$ sudo su test
$ ./systemd --system --test
...
Failed to create /user.slice/user-1000.slice/session-6.scope/init.scope control group: Permission denied
Failed to allocate manager object: Permission denied

Above error message is caused by the fact that user test didn't have its
own session and we tried to set up init.scope already running as user
test in the directory owned by different user.

Let's try to setup cgroup hierarchy, but if that fails return error only
when not running in the test mode.

Fixes #8072

(cherry picked from commit aa77e234fce7413b7dd64f99ea51450f2e2e9dbd)

5 years agomeson: avoid warning about comparison of bool and string
Zbigniew Jędrzejewski-Szmek [Fri, 9 Mar 2018 13:21:08 +0000 (14:21 +0100)]
meson: avoid warning about comparison of bool and string

meson.build:2907: WARNING: Trying to compare values of different types (bool, str) using ==.
The result of this is undefined and will become a hard error in a future Meson release.

(cherry picked from commit af4d7860c4e757f34a02ca73a0b14c73c18f8b30)

5 years agobasic/cgroup-util: remove unused variable
Zbigniew Jędrzejewski-Szmek [Tue, 6 Mar 2018 08:37:11 +0000 (09:37 +0100)]
basic/cgroup-util: remove unused variable

(cherry picked from commit eef03d70c1bedb3aabd4e2bcf10ab1f2678443bf)