chiark / gitweb /
elogind.git
2 years agoPrep v230: No longer print double messages when shutting down or rebooting.
Sven Eden [Thu, 8 Jun 2017 08:56:06 +0000 (10:56 +0200)]
Prep v230: No longer print double messages when shutting down or rebooting.

2 years agoPrep v230: Add utmp support to make wall message to work properly.
Sven Eden [Thu, 8 Jun 2017 06:49:12 +0000 (08:49 +0200)]
Prep v230: Add utmp support to make wall message to work properly.

2 years agoPrep v230: Add support for scheduled shutdown/reboot and the cancellation of them.
Sven Eden [Wed, 7 Jun 2017 10:09:39 +0000 (12:09 +0200)]
Prep v230: Add support for scheduled shutdown/reboot and the cancellation of them.

2 years agoPrep v230: Return 'no' when asked whether we can reboot into firmware setup. elogind...
Sven Eden [Thu, 8 Jun 2017 06:30:23 +0000 (08:30 +0200)]
Prep v230: Return 'no' when asked whether we can reboot into firmware setup. elogind does not support EFI.

2 years agoPrep v230: Move musl_missing and parse-printf-format to libshared.
Sven Eden [Wed, 7 Jun 2017 10:10:11 +0000 (12:10 +0200)]
Prep v230: Move musl_missing and parse-printf-format to libshared.

2 years agoPrep v230: Remove possibly existing header symlinks before creating new ones.
Sven Eden [Wed, 7 Jun 2017 10:08:26 +0000 (12:08 +0200)]
Prep v230: Remove possibly existing header symlinks before creating new ones.

2 years agoPrep v230: src/logind.c: Do not call manager_free(m) if an error lead to m still...
Sven Eden [Wed, 7 Jun 2017 06:02:10 +0000 (08:02 +0200)]
Prep v230: src/logind.c: Do not call manager_free(m) if an error lead to m still being NULL.

2 years agoPrep v230: Move installed headers
Sven Eden [Fri, 2 Jun 2017 09:18:12 +0000 (11:18 +0200)]
Prep v230: Move installed headers

The headers are now installed into

  /usr/include/elogind/systemd

and the pkg-config file now returns -I/usr/include/elogind for CFLAGS.

Further
  /usr/include/elogind
contains symlinks to the headers, so existing packages already including
<elogind/sd-login.h> will not be broken.

This way no software has to change their include lines anywhere to
support elogind any more. All they have to do is either add
LIBSYSTEMD_CFLAGS or LIBELOGIND_CFLAGS from pkg-config and be done
with it.

So most patching can be avoided, just some configure adaption is
needed.

However, this can lead to systemd/elogind bug confusion if there is anything
mixed up on a system that shouldn't.

Downstreams, chose any of the two ways to your own discretion!

See https://bugs.freedesktop.org/show_bug.cgi?id=101251

2 years agoPrep v230: Apply missing upstream fixes and updates (8/8) src/systemd.
Sven Eden [Wed, 31 May 2017 05:10:24 +0000 (07:10 +0200)]
Prep v230: Apply missing upstream fixes and updates (8/8) src/systemd.

2 years agoPrep v230: Apply missing upstream fixes and updates (7/8) src/shared.
Sven Eden [Wed, 31 May 2017 05:15:22 +0000 (07:15 +0200)]
Prep v230: Apply missing upstream fixes and updates (7/8) src/shared.

2 years agoPrep v230: Apply missing upstream fixes and updates (6/8) src/login.
Sven Eden [Wed, 31 May 2017 05:35:28 +0000 (07:35 +0200)]
Prep v230: Apply missing upstream fixes and updates (6/8) src/login.

2 years agoPrep v230: Apply missing upstream fixes and updates (5/8) src/libelogind.
Sven Eden [Wed, 31 May 2017 05:39:59 +0000 (07:39 +0200)]
Prep v230: Apply missing upstream fixes and updates (5/8) src/libelogind.

2 years agoPrep v230: Apply missing upstream fixes and updates (4/8) src/core.
Sven Eden [Wed, 31 May 2017 05:08:06 +0000 (07:08 +0200)]
Prep v230: Apply missing upstream fixes and updates (4/8) src/core.

2 years agoPrep v230: Apply missing upstream fixes and updates (3/8) src/cgroups-agent.
Sven Eden [Wed, 31 May 2017 05:00:37 +0000 (07:00 +0200)]
Prep v230: Apply missing upstream fixes and updates (3/8) src/cgroups-agent.

2 years agoPrep v230: Apply missing upstream fixes and updates (2/8) src/basic.
Sven Eden [Wed, 24 May 2017 11:51:31 +0000 (13:51 +0200)]
Prep v230: Apply missing upstream fixes and updates (2/8) src/basic.

2 years agoPrep v230: Apply missing upstream fixes and updates (1/8) root build files.
Sven Eden [Tue, 23 May 2017 15:22:48 +0000 (17:22 +0200)]
Prep v230: Apply missing upstream fixes and updates (1/8) root build files.

2 years agoPrep v230: Update POT files to upstream
Sven Eden [Tue, 23 May 2017 14:44:41 +0000 (16:44 +0200)]
Prep v230: Update POT files to upstream

2 years agobasic: remove rm_rf_and_free, add rm_rf_physical_and_free, use rm_rf_physical_and_fre...
Evgeny Vereshchagin [Fri, 20 May 2016 13:08:24 +0000 (16:08 +0300)]
basic: remove rm_rf_and_free, add rm_rf_physical_and_free, use rm_rf_physical_and_freep in tests (#3292)

Some distros don't mount /tmp as tmpfs.
For example:
https://lists.ubuntu.com/archives/ubuntu-cloud/2016-January/001009.html

Some tests:
* print 'Attempted to remove disk file system, and we can't allow that.'
* don't really cleanup /tmp

2 years agocore: update CGroupBlockIODeviceBandwidth to record both rbps and wbps
Tejun Heo [Wed, 18 May 2016 20:51:46 +0000 (13:51 -0700)]
core: update CGroupBlockIODeviceBandwidth to record both rbps and wbps

CGroupBlockIODeviceBandwith is used to keep track of IO bandwidth limits for
legacy cgroup hierarchies.  Unlike the unified hierarchy counterpart
CGroupIODeviceLimit, a CGroupBlockIODeviceBandwiddth records either a read or
write limit and has a couple issues.

* There's no way to clear specific config entry.

* When configs are cleared for an IO direction of a unit, the kernel settings
  aren't cleared accordingly creating discrepancies.

This patch updates CGroupBlockIODeviceBandwidth so that it behaves similarly to
CGroupIODeviceLimit - each entry records both rbps and wbps limits and is
cleared if both are at default values after kernel settings are updated.

2 years agocore: introduce CGroupIOLimitType enums
Tejun Heo [Wed, 18 May 2016 20:50:56 +0000 (13:50 -0700)]
core: introduce CGroupIOLimitType enums

Currently, there are two cgroup IO limits, bandwidth max for read and write,
and they are hard-coded in various places.  This is fine for two limits but IO
is expected to grow more limits - low, high and max limits for bandwidth and
IOPS - and hard-coding each limit won't make sense.

This patch replaces hard-coded limits with an array indexed by
CGroupIOLimitType and accompanying string and default value tables so that new
limits can be added trivially.

2 years agobasic: define HEXDIGITS
Daniel Kahn Gillmor [Tue, 17 May 2016 13:44:32 +0000 (09:44 -0400)]
basic: define HEXDIGITS

define HEXDIGITS alongside DIGITS, and use it where it's already useful.  We'll
use it again shortly when parsing MAC addresses.

2 years agomissing.h: add BTRFS_IOC_QUOTA_RESCAN_WAIT (#3266)
Stefan Saraev [Mon, 16 May 2016 14:58:46 +0000 (17:58 +0300)]
missing.h: add BTRFS_IOC_QUOTA_RESCAN_WAIT (#3266)

2 years agologind: introduce LockedHint and SetLockedHint (#3238)
Victor Toso [Wed, 11 May 2016 17:34:13 +0000 (19:34 +0200)]
logind: introduce LockedHint and SetLockedHint (#3238)

Desktop environments can keep this property up to date to allow
applications to easily track session's Lock status.

2 years agopo, catalog - add Bulgarian translation
Alexander Shopov [Wed, 11 May 2016 07:02:04 +0000 (10:02 +0300)]
po, catalog - add Bulgarian translation

2 years agolocale-util: mark special_glyph() as _const_
Zbigniew Jędrzejewski-Szmek [Mon, 9 May 2016 15:24:08 +0000 (11:24 -0400)]
locale-util: mark special_glyph() as _const_

_const_ means that the caller can assume that the function will return the same
result every time (and will not modify global memory). special_glyph() meets
this: even though it depends on global memory, that part of global memory is
not expected to change. This allows the calls to special_glyph() to be
optimized, even if -flto is not used.

2 years agotree-wide: rename draw_special_char to special_glyph
Zbigniew Jędrzejewski-Szmek [Sat, 7 May 2016 21:30:18 +0000 (17:30 -0400)]
tree-wide: rename draw_special_char to special_glyph

That function doesn't draw anything on it's own, just returns a string, which
sometimes is more than one character. Also remove "DRAW_" prefix from character
names, TREE_* and ARROW and BLACK_CIRCLE are unambigous on their own, don't
draw anything, and are always used as an argument to special_glyph().

Rename "DASH" to "MDASH", as there's more than one type of dash.

2 years agocore: rework how we flush incoming traffic when a socket unit goes down
Lennart Poettering [Fri, 6 May 2016 11:29:26 +0000 (13:29 +0200)]
core: rework how we flush incoming traffic when a socket unit goes down

Previously, we'd simply close and reopen the socket file descriptors. This is
problematic however, as we won't transition through the SOCKET_CHOWN state
then, and thus the file ownership won't be correct for the sockets.

Rework the flushing logic, and actually read any queued data from the sockets
for flushing, and accept any queued messages and disconnect them.

2 years agocore: add io controller support on the unified hierarchy
Tejun Heo [Thu, 5 May 2016 20:42:55 +0000 (16:42 -0400)]
core: add io controller support on the unified hierarchy

On the unified hierarchy, blkio controller is renamed to io and the interface
is changed significantly.

* blkio.weight and blkio.weight_device are consolidated into io.weight which
  uses the standardized weight range [1, 10000] with 100 as the default value.

* blkio.throttle.{read|write}_{bps|iops}_device are consolidated into io.max.
  Expansion of throttling features is being worked on to support
  work-conserving absolute limits (io.low and io.high).

* All stats are consolidated into io.stats.

This patchset adds support for the new interface.  As the interface has been
revamped and new features are expected to be added, it seems best to treat it
as a separate controller rather than trying to expand the blkio settings
although we might add automatic translation if only blkio settings are
specified.

* io.weight handling is mostly identical to blkio.weight[_device] handling
  except that the weight range is different.

* Both read and write bandwidth settings are consolidated into
  CGroupIODeviceLimit which describes all limits applicable to the device.
  This makes it less painful to add new limits.

* "max" can be used to specify the maximum limit which is equivalent to no
  config for max limits and treated as such.  If a given CGroupIODeviceLimit
  doesn't contain any non-default configs, the config struct is discarded once
  the no limit config is applied to cgroup.

* lookup_blkio_device() is renamed to lookup_block_device().

Signed-off-by: Tejun Heo <htejun@fb.com>
2 years agotree-wide: introduce new SOCKADDR_UN_LEN() macro, and use it everywhere
Lennart Poettering [Thu, 5 May 2016 20:24:36 +0000 (22:24 +0200)]
tree-wide: introduce new SOCKADDR_UN_LEN() macro, and use it everywhere

The macro determines the right length of a AF_UNIX "struct sockaddr_un" to pass to
connect() or bind(). It automatically figures out if the socket refers to an
abstract namespace socket, or a socket in the file system, and properly handles
the full length of the path field.

This macro is not only safer, but also simpler to use, than the usual
offsetof() + strlen() logic.

2 years agocore: use an AF_UNIX/SOCK_DGRAM socket for cgroup agent notification
Lennart Poettering [Wed, 4 May 2016 18:43:23 +0000 (20:43 +0200)]
core: use an AF_UNIX/SOCK_DGRAM socket for cgroup agent notification

dbus-daemon currently uses a backlog of 30 on its D-bus system bus socket. On
overloaded systems this means that only 30 connections may be queued without
dbus-daemon processing them before further connection attempts fail. Our
cgroups-agent binary so far used D-Bus for its messaging, and hitting this
limit hence may result in us losing cgroup empty messages.

This patch adds a seperate cgroup agent socket of type AF_UNIX/SOCK_DGRAM.
Since sockets of these types need no connection set up, no listen() backlog
applies. Our cgroup-agent binary will hence simply block as long as it can't
enqueue its datagram message, so that we won't lose cgroup empty messages as
likely anymore.

This also rearranges the ordering of the processing of SIGCHLD signals, service
notification messages (sd_notify()...) and the two types of cgroup
notifications (inotify for the unified hierarchy support, and agent for the
classic hierarchy support). We now always process events for these in the
following order:

  1. service notification messages  (SD_EVENT_PRIORITY_NORMAL-7)
  2. SIGCHLD signals (SD_EVENT_PRIORITY_NORMAL-6)
  3. cgroup inotify and cgroup agent (SD_EVENT_PRIORITY_NORMAL-5)

This is because when receiving SIGCHLD we invalidate PID information, which we
need to process the service notification messages which are bound to PIDs.
Hence the order between the first two items. And we want to process SIGCHLD
metadata to detect whether a service is gone, before using cgroup
notifications, to decide when a service is gone, since the former carries more
useful metadata.

Related to this:
https://bugs.freedesktop.org/show_bug.cgi?id=95264
https://github.com/elogind/elogind/issues/1961

2 years agologind: enforce a limit on inhibitors we hand out
Lennart Poettering [Wed, 4 May 2016 17:40:05 +0000 (19:40 +0200)]
logind: enforce a limit on inhibitors we hand out

For similar reasons as the recent addition of a limit on sessions.

Note that we don't enforce a limit on inhibitors per-user currently, but
there's an implicit one, since each inhibitor takes up one fd, and fds are
limited via RLIMIT_NOFILE, and the limit on the number of processes per user.

2 years agologind: expose more configuration settings as bus properties
Lennart Poettering [Wed, 4 May 2016 17:22:30 +0000 (19:22 +0200)]
logind: expose more configuration settings as bus properties

2 years agologind: don't include session lists in PropertyChanged messages
Lennart Poettering [Wed, 4 May 2016 17:05:18 +0000 (19:05 +0200)]
logind: don't include session lists in PropertyChanged messages

If we have a lot of simultaneous sessions we really shouldn't send the full
list of active sessions with each PropertyChanged message for user and seat
objects, as that can become quite substantial data, we probably shouldn't dump
on the bus on each login and logout.

Note that the global list of sessions doesn't send out changes like this
either, it only supports requesting the session list with ListSessions().

If cients want to get notified about sessions coming and going they should
subscribe to SessionNew and SessionRemoved signals, and clients generally do
that already.

This is kind of an API break, but then again the fact that this was included
was never documented.

2 years agologind: process session/inhibitor fds at higher priority
Lennart Poettering [Wed, 4 May 2016 17:01:56 +0000 (19:01 +0200)]
logind: process session/inhibitor fds at higher priority

Let's make sure we process session and inhibitor pipe fds (that signal
sessions/inhibtors going away) at a higher priority
than new bus calls that might create new sessions or inhibitors. This helps
ensuring that the number of open sessions stays minimal.

2 years agologind: enforce a limit on current user sessions
Lennart Poettering [Wed, 4 May 2016 16:57:15 +0000 (18:57 +0200)]
logind: enforce a limit on current user sessions

We really should put limits on all resources we manage, hence add one to the
number of concurrent sessions, too. This was previously unbounded, hence set a
relatively high limit of 8K by default.

Note that most PAM setups will actually invoke pam_elogind prefixed with "-",
so that the return code of pam_elogind is ignored, and the login attempt
succeeds anyway. On systems like this the session will be created but is not
tracked by elogind.

2 years agocore: make unit_has_mask_realized() consider controller enable state
Tejun Heo [Sat, 30 Apr 2016 20:12:54 +0000 (16:12 -0400)]
core: make unit_has_mask_realized() consider controller enable state

unit_has_mask_realized() determines whether the specified unit has its cgroups
set up properly given the desired target_mask; however, on the unified
hierarchy, controllers need to be enabled explicitly for children and the mask
of enabled controllers can deviate from target_mask.  Only considering
target_mask in unit_has_mask_realized() can lead to false positives and
skipping enabling the requested controllers.

This patch adds unit->cgroup_enabled_mask to track which controllers are
enabled and updates unit_has_mask_realized() to also consider enable_mask.

Signed-off-by: Tejun Heo <htejun@fb.com>
2 years agomachined: support non-btrfs file systems with "machinectl clone"
Lennart Poettering [Fri, 29 Apr 2016 18:06:20 +0000 (20:06 +0200)]
machined: support non-btrfs file systems with "machinectl clone"

Fall back to a normal copy operation when the backing file system isn't btrfs,
and hence doesn't support cheap snapshotting. Of course, this will be slow, but
given that the execution is asynchronous now, this should be OK.

Fixes: #1308

2 years agocopy: adjust directory times after writing to the directory
Lennart Poettering [Fri, 29 Apr 2016 17:44:59 +0000 (19:44 +0200)]
copy: adjust directory times after writing to the directory

When recursively copying a directory tree, fix up the file times after having
created all contents in it, so that our changes don't end up altering any of
the directory times.

2 years agocopy: return the right error when we can't open a file
Lennart Poettering [Fri, 29 Apr 2016 17:42:07 +0000 (19:42 +0200)]
copy: return the right error when we can't open a file

2 years agocopy: also copy AF_UNIX sockets
Lennart Poettering [Fri, 29 Apr 2016 12:21:22 +0000 (14:21 +0200)]
copy: also copy AF_UNIX sockets

We previously would fail with EOPNOTSUPP when encountering an AF_UNIX socket in
the directory tree to copy. Fix that, and copy them too (even if they are dead
in the result).

Fixes: #2914

2 years agoparse-util: fix conversion from size_t on s390 (#3147)
Lubomir Rintel [Fri, 29 Apr 2016 09:45:07 +0000 (11:45 +0200)]
parse-util: fix conversion from size_t on s390 (#3147)

On s390 size_t is an unsigned long, nor an unsigned int. They both are
of the same size and can be cast to each other safely, but the compiler
still seems unhappy about incompatible pointers.

Fixes: 7c2da2ca8

2 years agobasic/mount-util: recognize pvfs2 as network fs (#3140)
Zbigniew Jędrzejewski-Szmek [Thu, 28 Apr 2016 17:49:16 +0000 (13:49 -0400)]
basic/mount-util: recognize pvfs2 as network fs (#3140)

Added to kernel 4.6.

2 years agotree-wide: rename hidden_file to hidden_or_backup_file and optimize
Zbigniew Jędrzejewski-Szmek [Wed, 27 Apr 2016 13:24:59 +0000 (09:24 -0400)]
tree-wide: rename hidden_file to hidden_or_backup_file and optimize

In standard linux parlance, "hidden" usually means that the file name starts
with ".", and nothing else. Rename the function to convey what the function does
better to casual readers.

Stop exposing hidden_file_allow_backup which is rather ugly and rewrite
hidden_file to extract the suffix first. Note that hidden_file_allow_backup
excluded files with "~" at the end, which is quite confusing. Let's get
rid of it before it gets used in the wrong place.

2 years agobasic/dirent-util: do not call hidden_file_allow_backup from dirent_is_file_with_suffix
Zbigniew Jędrzejewski-Szmek [Wed, 27 Apr 2016 12:59:12 +0000 (08:59 -0400)]
basic/dirent-util: do not call hidden_file_allow_backup from dirent_is_file_with_suffix

If the file name is supposed to end in a suffix, there's not need to check the
name against a list of "special" file names, which is slow. Instead, just check
that the name doens't start with a period.

2 years agopath-util: Add hidden suffixes for ucf (#3131)
Martin Pitt [Wed, 27 Apr 2016 07:58:42 +0000 (09:58 +0200)]
path-util: Add hidden suffixes for ucf (#3131)

ucf is a standard Debian helper for managing configuration file upgrades which
need more interaction or elaborate merging than conffiles managed by dpkg.
Ignore its temporary and backup files similarly to the *.dpkg-* ones to avoid
creating units for them in generators.

https://bugs.debian.org/775903

2 years agobuild-sys: improve compat with older kernel headers
Lennart Poettering [Wed, 27 Apr 2016 07:44:49 +0000 (09:44 +0200)]
build-sys: improve compat with older kernel headers

In 4.2 kernel headers, some netlink defines are missing that we need. missing.h
already can add them in, but currently makes this dependent on a definition
that these kernels already have. Change the check hence to check for the newest
definition in the table, so that the whole bunch of definitions as added in on
all kernels lacking this.

2 years agoelogind --user: call pam_loginuid when creating user@.service (#3120)
Zbigniew Jędrzejewski-Szmek [Tue, 26 Apr 2016 09:19:10 +0000 (05:19 -0400)]
elogind --user: call pam_loginuid when creating user@.service (#3120)

This way the user service will have a loginuid, and it will be inherited by
child services. This shouldn't change anything as far as elogind itself is
concerned, but is nice for various services spawned from by elogind --user
that expect a loginuid.

pam_loginuid(8) says that it should be enabled for "..., crond and atd".
user@.service should behave similarly to those two as far as audit is
concerned.

https://bugzilla.redhat.com/show_bug.cgi?id=1328947#c28

2 years agonspawn: don't try to patch UIDs/GIDs of procfs and suchlike
Lennart Poettering [Fri, 22 Apr 2016 16:10:16 +0000 (18:10 +0200)]
nspawn: don't try to patch UIDs/GIDs of procfs and suchlike

2 years agonspawn: make -U a tiny bit smarter
Lennart Poettering [Fri, 22 Apr 2016 12:10:09 +0000 (14:10 +0200)]
nspawn: make -U a tiny bit smarter

With this change -U will turn on user namespacing only if the kernel actually
supports it and otherwise gracefully degrade to non-userns mode.

2 years agotree-wide: use mdash instead of a two minuses
Zbigniew Jędrzejewski-Szmek [Fri, 22 Apr 2016 02:57:06 +0000 (22:57 -0400)]
tree-wide: use mdash instead of a two minuses

2 years agonetworkd: bump MTU to 1280 for interfaces which have IPv6 enabled (#3077)
Susant Sahani [Thu, 21 Apr 2016 00:34:13 +0000 (06:04 +0530)]
networkd: bump MTU to 1280 for interfaces which have IPv6 enabled (#3077)

IPv6 protocol requires a minimum MTU of 1280 bytes on the interface.
This fixes #3046.

Introduce helper link_ipv6_enabled() to figure out whether IPV6 is enabled.
Introduce network_has_static_ipv6_addresses() to find out if any static
ipv6 address configured.
If IPv6 is not configured on any interface that is SLAAC, DHCPv6 and static
IPv6 addresses not configured, then IPv6 will be automatically disabled for that
interface, that is we write "1" to /proc/sys/net/ipv6/conf//disable_ipv6.

2 years agotree-wide: don't assume CLOCK_BOOTIME is generally available
Lennart Poettering [Wed, 20 Apr 2016 16:12:57 +0000 (18:12 +0200)]
tree-wide: don't assume CLOCK_BOOTIME is generally available

Before we invoke now(CLOCK_BOOTTIME), let's make sure we actually have that
clock, since now() will otherwise hit an assert.

Specifically, let's refuse CLOCK_BOOTTIME early in sd-event if the kernel
doesn't actually support it.

This is a follow-up for #3037, and specifically:

https://github.com/elogind/elogind/pull/3037#issuecomment-210199167

2 years agoshared: move unit-specific code from bus-util.h to bus-unit-util.h
Lennart Poettering [Wed, 20 Apr 2016 15:43:13 +0000 (17:43 +0200)]
shared: move unit-specific code from bus-util.h to bus-unit-util.h

Previously we'd have generally useful sd-bus utilities in bust-util.h,
intermixed with code that is specifically for writing clients for PID 1,
wrapping job and unit handling. Let's split the latter out and move it into
bus-unit-util.c, to make the sources a bit short and easier to grok.

2 years agocore,systemctl: add bus API to retrieve processes of a unit
Lennart Poettering [Wed, 20 Apr 2016 13:28:28 +0000 (15:28 +0200)]
core,systemctl: add bus API to retrieve processes of a unit

This adds a new GetProcesses() bus call to the Unit object which returns an
array consisting of all PIDs, their process names, as well as their full cgroup
paths. This is then used by "systemctl status" to show the per-unit process
tree.

This has the benefit that the client-side no longer needs to access the
cgroupfs directly to show the process tree of a unit. Instead, it now uses this
new API, which means it also works if -H or -M are used correctly, as the
information from the specific host is used, and not the one from the local
system.

Fixes: #2945

2 years agologind: use type to determine graphical sessions (#3071)
Michał Bartoszkiewicz [Wed, 20 Apr 2016 08:06:26 +0000 (10:06 +0200)]
logind: use type to determine graphical sessions (#3071)

2 years agobasic: user-utils.c needs missing.h for secure_getenv (#3059)
michaelolbrich [Mon, 18 Apr 2016 13:28:00 +0000 (15:28 +0200)]
basic: user-utils.c needs missing.h for secure_getenv (#3059)

Otherwise building may fail with:

src/basic/user-util.c: In function 'get_home_dir':
src/basic/user-util.c:343:9: error: implicit declaration of function 'secure_getenv' [-Werror=implicit-function-declaration]

2 years agonetworkd: allow setting of multicast querier for linux bridge (#3051)
Susant Sahani [Mon, 18 Apr 2016 11:45:52 +0000 (17:15 +0530)]
networkd: allow setting of multicast querier for linux bridge (#3051)

2 years agoconf-parser: Set EXTRACT_RETAIN_ESCAPE when extracting words (#2917)
Dan Nicholson [Mon, 18 Apr 2016 02:52:45 +0000 (19:52 -0700)]
conf-parser: Set EXTRACT_RETAIN_ESCAPE when extracting words (#2917)

If you reference another unit with an escaped name, the escaped characters
should remain in the extracted word. This used to work correctly prior to
commit 34f253f0.

The problem can be seen when units with escaped names are referenced.

$ cat "/usr/lib/elogind/system/dev-disk-by\x2dlabel-eos\x2dswap.swap"
[Swap]
What=/dev/disk/by-label/eos-swap

[Install]
WantedBy=dev-disk-by\x2dlabel-eos\x2dswap.device

$ systemctl enable "dev-disk-by\x2dlabel-eos\x2dswap.swap"
Created symlink
/etc/elogind/system/dev-disk-byx2dlabel-eosx2dswap.device.wants/dev-disk-by\x2dlabel-eos\x2dswap.swap,
pointing to /usr/lib/elogind/system/dev-disk-by\x2dlabel-eos\x2dswap.swap.

The wants directory should be created with the x2ds escaped with \.

2 years agotree-wide: fall back to now(CLOCK_MONOTONIC) if CLOCK_BOOTTIME unsupported (#3037)
Lubomir Rintel [Mon, 18 Apr 2016 01:45:42 +0000 (03:45 +0200)]
tree-wide: fall back to now(CLOCK_MONOTONIC) if CLOCK_BOOTTIME unsupported (#3037)

It was added in 2.6.39, and causes an assertion to fail when running in mock
hosted on 2.6.32-based RHEL-6:

Assertion 'clock_gettime(map_clock_id(clock_id), &ts) == 0' failed at elogind/src/basic/time-util.c:70, function now(). Aborting.

2 years agoshared/install,systemctl,core: report offending file on installation error
Zbigniew Jędrzejewski-Szmek [Sun, 17 Apr 2016 14:16:44 +0000 (10:16 -0400)]
shared/install,systemctl,core: report offending file on installation error

Fixes #2191:

$ systemctl --root=/ enable sddm
Created symlink /etc/elogind/system/display-manager.service, pointing to /usr/lib/elogind/system/sddm.service.
$ sudo build/systemctl --root=/ enable gdm
Failed to enable unit, file /etc/elogind/system/display-manager.service already exists and is a symlink to /usr/lib/elogind/system/sddm.service.
$ sudo build/systemctl --root= enable sddm
$ sudo build/systemctl --root= enable gdm
Failed to enable unit: File /etc/elogind/system/display-manager.service already exists and is a symlink to /usr/lib/elogind/system/sddm.service.

(I tried a few different approaches to pass the error information back to the
caller. Adding a new parameter to hold the error results in a gigantic patch
and a lot of hassle to pass the args arounds. Adding this information to the
changes array is straightforward and can be more easily extended in the
future.)

In case local installation is performed, the full set of errors can be reported
and we do that. When running over dbus, only the first error is reported.

2 years agotree-wide: introduce PATH_IN_SET macro
Zbigniew Jędrzejewski-Szmek [Sun, 17 Apr 2016 02:52:06 +0000 (22:52 -0400)]
tree-wide: introduce PATH_IN_SET macro

2 years agosystemctl/core: ignore masked units in preset-all
Zbigniew Jędrzejewski-Szmek [Sat, 16 Apr 2016 23:31:53 +0000 (19:31 -0400)]
systemctl/core: ignore masked units in preset-all

With any masked unit that would that would be enabled by presets, we'd get:

test@rawhide $ sudo systemctl preset-all
Failed to execute operation: Unit file is masked.

test@rawhide $ sudo systemctl --root=/ preset-all
Operation failed: Cannot send after transport endpoint shutdown

Simply ignore those units:

test@rawhide $ sudo systemctl preset-all
Unit xxx.service is masked, ignoring.

2 years agosd-bus: use IN_SET
Zbigniew Jędrzejewski-Szmek [Sat, 16 Apr 2016 22:21:58 +0000 (18:21 -0400)]
sd-bus: use IN_SET

2 years agocore/mount-setup.c: also relabel /dev/shm for selinux (#3039)
Harald Hoyer [Thu, 14 Apr 2016 23:14:29 +0000 (01:14 +0200)]
core/mount-setup.c: also relabel /dev/shm for selinux (#3039)

daemons, which wish to transition state from the initramfs to the real
root, might use /dev/shm for their state.

As /dev is not relabeled across mount points, /dev/shm has to be
relabled explicitly.

2 years agosd-bus: query pid also when searching for supplementary gids
Ismo Puustinen [Wed, 13 Apr 2016 12:38:03 +0000 (15:38 +0300)]
sd-bus: query pid also when searching for supplementary gids

If the SD_BUS_CREDS_SUPPLEMENTARY_GIDS value is requested, the pid is
queried to find out the supplementary gids value from /proc/pid/status.
Otherwise sd_bus_creds_get_supplementary_gids() won't work unless some
other value in mask triggered fetching the pid information.

2 years agologind: allow any user to request lingering
Zbigniew Jędrzejewski-Szmek [Wed, 13 Apr 2016 02:52:28 +0000 (22:52 -0400)]
logind: allow any user to request lingering

We enable lingering for anyone who wants this. It is still disabled by
default to avoid keeping long-running processes accidentally.
Admins might want to customize this policy on multi-user sites.

2 years agocore: make sure we generate a nicer error when a linked unit is attempted to be enabled
Lennart Poettering [Mon, 11 Apr 2016 15:57:05 +0000 (17:57 +0200)]
core: make sure we generate a nicer error when a linked unit is attempted to be enabled

We don't allow using config symlinks to enable units, but the error message we
printed was awful. Fix that, and generate a more readable error.

Fixes #3010.

2 years agologind: reload config on SIGHUP
Zbigniew Jędrzejewski-Szmek [Sat, 9 Apr 2016 19:03:19 +0000 (15:03 -0400)]
logind: reload config on SIGHUP

v2:
- fix setting of kill_user_processes and
  *_ignore_inhibited settings

2 years agotree-wide: remove useless NULLs from strjoina
Zbigniew Jędrzejewski-Szmek [Sat, 9 Apr 2016 18:04:09 +0000 (14:04 -0400)]
tree-wide: remove useless NULLs from strjoina

The coccinelle patch didn't work in some places, I have no idea why.

2 years agobasic/util: check return value of dup2 in fork_agent()
Zbigniew Jędrzejewski-Szmek [Sat, 9 Apr 2016 01:08:29 +0000 (21:08 -0400)]
basic/util: check return value of dup2 in fork_agent()

CID #1304689.

2 years agotests: override XDG_RUNTIME_DIR where we use the user runtime dir
Lennart Poettering [Fri, 8 Apr 2016 16:54:05 +0000 (18:54 +0200)]
tests: override XDG_RUNTIME_DIR where we use the user runtime dir

We don#t really support systems where XDG_RUNTIME_DIR is not supported for
elogind --user. Hence, let's always set our own XDG_RUNTIME_DIR for tests that
involve elogind --user, so that we know it is set, and that it doesn't polute
the user's actual runtime dir.

2 years agotree-wide: add new SIGNAL_VALID() macro-like function that validates signal numbers
Lennart Poettering [Fri, 8 Apr 2016 09:27:28 +0000 (11:27 +0200)]
tree-wide: add new SIGNAL_VALID() macro-like function that validates signal numbers

And port all code over to use it.

2 years agocore: be more paranoid when mixing umask and fopen()
Lennart Poettering [Thu, 7 Apr 2016 14:15:26 +0000 (16:15 +0200)]
core: be more paranoid when mixing umask and fopen()

Let's be extra careful with the umask when we use simple fopen(), as this
creates files with 0777 by default.

2 years agocore: rework how transient unit files and property drop-ins work
Lennart Poettering [Thu, 7 Apr 2016 13:43:59 +0000 (15:43 +0200)]
core: rework how transient unit files and property drop-ins work

With this change the logic for placing transient unit files and drop-ins
generated via "systemctl set-property" is reworked.

The latter are now placed in the newly introduced "control" unit file
directory. The fomer are now placed in the "transient" unit file directory.

Note that the properties originally set when a transient unit was created will
be written to and stay in the transient unit file directory, while later
changes are done via drop-ins.

This is preparation for a later "systemctl revert" addition, where existing
drop-ins are flushed out, but the original transient definition is restored.

2 years agopolkit: don't start polkit agent when running as root
Martin Pitt [Tue, 5 Apr 2016 08:30:45 +0000 (10:30 +0200)]
polkit: don't start polkit agent when running as root

On the server side we already bypass the polkit checks if the caller is root
(see the sd_bus_query_sender_privilege() call in bus_verify_polkit_async()). So
there is no reason to invoke polkit when running
systemctl/machinectl/loginctl/timedatectl as root.

Fixes #2748

2 years agobasic: fallback to fstatat if entry->d_type is DT_UNKNOWN
Evgeny Vereshchagin [Mon, 4 Apr 2016 11:07:56 +0000 (14:07 +0300)]
basic: fallback to fstatat if entry->d_type is DT_UNKNOWN

* tests-functions: improve FSTYPE-support

make clean setup FSTYPE=reiserfs is working fine now :)

* basic: fallback to fstatat if entry->d_type is DT_UNKNOWN

Fixes localectl on reiserfs:

-bash-4.3# mkdir -p /usr/lib/locale
-bash-4.3# stat -f /usr/lib/locale/
  File: "/usr/lib/locale/"
    ID: bdb0322715b5366e Namelen: 255     Type: reiserfs
Block size: 4096
Blocks: Total: 99835      Free: 60262      Available: 60262
Inodes: Total: 0          Free: 0
-bash-4.3# mkdir /usr/lib/locale/HeyHo
-bash-4.3# localectl list-locales --no-pager

-bash-4.3# mount -t tmpfs tmpfs /usr/lib/locale
-bash-4.3# mkdir /usr/lib/locale/HeyHo
-bash-4.3# localectl list-locales --no-pager
HeyHo

2 years agotest-compress-benchmark: fix argument parsing on 32bit
Zbigniew Jędrzejewski-Szmek [Sat, 2 Apr 2016 21:46:49 +0000 (17:46 -0400)]
test-compress-benchmark: fix argument parsing on 32bit

The patch is not minimal, but a function to parse size_t is probably
going to come in handy in other places, so I think it's nicer to define
a proper parsing function than to open-code the cast.

2 years agobus-util: Fix reading uint32 properties
Martin Pitt [Fri, 1 Apr 2016 12:16:14 +0000 (14:16 +0200)]
bus-util: Fix reading uint32 properties

Fix copy&paste bug in map_basic() to use the correct data type for
SD_BUS_TYPE_UINT32. Before we were copying the wrong 32 bits into the
destination pointer, resulting in complete garbage on big-endian systems.

Fixes #2927

2 years agoshared: fix a misspelling of "journalctl"
Biao Lu [Mon, 28 Mar 2016 17:46:04 +0000 (01:46 +0800)]
shared: fix a misspelling of "journalctl"

2 years agocore: update populated event handling in unified hierarchy
Tejun Heo [Fri, 25 Mar 2016 15:38:50 +0000 (11:38 -0400)]
core: update populated event handling in unified hierarchy

Earlier during the development of unified hierarchy, the populated event was
reported through by the dedicated "cgroup.populated" file; however, the
interface was updated so that it's reported through the "populated" field of
"cgroup.events" file.  Update populated event handling logic accordingly.

2 years agoIgnore BOM in config files
Zbigniew Jędrzejewski-Szmek [Tue, 22 Mar 2016 03:34:13 +0000 (23:34 -0400)]
Ignore BOM in config files

Fixes #2823.

Also remove unnecessary feof check.

2 years agobasic/missing: move syscall definitions to basic/missing_syscall.h
Zbigniew Jędrzejewski-Szmek [Thu, 17 Mar 2016 17:26:13 +0000 (13:26 -0400)]
basic/missing: move syscall definitions to basic/missing_syscall.h

We have a bunch of syscall wrapper definitions and it's easier to
see that they follow the same pattern if they are not interspersed
with other defines.

Change the wrappers to be uniform:
- if __NR_XXX is not defined, do not bother to call the syscall,
  and return -1/ENOSYS immediately.
- do not check __NR_XXX defines if we detect the symbol as defined,
  since we don't need them anyway
- reindent stuff for readability

New file basic/missing_syscall.h is included at the end of missing.h
because it might make use of some of the definitions in missing.h.

2 years agologinctl: add --value option
Zbigniew Jędrzejewski-Szmek [Thu, 17 Mar 2016 16:48:02 +0000 (12:48 -0400)]
loginctl: add --value option

2 years agorules: allow users to access frame buffer devices
Zbigniew Jędrzejewski-Szmek [Thu, 17 Mar 2016 12:40:39 +0000 (08:40 -0400)]
rules: allow users to access frame buffer devices

For example it allows weston to be started unprivileged.

Related discussion:
https://bugs.freedesktop.org/show_bug.cgi?id=73782
https://lists.freedesktop.org/archives/wayland-devel/2015-May/022005.html
https://bugzilla.redhat.com/show_bug.cgi?id=1226680

2 years agobasic/log: remove unused return value
Zbigniew Jędrzejewski-Szmek [Tue, 15 Mar 2016 23:27:36 +0000 (19:27 -0400)]
basic/log: remove unused return value

2 years agobasic/macros: clang 3.5 doesn't support alloc_size
Zbigniew Jędrzejewski-Szmek [Tue, 15 Mar 2016 23:27:28 +0000 (19:27 -0400)]
basic/macros: clang 3.5 doesn't support alloc_size

The attribute was removed in commit c047507 in the clang repository as it
was never properly implemented anyway. Avoid using the attribute with
clang because it generates a ton of annoying warnings.

2 years agobasic/missing: add copy_file_range
Zbigniew Jędrzejewski-Szmek [Tue, 15 Mar 2016 23:26:30 +0000 (19:26 -0400)]
basic/missing: add copy_file_range

syscall numbers based on:
https://fedora.juszkiewicz.com.pl/syscalls.html

2 years agoAdded support for 3D printers to uaccess (ID_MAKER_TOOL)
Jaroslav Škarvada [Tue, 15 Mar 2016 13:25:51 +0000 (14:25 +0100)]
Added support for 3D printers to uaccess (ID_MAKER_TOOL)

This is to support 3D printers, CNCs, laser cutters, 3D scanners, etc.

2 years agoinclude sys/sysmacros.h in more places
Mike Frysinger [Mon, 14 Mar 2016 21:44:49 +0000 (17:44 -0400)]
include sys/sysmacros.h in more places

Since glibc is moving away from implicitly including sys/sysmacros.h
all the time via sys/types.h, include the header directly in more
places.  This seems to cover most makedev/major/minor usage.

2 years agoheaders: use __inline__ instead of inline
Zbigniew Jędrzejewski-Szmek [Fri, 11 Mar 2016 18:41:49 +0000 (13:41 -0500)]
headers: use __inline__ instead of inline

https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Alternate-Keywords.html#Alternate-Keywords
recommends __inline__ over inline in ANSI C compatible headers.
Tested with gcc-5.3 and clang-3.7.

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

2 years agostring-table: split long definitions
Zbigniew Jędrzejewski-Szmek [Fri, 4 Mar 2016 16:28:04 +0000 (11:28 -0500)]
string-table: split long definitions

2 years agotree-wide: use SET_FLAG() macro to make code more clear
Alexander Kuleshov [Thu, 3 Mar 2016 17:30:37 +0000 (23:30 +0600)]
tree-wide: use SET_FLAG() macro to make code more clear

2 years agoselinux: always try to load the full selinux db
Zbigniew Jędrzejewski-Szmek [Wed, 2 Mar 2016 01:35:55 +0000 (20:35 -0500)]
selinux: always try to load the full selinux db

https://github.com/elogind/elogind/pull/2508#issuecomment-190901170
Maybe fixes https://bugzilla.redhat.com/show_bug.cgi?id=1308771.

2 years agotree-wide: no need to pass excess flags to open()/openat() if O_PATH is passed
Alexander Kuleshov [Tue, 1 Mar 2016 18:25:09 +0000 (00:25 +0600)]
tree-wide: no need to pass excess flags to open()/openat() if O_PATH is passed

As described in the documentation:

When O_PATH is specified in flags, flag bits other than O_CLOEXEC,
O_DIRECTORY, and O_NOFOLLOW are ignored.

So, we can remove unnecessary flags in a case when O_PATH is passed
to the open() or openat().

2 years agoRedefine 32bit time_t format to signed
Zbigniew Jędrzejewski-Szmek [Tue, 1 Mar 2016 17:08:02 +0000 (12:08 -0500)]
Redefine 32bit time_t format to signed

It seems that it is signed both on i386 and arm.

Avoids a stupid gcc warning on arm:

src/udev/udevadm-monitor.c: In function ‘print_device’:
src/udev/udevadm-monitor.c:44:16: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘__time_t {aka long int}’ [-Wformat=]
         printf("%-6s[%"PRI_TIME".%06ld] %-8s %s (%s)\n",
                ^

2 years agocore: avoid compiler warning when compiling with -fexceptions
Thomas Haller [Sat, 27 Feb 2016 12:40:50 +0000 (13:40 +0100)]
core: avoid compiler warning when compiling with -fexceptions

Initialize auto variables with cleanup attribute, otherwise we
get a compiler warning with -fexceptions.

    ./configure CFLAGS='-Wmaybe-uninitialized -fexceptions -O2'

2 years agocore: when enabling a generated unit file, return a clean error
Lennart Poettering [Wed, 24 Feb 2016 15:02:48 +0000 (16:02 +0100)]
core: when enabling a generated unit file, return a clean error

Let's be precise when the user tries to invoke an "enable" operation on a
generated unit file.

2 years agobasic: mark unused variable as such
Thomas Hindoe Paaboel Andersen [Tue, 23 Feb 2016 18:21:54 +0000 (19:21 +0100)]
basic: mark unused variable as such

2 years agotree-wide: minor formatting inconsistency cleanups
Vito Caputo [Tue, 23 Feb 2016 17:52:52 +0000 (09:52 -0800)]
tree-wide: minor formatting inconsistency cleanups

2 years agotree-wide: make ++/-- usage consistent WRT spacing
Vito Caputo [Tue, 23 Feb 2016 04:32:04 +0000 (20:32 -0800)]
tree-wide: make ++/-- usage consistent WRT spacing

Throughout the tree there's spurious use of spaces separating ++ and --
operators from their respective operands.  Make ++ and -- operator
consistent with the majority of existing uses; discard the spaces.