chiark / gitweb /
elogind.git
6 years agobus-util: treat an empty string as a NULL
Lennart Poettering [Wed, 17 Aug 2016 17:03:44 +0000 (19:03 +0200)]
bus-util: treat an empty string as a NULL

Instead of ignoring empty strings retrieved via the bus, treat them as NULL, as
it's customary in elogind.

6 years agobus-util: support mapping signed integers with bus_map_properties()
Lennart Poettering [Wed, 17 Aug 2016 17:00:12 +0000 (19:00 +0200)]
bus-util: support mapping signed integers with bus_map_properties()

Let's make sure we can read the exit code/status properties exposed by PID 1
properly. Let's reuse the existing code for unsigned fields, as we just use it
to copy words around, and don't calculate it.

6 years agocore: rename cg_unified() to cg_all_unified()
Tejun Heo [Mon, 15 Aug 2016 22:13:36 +0000 (18:13 -0400)]
core: rename cg_unified() to cg_all_unified()

A following patch will update cgroup handling so that the elogind controller
(/sys/fs/cgroup/elogind) can use the unified hierarchy even if the kernel
resource controllers are on the legacy hierarchies.  This would require
distinguishing whether all controllers are on cgroup v2 or only the elogind
controller is.  In preparation, this patch renames cg_unified() to
cg_all_unified().

This patch doesn't cause any functional changes.

6 years agocore: use the unified hierarchy for the elogind cgroup controller hierarchy
Tejun Heo [Mon, 15 Aug 2016 22:13:36 +0000 (18:13 -0400)]
core: use the unified hierarchy for the elogind cgroup controller hierarchy

Currently, elogind uses either the legacy hierarchies or the unified hierarchy.
When the legacy hierarchies are used, elogind uses a named legacy hierarchy
mounted on /sys/fs/cgroup/elogind without any kernel controllers for process
management.  Due to the shortcomings in the legacy hierarchy, this involves a
lot of workarounds and complexities.

Because the unified hierarchy can be mounted and used in parallel to legacy
hierarchies, there's no reason for elogind to use a legacy hierarchy for
management even if the kernel resource controllers need to be mounted on legacy
hierarchies.  It can simply mount the unified hierarchy under
/sys/fs/cgroup/elogind and use it without affecting other legacy hierarchies.
This disables a significant amount of fragile workaround logics and would allow
using features which depend on the unified hierarchy membership such bpf cgroup
v2 membership test.  In time, this would also allow deleting the said
complexities.

This patch updates elogind so that it prefers the unified hierarchy for the
elogind cgroup controller hierarchy when legacy hierarchies are used for kernel
resource controllers.

* cg_unified(@controller) is introduced which tests whether the specific
  controller in on unified hierarchy and used to choose the unified hierarchy
  code path for process and service management when available.  Kernel
  controller specific operations remain gated by cg_all_unified().

* "elogind.legacy_elogind_cgroup_controller" kernel argument can be used to
  force the use of legacy hierarchy for elogind cgroup controller.

* nspawn: By default nspawn uses the same hierarchies as the host.  If
  UNIFIED_CGROUP_HIERARCHY is set to 1, unified hierarchy is used for all.  If
  0, legacy for all.

* nspawn: arg_unified_cgroup_hierarchy is made an enum and now encodes one of
  three options - legacy, only elogind controller on unified, and unified.  The
  value is passed into mount setup functions and controls cgroup configuration.

* nspawn: Interpretation of SYSTEMD_CGROUP_CONTROLLER to the actual mount
  option is moved to mount_legacy_cgroup_hierarchy() so that it can take an
  appropriate action depending on the configuration of the host.

v2: - CGroupUnified enum replaces open coded integer values to indicate the
      cgroup operation mode.
    - Various style updates.

v3: Fixed a bug in detect_unified_cgroup_hierarchy() introduced during v2.

v4: Restored legacy container on unified host support and fixed another bug in
    detect_unified_cgroup_hierarchy().

6 years agocore: add Ref()/Unref() bus calls for units
Lennart Poettering [Mon, 15 Aug 2016 16:12:01 +0000 (18:12 +0200)]
core: add Ref()/Unref() bus calls for units

This adds two (privileged) bus calls Ref() and Unref() to the Unit interface.
The two calls may be used by clients to pin a unit into memory, so that various
runtime properties aren't flushed out by the automatic GC. This is necessary
to permit clients to race-freely acquire runtime results (such as process exit
status/code or accumulated CPU time) on successful service termination.

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

Transient units may also gain a reference at the time of creation, via the new
AddRef property (that is only defined for transient units at the time of
creation).

6 years agosd-bus: add a "recursive" mode to sd_bus_track
Lennart Poettering [Mon, 15 Aug 2016 12:58:09 +0000 (14:58 +0200)]
sd-bus: add a "recursive" mode to sd_bus_track

This adds an optional "recursive" counting mode to sd_bus_track. If enabled
adding the same name multiple times to an sd_bus_track object is counted
individually, so that it also has to be removed the same number of times before
it is gone again from the tracking object.

This functionality is useful for implementing local ref counted objects that
peers make take references on.

6 years agocore: add cgroup CPU controller support on the unified hierarchy
Tejun Heo [Sun, 7 Aug 2016 13:45:39 +0000 (09:45 -0400)]
core: add cgroup CPU controller support on the unified hierarchy

Unfortunately, due to the disagreements in the kernel development community,
CPU controller cgroup v2 support has not been merged and enabling it requires
applying two small out-of-tree kernel patches.  The situation is explained in
the following documentation.

 https://git.kernel.org/cgit/linux/kernel/git/tj/cgroup.git/tree/Documentation/cgroup-v2-cpu.txt?h=cgroup-v2-cpu

While it isn't clear what will happen with CPU controller cgroup v2 support,
there are critical features which are possible only on cgroup v2 such as
buffered write control making cgroup v2 essential for a lot of workloads.  This
commit implements elogind CPU controller support on the unified hierarchy so
that users who choose to deploy CPU controller cgroup v2 support can easily
take advantage of it.

On the unified hierarchy, "cpu.weight" knob replaces "cpu.shares" and "cpu.max"
replaces "cpu.cfs_period_us" and "cpu.cfs_quota_us".  [Startup]CPUWeight config
options are added with the usual compat translation.  CPU quota settings remain
unchanged and apply to both legacy and unified hierarchies.

v2: - Error in man page corrected.
    - CPU config application in cgroup_context_apply() refactored.
    - CPU accounting now works on unified hierarchy.

6 years agoadd a new tool for creating transient mount and automount units
Lennart Poettering [Fri, 5 Aug 2016 22:32:46 +0000 (00:32 +0200)]
add a new tool for creating transient mount and automount units

This adds "elogind-mount" which is for transient mount and automount units what
"elogind-run" is for transient service, scope and timer units.

The tool allows establishing mounts and automounts during runtime. It is very
similar to the usual /bin/mount commands, but can pull in additional
dependenices on access (for example, it pulls in fsck automatically), an take
benefit of the automount logic.

This tool is particularly useful for mount removable file systems (such as USB
sticks), as the automount logic (together with automatic unmount-on-idle), as
well as automatic fsck on first access ensure that the removable file system
has a high chance to remain in a fully clean state even when it is unplugged
abruptly, and returns to a clean state on the next re-plug.

This is a follow-up for #2471, as it adds a simple client-side for the
transient automount logic added in that PR.

In later work it might make sense to invoke this tool automatically from udev
rules in order to implement a simpler and safer version of removable media
management á la udisks.

6 years agoutil-lib: unify parsing of nice level values
Lennart Poettering [Fri, 5 Aug 2016 09:17:08 +0000 (11:17 +0200)]
util-lib: unify parsing of nice level values

This adds parse_nice() that parses a nice level and ensures it is in the right
range, via a new nice_is_valid() helper. It then ports over a number of users
to this.

No functional changes.

6 years agofileio: fix MIN/MAX mixup (#3896)
Vito Caputo [Fri, 5 Aug 2016 04:09:23 +0000 (21:09 -0700)]
fileio: fix MIN/MAX mixup (#3896)

The intention is to clamp the value to READ_FULL_BYTES_MAX, which
would be the minimum of the two.

6 years agobasic/set: remove some spurious spaces
Zbigniew Jędrzejewski-Szmek [Fri, 5 Aug 2016 00:36:10 +0000 (20:36 -0400)]
basic/set: remove some spurious spaces

6 years agofileio: fix read_full_stream() bugs (#3887)
Vito Caputo [Thu, 4 Aug 2016 20:52:02 +0000 (13:52 -0700)]
fileio: fix read_full_stream() bugs (#3887)

read_full_stream() _always_ allocated twice the memory needed, due to
only breaking the realloc() && fread() loop when fread() returned 0,
requiring another iteration and exponentially enlarged buffer just to
discover the EOF condition.

This also caused file sizes >2MiB && <= 4MiB to erroneously be treated
as E2BIG, due to the inappropriately doubled buffer size exceeding
4*1024*1024.

Also made the 4*1024*1024 magic number a READ_FULL_BYTES_MAX constant.

6 years agoutil-lib: add parse_percent_unbounded() for percentages over 100% (#3886)
David Michael [Thu, 4 Aug 2016 11:09:54 +0000 (04:09 -0700)]
util-lib: add parse_percent_unbounded() for percentages over 100% (#3886)

This permits CPUQuota to accept greater values as documented.

6 years agoutil-lib: make timestamp generation and parsing reversible (#3869)
Lennart Poettering [Wed, 3 Aug 2016 23:04:53 +0000 (01:04 +0200)]
util-lib: make timestamp generation and parsing reversible (#3869)

This patch improves parsing and generation of timestamps and calendar
specifications in two ways:

- The week day is now always printed in the abbreviated English form, instead
  of the locale's setting. This makes sure we can always parse the week day
  again, even if the locale is changed. Given that we don't follow locale
  settings for printing timestamps in any other way either (for example, we
  always use 24h syntax in order to make uniform parsing possible), it only
  makes sense to also stick to a generic, non-localized form for the timestamp,
  too.

- When parsing a timestamp, the local timezone (in its DST or non-DST name)
  may be specified, in addition to "UTC". Other timezones are still not
  supported however (not because we wouldn't want to, but mostly because libc
  offers no nice API for that). In itself this brings no new features, however
  it ensures that any locally formatted timestamp's timezone is also parsable
  again.

These two changes ensure that the output of format_timestamp() may always be
passed to parse_timestamp() and results in the original input. The related
flavours for usec/UTC also work accordingly. Calendar specifications are
extended in a similar way.

The man page is updated accordingly, in particular this removes the claim that
timestamps elogind prints wouldn't be parsable by elogind. They are now.

The man page previously showed invalid timestamps as examples. This has been
removed, as the man page shouldn't be a unit test, where such negative examples
would be useful. The man page also no longer mentions the names of internal
functions, such as format_timestamp_us() or UNIX error codes such as EINVAL.

6 years agoclean-ipc: debug log about all remove IPC objects
Lennart Poettering [Tue, 2 Aug 2016 09:14:56 +0000 (11:14 +0200)]
clean-ipc: debug log about all remove IPC objects

6 years agocore: add RemoveIPC= setting
Lennart Poettering [Mon, 1 Aug 2016 17:24:40 +0000 (19:24 +0200)]
core: add RemoveIPC= setting

This adds the boolean RemoveIPC= setting to service, socket, mount and swap
units (i.e.  all unit types that may invoke processes). if turned on, and the
unit's user/group is not root, all IPC objects of the user/group are removed
when the service is shut down. The life-cycle of the IPC objects is hence bound
to the unit life-cycle.

This is particularly relevant for units with dynamic users, as it is essential
that no objects owned by the dynamic users survive the service exiting. In
fact, this patch adds code to imply RemoveIPC= if DynamicUser= is set.

In order to communicate the UID/GID of an executed process back to PID 1 this
adds a new "user lookup" socket pair, that is inherited into the forked
processes, and closed before the exec(). This is needed since we cannot do NSS
from PID 1 due to deadlock risks, However need to know the used UID/GID in
order to clean up IPC owned by it if the unit shuts down.

6 years agovirt: detect bhyve (FreeBSD hypervisor) (#3840)
Leonardo Brondani Schenkel [Mon, 1 Aug 2016 13:04:49 +0000 (15:04 +0200)]
virt: detect bhyve (FreeBSD hypervisor) (#3840)

The CPUID and DMI vendor strings do not seem to be documented.
Values were found experimentally and by inspecting the source code.

6 years agoclean-ipc: shorten code a bit
Lennart Poettering [Thu, 28 Jul 2016 07:51:47 +0000 (09:51 +0200)]
clean-ipc: shorten code a bit

6 years agoclean-ipc: don't filter out '.' and '..' twice
Lennart Poettering [Thu, 28 Jul 2016 07:51:25 +0000 (09:51 +0200)]
clean-ipc: don't filter out '.' and '..' twice

6 years agocore: inherit TERM from PID 1 for all services started on /dev/console
Lennart Poettering [Wed, 27 Jul 2016 13:25:55 +0000 (15:25 +0200)]
core: inherit TERM from PID 1 for all services started on /dev/console

This way, invoking nspawn from a shell in the best case inherits the TERM
setting all the way down into the login shell spawned in the container.

Fixes: #3697
6 years agostring-util: rework memory_erase() to not use GCC optimize attribute (#3812)
Michael Biebl [Wed, 27 Jul 2016 03:32:37 +0000 (05:32 +0200)]
string-util: rework memory_erase() to not use GCC optimize attribute (#3812)

"#pragma GCC optimize" is merely a convenience to decorate multiple
functions with attribute optimize. And the manual has this to say about
this attribute:

  This attribute should be used for debugging purposes only. It
  is not suitable in production code.

Some versions of GCC also seem to have a problem with this pragma in
combination with LTO, resulting in ICEs.

So use a different approach (indirect the memset call via a volatile
function pointer) as implemented in openssl's crypto/mem_clr.c.

Closes: #3811
6 years agoutil-lib: rework /tmp and /var/tmp handling code
Lennart Poettering [Tue, 26 Jul 2016 15:23:28 +0000 (17:23 +0200)]
util-lib: rework /tmp and /var/tmp handling code

Beef up the existing var_tmp() call, rename it to var_tmp_dir() and add a
matching tmp_dir() call (the former looks for the place for /var/tmp, the
latter for /tmp).

Both calls check $TMPDIR, $TEMP, $TMP, following the algorithm Python3 uses.
All dirs are validated before use. secure_getenv() is used in order to limite
exposure in suid binaries.

This also ports a couple of users over to these new APIs.

The var_tmp() return parameter is changed from an allocated buffer the caller
will own to a const string either pointing into environ[], or into a static
const buffer. Given that environ[] is mostly considered constant (and this is
exposed in the very well-known getenv() call), this should be OK behaviour and
allows us to avoid memory allocations in most cases.

Note that $TMPDIR and friends override both /var/tmp and /tmp usage if set.

6 years agoAdd enable_disable() helper
Zbigniew Jędrzejewski-Szmek [Sun, 24 Jul 2016 18:12:58 +0000 (14:12 -0400)]
Add enable_disable() helper

In this patch "enabled" and "disabled" is used exclusively, but "enable" and
"disable" forms are need for the following patch.

6 years agobootctl: move toupper() implementation to string-util.h
Lennart Poettering [Tue, 19 Jul 2016 18:43:54 +0000 (20:43 +0200)]
bootctl: move toupper() implementation to string-util.h

We already have tolower() calls there, hence let's unify this at one place.
Also, update the code to only use ASCII operations, so that we don't end up
being locale dependant.

6 years agocore: add a concept of "dynamic" user ids, that are allocated as long as a service...
Lennart Poettering [Thu, 14 Jul 2016 10:37:28 +0000 (12:37 +0200)]
core: add a concept of "dynamic" user ids, that are allocated as long as a service is running

This adds a new boolean setting DynamicUser= to service files. If set, a new
user will be allocated dynamically when the unit is started, and released when
it is stopped. The user ID is allocated from the range 61184..65519. The user
will not be added to /etc/passwd (but an NSS module to be added later should
make it show up in getent passwd).

For now, care should be taken that the service writes no files to disk, since
this might result in files owned by UIDs that might get assigned dynamically to
a different service later on. Later patches will tighten sandboxing in order to
ensure that this cannot happen, except for a few selected directories.

A simple way to test this is:

        elogind-run -p DynamicUser=1 /bin/sleep 99999

6 years agosysusers: move various user credential validity checks to src/basic/
Lennart Poettering [Thu, 14 Jul 2016 10:23:39 +0000 (12:23 +0200)]
sysusers: move various user credential validity checks to src/basic/

This way we can reuse them for validating User=/Group= settings in unit files
(to be added in a later commit).

Also, add some tests for them.

6 years agocore: introduce MemorySwapMax=
WaLyong Cho [Mon, 4 Jul 2016 07:03:54 +0000 (07:03 +0000)]
core: introduce MemorySwapMax=

Similar to MemoryMax=, MemorySwapMax= limits swap usage. This controls
controls "memory.swap.max" attribute in unified cgroup.

6 years agocgroup: detect cgroup namespaces
Christian Brauner [Thu, 23 Jun 2016 09:52:45 +0000 (11:52 +0200)]
cgroup: detect cgroup namespaces

- define CLONE_NEWCGROUP
- add fun to detect whether cgroup namespaces are supported

6 years agoRevert "build-sys: hide magic section variables from exported symbols"
David Herrmann [Wed, 22 Jul 2015 09:16:44 +0000 (11:16 +0200)]
Revert "build-sys: hide magic section variables from exported symbols"

This reverts commit aac7c5ed8bc6ffaba417b9c0b87bcf342865431b. This
visibility bug originated in ld.gold and has been fixed upstream:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5417c94d1a944d1a27f99240e5d62a6d7cd324f1

6 years agoMerge pull request #21 from elogind/v231-stable
Sven Eden [Mon, 3 Jul 2017 13:31:42 +0000 (15:31 +0200)]
Merge pull request #21 from elogind/v231-stable

V231 stable

6 years agoMerge pull request #19 from elogind/dev_v231
Sven Eden [Mon, 3 Jul 2017 13:28:24 +0000 (15:28 +0200)]
Merge pull request #19 from elogind/dev_v231

Merge dev_v231 into master

6 years agoVersion 231.4 Release v231.4
Sven Eden [Mon, 3 Jul 2017 13:21:43 +0000 (15:21 +0200)]
Version 231.4 Release

6 years agoRe-add the saving of the user state file when creating a new session.
Sven Eden [Mon, 3 Jul 2017 12:48:37 +0000 (14:48 +0200)]
Re-add the saving of the user state file when creating a new session.

6 years agoVersion v231.3 v231.3
Sven Eden [Thu, 29 Jun 2017 11:49:09 +0000 (13:49 +0200)]
Version v231.3

6 years agoPrep v231.3: libelogind-shared.so does not need to be installed.
Sven Eden [Thu, 29 Jun 2017 13:20:30 +0000 (15:20 +0200)]
Prep v231.3: libelogind-shared.so does not need to be installed.

6 years agoPrep v231.3: Fix typo in README
Sven Eden [Thu, 29 Jun 2017 11:36:08 +0000 (13:36 +0200)]
Prep v231.3: Fix typo in README

6 years agoPrep v231.3: libelogind-internal does not need to link against libresolv
Sven Eden [Thu, 29 Jun 2017 10:32:26 +0000 (12:32 +0200)]
Prep v231.3: libelogind-internal does not need to link against libresolv

6 years agoPrep v231.3: Add --with-cgroup-controller=name to configure
Sven Eden [Thu, 29 Jun 2017 09:14:20 +0000 (11:14 +0200)]
Prep v231.3: Add --with-cgroup-controller=name to configure

This option can be used, if elogind is built while a different cgroup
controller than planned is active.
A valid scenario could be a gentoo user switching from systemd to
openrc+elogind.

6 years agoPrep v231.3: Only ask for reboot authorization when shutting down or rebooting.
Sven Eden [Thu, 29 Jun 2017 08:06:25 +0000 (10:06 +0200)]
Prep v231.3: Only ask for reboot authorization when shutting down or rebooting.

It is not needed to ask for authorization to put the system to sleep.
Such a system is most commonly a single-user laptop, and no user,
especially me, wants to enter the root password after hitting the
suspend key. ;-)

6 years agoPrep v231.3: No authorization for setting the wall message.
Sven Eden [Thu, 29 Jun 2017 08:03:32 +0000 (10:03 +0200)]
Prep v231.3: No authorization for setting the wall message.

elogind only calls this when shutting down, rebooting or cancelling a
pending shutdown/reboot. Authorization is already needed there, so do
not question the user twice, just because they forgot to sudo.

6 years agoVersion v231.2
Sven Eden [Thu, 29 Jun 2017 08:02:40 +0000 (10:02 +0200)]
Version v231.2

6 years agoPrep v231.2: Make sure logs go to syslog or kmsg if elogind was started in debug...
Sven Eden [Wed, 28 Jun 2017 16:56:23 +0000 (18:56 +0200)]
Prep v231.2: Make sure logs go to syslog or kmsg if elogind was started in debug mode, even if it was started from a tty.

6 years agoPrep v231.2: Minor changes to make future patching easier.
Sven Eden [Wed, 28 Jun 2017 08:48:10 +0000 (10:48 +0200)]
Prep v231.2: Minor changes to make future patching easier.

6 years agoPrep v231.2: Move elogind specific code in logind-dbus.c to elogind-dbus.c
Sven Eden [Wed, 28 Jun 2017 08:41:24 +0000 (10:41 +0200)]
Prep v231.2: Move elogind specific code in logind-dbus.c to elogind-dbus.c

6 years agoPrep v231.2: Do not set a wall message when suspending (none there anyway)
Sven Eden [Wed, 28 Jun 2017 05:49:45 +0000 (07:49 +0200)]
Prep v231.2: Do not set a wall message when suspending (none there anyway)

6 years agoPrep v231.2: elogind is a stand-alone daemon, so do not exit if suspending the system...
Sven Eden [Tue, 27 Jun 2017 06:25:23 +0000 (08:25 +0200)]
Prep v231.2: elogind is a stand-alone daemon, so do not exit if suspending the system fails.

6 years agoPrep v231.2: Send processes the wakeup signal, even if suspending the system failed.
Sven Eden [Tue, 27 Jun 2017 06:05:27 +0000 (08:05 +0200)]
Prep v231.2: Send processes the wakeup signal, even if suspending the system failed.

6 years agoPrep v231.2: Only check time and wall arguments for shutdown and reboot.
Sven Eden [Mon, 26 Jun 2017 17:09:25 +0000 (19:09 +0200)]
Prep v231.2: Only check time and wall arguments for shutdown and reboot.

6 years agoPrep v231.2: elogind_log_special() : Add missing case breaks.
Sven Eden [Mon, 26 Jun 2017 16:39:03 +0000 (18:39 +0200)]
Prep v231.2: elogind_log_special() : Add missing case breaks.

6 years agoPrep v231.2: Add mor debug messages to find out, why 'loginctl suspend' isn't working.
Sven Eden [Mon, 26 Jun 2017 07:03:51 +0000 (09:03 +0200)]
Prep v231.2: Add mor debug messages to find out, why 'loginctl suspend' isn't working.

6 years agoPrep v231.2: Really set an extra wall message (if any) and display it when cancelling...
Sven Eden [Mon, 26 Jun 2017 06:18:53 +0000 (08:18 +0200)]
Prep v231.2: Really set an extra wall message (if any) and display it when cancelling a pending shutdown/reboot

6 years agoPrep v231.2: loginctl: Move check for cancelling a scheduled shutdown to allow extra...
Sven Eden [Mon, 26 Jun 2017 06:03:24 +0000 (08:03 +0200)]
Prep v231.2: loginctl: Move check for cancelling a scheduled shutdown to allow extra wall messages.

6 years agoPrep v231.2: Add log messages for loginctl invoking system commands.
Sven Eden [Thu, 22 Jun 2017 16:22:58 +0000 (18:22 +0200)]
Prep v231.2: Add log messages for loginctl invoking system commands.

6 years agoPrep v231.2: Mask get_startup_time(), it won't work without systemd running the show...
Sven Eden [Thu, 22 Jun 2017 16:21:16 +0000 (18:21 +0200)]
Prep v231.2: Mask get_startup_time(), it won't work without systemd running the show anyway.

6 years agoPrep v231.2: Mask unsupported bus errors.
Sven Eden [Thu, 22 Jun 2017 16:20:09 +0000 (18:20 +0200)]
Prep v231.2: Mask unsupported bus errors.

6 years agoPrep v231.2: login1.policy vendor is the project, not it's description.
Sven Eden [Thu, 22 Jun 2017 16:18:07 +0000 (18:18 +0200)]
Prep v231.2: login1.policy vendor is the project, not it's description.

6 years agoPrep v321.2: Fix org.freedesktop.login1 where named org.freedesktop.elogind
Sven Eden [Thu, 22 Jun 2017 16:17:20 +0000 (18:17 +0200)]
Prep v321.2: Fix org.freedesktop.login1 where named org.freedesktop.elogind

6 years agoPrep v231.2: Fix missing/double wall msgs on scheduled shutdown/reboot
Sven Eden [Wed, 21 Jun 2017 08:57:17 +0000 (10:57 +0200)]
Prep v231.2: Fix missing/double wall msgs on scheduled shutdown/reboot

- Do not do anything in manager_setup_wall_message_timer() if wall
  messages are disabled anyway.
- Set up a wall timer in any case there is time left. The original
  sources would not even set up a timer if the next messages would
  be now. As time is measured in USEC, that's pretty rare, but
  possible.
- If less than 1 Second is left to the first message, delay it.
- systemd would print out a message at once, if less than 15 minutes
  are left to the event. Do this only, if the next scheduled message
  wouldn't come within the next 3 seconds, or it might come to
  awkward double messages.

6 years agoPrep v231.2: Remove modes and states assertion in do_sleep()
Sven Eden [Wed, 21 Jun 2017 06:49:50 +0000 (08:49 +0200)]
Prep v231.2: Remove modes and states assertion in do_sleep()

It is perfectly valid to have NULL modes. The default configuration
for suspend to ram is such a case.
Having NULL states doesn't make any sense other than no suspension is
possible any more. But a user might have set any *State value to an
empty string, so better assume (and assert) nothing here.

6 years agoPrep v231.2: login/elogind.c: Remove bus_forward_agent_released()
Sven Eden [Tue, 20 Jun 2017 04:48:14 +0000 (06:48 +0200)]
Prep v231.2: login/elogind.c: Remove bus_forward_agent_released()

This method is called from a systemd manager that is the system
instance to inform all user instances of systemd about the pending
cgroup release.

elogind on the other hand is always there just once. And the release
of cgroups is handled by the local cgroups manager, which should be
provided by the running init system.

Even if there is no cgroup management, so elogind sets itself up as
a small cgroups manager itself, there aren't any user instances that
could react on the forwarding anyway.

6 years agoPrep v231.2: Remove --disable-kdbus option from configure.
Sven Eden [Mon, 19 Jun 2017 17:28:05 +0000 (19:28 +0200)]
Prep v231.2: Remove --disable-kdbus option from configure.

Support for kdbus can no longer be enabled or disabled. It is simply
there and will be used if needed and possible.
So if you have kdbus available, elogind might use it.

6 years agoPrep v231.2: Remove orphaned files
Sven Eden [Mon, 19 Jun 2017 17:27:19 +0000 (19:27 +0200)]
Prep v231.2: Remove orphaned files

6 years agoPrep v231.2: pam_elogind must be linked against libshared, not libelogind-shared.
Sven Eden [Mon, 19 Jun 2017 17:03:17 +0000 (19:03 +0200)]
Prep v231.2: pam_elogind must be linked against libshared, not libelogind-shared.

6 years agoPrep v231.2: Make elogind musl-libc-compatible again.
Sven Eden [Mon, 19 Jun 2017 09:51:42 +0000 (11:51 +0200)]
Prep v231.2: Make elogind musl-libc-compatible again.

6 years agoPrep v231.2: basic/stdio-util.h must include parse-printf-format.h instead of printf.h
Sven Eden [Mon, 19 Jun 2017 09:04:44 +0000 (11:04 +0200)]
Prep v231.2: basic/stdio-util.h must include parse-printf-format.h instead of printf.h

6 years agoPrep v231.2: Apply some minor style fixes
Sven Eden [Mon, 19 Jun 2017 08:17:56 +0000 (10:17 +0200)]
Prep v231.2: Apply some minor style fixes

6 years agosd-event: "when exiting no signal event are pending" is a wrong assertion (#5271)
Franck Bui [Wed, 8 Feb 2017 19:56:22 +0000 (20:56 +0100)]
sd-event: "when exiting no signal event are pending" is a wrong assertion (#5271)

The code make the following assertion: when freeing a event loop object
(usually it's done after exiting from the main event loop), no signal events
are still queued and are pending.

This assertion can be found in event_unmask_signal_data() with
"assert(!d->current);" assertion.

It appears that this assertion can be wrong at least in a specific case
described below.

Consider the following example which is inspired from udev: a process defines 3
source events: 2 are created by sd_event_add_signal() and 1 is created by
sd_event_add_post().

 1. the process receives the 2 signals consecutively so that signal 'A' source
     event is queued and pending. Consequently the post source event is also
     queued and pending. This is done by sd_event_wait().

 2. The callback for signal 'A' is called by sd_event_dispatch().

 3. The next call to sd_event_wait() will queue signal 'B' source event.

 4. The callback for the post source event is called and calls sd_event_exit().

 5. the event loop is exited.

 6. freeing the event loop object will lead to the assertion failure in
     event_unmask_signal_data().

This patch simply removes this assertion as it doesn't seem to be a
bug if the signal data still reference a signal source at this point.

(cherry picked from commit 4470860388e12a5dda1d65773e411a349221a3e9)

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

(cherry picked from commit 29d87223d54fc13e16f444677f0a94ed0755bd88)

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
(cherry picked from commit 84a4e6608dbda38c724ab196a226db209a50b224)

6 years agoelogind: ignore lack of tty when checking whether colors should be enabled
Zbigniew Jędrzejewski-Szmek [Fri, 19 Aug 2016 02:03:56 +0000 (22:03 -0400)]
elogind: ignore lack of tty when checking whether colors should be enabled

When started by the kernel, we are connected to the console, and we'll set TERM
properly to some value in fixup_environment(). We'll then enable or disable
colors based on the value of $SYSTEMD_COLORS and $TERM.

When reexecuting, TERM should be already set, so we can use this value.
Effectively, behaviour is the same as before affd7ed1a was reverted, but instead
of reopening the console before configuring color output, we just ignore what
stdout is connected to and decide based on the variables only.

(cherry picked from commit 158fbf7661912adf0f42c93155499119811dde82)

6 years agoman: explain that *KeyIgnoreInhibited only apply to a subset of locks
Zbigniew Jędrzejewski-Szmek [Sun, 14 Aug 2016 20:27:59 +0000 (16:27 -0400)]
man: explain that *KeyIgnoreInhibited only apply to a subset of locks

Follow-up for #3924.

(cherry picked from commit 05b2a8fd7a0533758d2f532df798cabc3c442683)

6 years agoRevert "logind: really handle *KeyIgnoreInhibited options in logind.conf"
Mantas Mikulėnas [Mon, 8 Aug 2016 08:07:38 +0000 (11:07 +0300)]
Revert "logind: really handle *KeyIgnoreInhibited options in logind.conf"

This reverts commit 8121f4d209eca85dcb11830800483cdfafbef9b7.

The special 'key handling' inhibitors should always work regardless of
any *IgnoreInhibited settings – otherwise they're nearly useless.

Reverts: #3470
Fixes: #3897
(cherry picked from commit 06a70b918d4d753769a727239f75af8896006467)

6 years agologind: 0% and 100% should be valid for UserTasksMax (#3836)
Tejun Heo [Mon, 1 Aug 2016 01:38:47 +0000 (21:38 -0400)]
logind: 0% and 100% should be valid for UserTasksMax (#3836)

config_parse_user_tasks_max() was incorrectly accepting percentage value
between 1 and 99.  Update it to accept 0% and 100%.  This brings it in line
with TasksMax handling in elogind.
(cherry picked from commit cb3e4417590196bd30e1b8097348dca6ba34bd15)

6 years agov231.1 - mark commit before applying upstream stable patches.
Sven Eden [Mon, 19 Jun 2017 06:59:37 +0000 (08:59 +0200)]
v231.1 - mark commit before applying upstream stable patches.

6 years agoPrep v229.6: Send wakeup call to suspended processes.
Sven Eden [Thu, 15 Jun 2017 14:51:11 +0000 (16:51 +0200)]
Prep v229.6: Send wakeup call to suspended processes.

Somewhere in the update stream from 227.x to 228.x the sending of the
wakeup signal to sleeping processes got lost.

Re-add the sending of the wakeup signal.

Fixes issue 17
 ( https://github.com/elogind/elogind/issues/17 )

6 years agoPrep v231: Add missing line breaks in loginctl help text
Sven Eden [Wed, 14 Jun 2017 15:57:24 +0000 (17:57 +0200)]
Prep v231: Add missing line breaks in loginctl help text

6 years agoPrep v231: Update man pages to include upstream changes
Sven Eden [Wed, 14 Jun 2017 15:42:55 +0000 (17:42 +0200)]
Prep v231: Update man pages to include upstream changes

6 years agoPrep v231: Updated POT-Files to upstream version
Sven Eden [Mon, 12 Jun 2017 14:47:56 +0000 (16:47 +0200)]
Prep v231: Updated POT-Files to upstream version

6 years agoPrep v231: Add new files to Makefile.am and Code::Blocks project file.
Sven Eden [Wed, 14 Jun 2017 15:45:33 +0000 (17:45 +0200)]
Prep v231: Add new files to Makefile.am and Code::Blocks project file.

6 years agoPrep v231: Move elogind specific code in login/loginctl.c to login/eloginctl.c
Sven Eden [Wed, 14 Jun 2017 15:41:36 +0000 (17:41 +0200)]
Prep v231: Move elogind specific code in login/loginctl.c to login/eloginctl.c

6 years agoPrep v231: Reorganize elogind specific code in login/logind-action.c
Sven Eden [Wed, 14 Jun 2017 15:23:00 +0000 (17:23 +0200)]
Prep v231: Reorganize elogind specific code in login/logind-action.c

- Move elogind specific code in login/logind-action.c to
  login/elogind-action.c
- Remove login/logind-sleep.*
- Add src/sleep from upstream
- Integrate the systemd-sleep utility, so future fixes and updates
  will be easier to spot and to apply.

6 years agoPrep v231: Move elogind specific code in login/logind.c to login/elogind.c
Sven Eden [Wed, 14 Jun 2017 15:39:24 +0000 (17:39 +0200)]
Prep v231: Move elogind specific code in login/logind.c to login/elogind.c

6 years agoPrep v231: Move can_sleep() back to src/shared/sleep-config.c
Sven Eden [Wed, 14 Jun 2017 15:37:58 +0000 (17:37 +0200)]
Prep v231: Move can_sleep() back to src/shared/sleep-config.c

6 years agoPrep v231: Update build root files to upstream
Sven Eden [Mon, 12 Jun 2017 14:29:59 +0000 (16:29 +0200)]
Prep v231: Update build root files to upstream

6 years agoPrep v231: Minor fix for update-utmp
Sven Eden [Wed, 14 Jun 2017 15:21:19 +0000 (17:21 +0200)]
Prep v231: Minor fix for update-utmp

6 years agoPrep v231: Apply missing fixes from upstream (6/6) src/systemd
Sven Eden [Wed, 14 Jun 2017 15:44:53 +0000 (17:44 +0200)]
Prep v231: Apply missing fixes from upstream (6/6) src/systemd

6 years agoPrep v231: Apply missing fixes from upstream (5/6) src/shared
Sven Eden [Wed, 14 Jun 2017 15:44:53 +0000 (17:44 +0200)]
Prep v231: Apply missing fixes from upstream (5/6) src/shared

6 years agoPrep v231: Apply missing fixes from upstream (4/6) src/login
Sven Eden [Wed, 14 Jun 2017 15:44:53 +0000 (17:44 +0200)]
Prep v231: Apply missing fixes from upstream (4/6) src/login

6 years agoPrep v231: Apply missing fixes from upstream (3/6) src/libelogind
Sven Eden [Wed, 14 Jun 2017 15:44:53 +0000 (17:44 +0200)]
Prep v231: Apply missing fixes from upstream (3/6) src/libelogind

6 years agoPrep v231: Apply missing fixes from upstream (2/6) src/core
Sven Eden [Wed, 14 Jun 2017 15:44:53 +0000 (17:44 +0200)]
Prep v231: Apply missing fixes from upstream (2/6) src/core

6 years agoPrep v231: Apply missing fixes from upstream (1/6) src/basic
Sven Eden [Wed, 14 Jun 2017 15:44:53 +0000 (17:44 +0200)]
Prep v231: Apply missing fixes from upstream (1/6) src/basic

6 years agoPrep v231: Cleaned up tree
Sven Eden [Mon, 12 Jun 2017 14:47:37 +0000 (16:47 +0200)]
Prep v231: Cleaned up tree

6 years agofileio: imply /tmp as directory if passed as NULL to open_tmpfile_unlinkable()
Lennart Poettering [Mon, 25 Jul 2016 18:35:04 +0000 (20:35 +0200)]
fileio: imply /tmp as directory if passed as NULL to open_tmpfile_unlinkable()

We can make this smarter one day, to honour $TMPDIR and friends, but for now,
let's just use /tmp.

6 years agonamespace: don't fail on masked mounts (#3794)
Alban Crequy [Mon, 25 Jul 2016 13:39:46 +0000 (15:39 +0200)]
namespace: don't fail on masked mounts (#3794)

Before this patch, a service file with ReadWriteDirectories=/file...
could fail if the file exists but is not a mountpoint, despite being
listed in /proc/self/mountinfo. It could happen with masked mounts.

Fixes https://github.com/elogind/elogind/issues/3793

6 years agoUse "return log_error_errno" in more places"
Zbigniew Jędrzejewski-Szmek [Sat, 23 Jul 2016 00:27:45 +0000 (20:27 -0400)]
Use "return log_error_errno" in more places"

6 years agocgroup: whitelist inaccessible devices for "auto" and "closed" DevicePolicy.
Alessandro Puccetti [Fri, 22 Jul 2016 10:00:49 +0000 (12:00 +0200)]
cgroup: whitelist inaccessible devices for "auto" and "closed" DevicePolicy.

https://github.com/elogind/elogind/pull/3685 introduced
/run/elogind/inaccessible/{chr,blk} to map inacessible devices,
this patch allows elogind running inside a nspawn container to create
/run/elogind/inaccessible/{chr,blk}.

6 years agosd-id128: handle NULL return parameter in sd_id128_from_string() nicer
Lennart Poettering [Thu, 21 Jul 2016 18:23:51 +0000 (20:23 +0200)]
sd-id128: handle NULL return parameter in sd_id128_from_string() nicer

If the return parameter is NULL, simply validate the string, and return no
error.

6 years agosd-id128: split UUID file read/write code into new id128-util.[ch]
Lennart Poettering [Thu, 21 Jul 2016 15:57:57 +0000 (17:57 +0200)]
sd-id128: split UUID file read/write code into new id128-util.[ch]

We currently have code to read and write files containing UUIDs at various
places. Unify this in id128-util.[ch], and move some other stuff there too.

The new files are located in src/libelogind/sd-id128/ (instead of src/shared/),
because they are actually the backend of sd_id128_get_machine() and
sd_id128_get_boot().

In follow-up patches we can use this reduce the code in nspawn and
machine-id-setup by adopted the common implementation.

6 years agotree-wide: use sd_id128_is_null() instead of sd_id128_equal where appropriate
Lennart Poettering [Thu, 21 Jul 2016 14:06:31 +0000 (16:06 +0200)]
tree-wide: use sd_id128_is_null() instead of sd_id128_equal where appropriate

It's a bit easier to read because shorter. Also, most likely a tiny bit faster.

6 years agomissing_syscall: add __NR_copy_file_range for powerpc architecture (#3772)
Alessio Igor Bogani [Thu, 21 Jul 2016 09:40:35 +0000 (11:40 +0200)]
missing_syscall: add __NR_copy_file_range for powerpc architecture (#3772)