chiark / gitweb /
elogind.git
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)

6 years agocore: remove duplicate includes (#3771)
Thomas H. P. Andersen [Thu, 21 Jul 2016 08:52:07 +0000 (10:52 +0200)]
core: remove duplicate includes (#3771)

6 years agocgroup: suppress sending follow-up SIGCONT after sending SIGCONT/SIGKILL anyway
Lennart Poettering [Wed, 20 Jul 2016 09:16:53 +0000 (11:16 +0200)]
cgroup: suppress sending follow-up SIGCONT after sending SIGCONT/SIGKILL anyway

6 years agocore: when forcibly killing/aborting left-over unit processes log about it
Lennart Poettering [Wed, 20 Jul 2016 09:16:05 +0000 (11:16 +0200)]
core: when forcibly killing/aborting left-over unit processes log about it

Let's lot at LOG_NOTICE about any processes that we are going to
SIGKILL/SIGABRT because clean termination of them didn't work.

This turns the various boolean flag parameters to cg_kill(), cg_migrate() and
related calls into a single binary flags parameter, simply because the function
now gained even more parameters and the parameter listed shouldn't get too
long.

Logging for killing processes is done either when the kill signal is SIGABRT or
SIGKILL, or on explicit request if KILL_TERMINATE_AND_LOG instead of LOG_TERMINATE
is passed. This isn't used yet in this patch, but is made use of in a later
patch.

6 years agoutil: don't send SIGCONT following a SIGCONT or SIGKILL in kill_and_sigcont()
Lennart Poettering [Wed, 20 Jul 2016 09:14:48 +0000 (11:14 +0200)]
util: don't send SIGCONT following a SIGCONT or SIGKILL in kill_and_sigcont()

6 years agologind: change TasksMax= value for user logins to 33%
Lennart Poettering [Tue, 19 Jul 2016 15:19:58 +0000 (17:19 +0200)]
logind: change TasksMax= value for user logins to 33%

Let's change from a fixed value of 12288 tasks per user to a relative value of
33%, which with the kernel's default of 32768 translates to 10813. This is a
slight decrease of the limit, for no other reason than "33%" sounding like a nice
round number that is close enough to 12288 (which would translate to 37.5%).
(Well, it also has the nice effect of still leaving a bit of room in the PID
space if there are 3 cooperating evil users that try to consume all PIDs...
Also, I like my bikesheds blue).

Since the new value is taken relative, and machined's TasksMax= setting
defaults to 16384, 33% inside of containers is usually equivalent to 5406,
which should still be ample space.

To summarize:

               | on the host | in the container
   old default |       12288 |            12288
   new default |       10813 |             5406

6 years agobasic: fix whitespace
Thomas Hindoe Paaboel Andersen [Mon, 18 Jul 2016 20:14:23 +0000 (22:14 +0200)]
basic: fix whitespace

6 years agotree-wide: get rid of selinux_context_t (#3732)
Zbigniew Jędrzejewski-Szmek [Fri, 15 Jul 2016 16:44:02 +0000 (12:44 -0400)]
tree-wide: get rid of selinux_context_t (#3732)

https://github.com/SELinuxProject/selinux/commit/9eb9c9327563014ad6a807814e7975424642d5b9
deprecated selinux_context_t. Replace with a simple char* everywhere.

Alternative fix for #3719.

6 years agoconf-parser: minor coding style improvements
Lennart Poettering [Thu, 14 Jul 2016 10:24:59 +0000 (12:24 +0200)]
conf-parser: minor coding style improvements

6 years agobasic/mount-util: recognize ocfs2 as network fs (#3713)
Valentin Vidić [Thu, 14 Jul 2016 05:34:36 +0000 (07:34 +0200)]
basic/mount-util: recognize ocfs2 as network fs (#3713)

6 years agoVarious fixes for typos found by lintian (#3705)
Michael Biebl [Tue, 12 Jul 2016 10:52:11 +0000 (12:52 +0200)]
Various fixes for typos found by lintian (#3705)

6 years agotreewide: fix typos and remove accidental repetition of words
Torstein Husebø [Sun, 10 Jul 2016 12:48:23 +0000 (14:48 +0200)]
treewide: fix typos and remove accidental repetition of words

6 years agobasic: log: Increase static buffer for source file location (#3674)
Daniel Mack [Thu, 7 Jul 2016 04:30:34 +0000 (06:30 +0200)]
basic: log: Increase static buffer for source file location (#3674)

Commit d054f0a4 ("tree-wide: use xsprintf() where applicable") used a
semantic patch approach to change a number of locations from

  snprintf(buf, sizeof(buf), FMT, ...)

to

  xsprintf(buf, FMT, ...)

The problem is that xsprintf() wraps the snprintf() in an
assert_message_se(), so if snprintf() reports an overflow of the
destination buffer, the binary will now terminate.

This hit a user running a version of elogind that was built from a
deeply nested system path.

Fix this by

a) Switching back to snprintf() for this particular case. We should really
rather truncate the location string than crash in such situations.

b) Increasing the size of that static string buffer, to make the event more
unlikely.

6 years agonamespace: unify limit behavior on non-directory paths
Alessandro Puccetti [Wed, 6 Jul 2016 07:48:58 +0000 (09:48 +0200)]
namespace: unify limit behavior on non-directory paths

Despite the name, `Read{Write,Only}Directories=` already allows for
regular file paths to be masked. This commit adds the same behavior
to `InaccessibleDirectories=` and makes it explicit in the doc.
This patch introduces `/run/elogind/inaccessible/{reg,dir,chr,blk,fifo,sock}`
{dile,device}nodes and mounts on the appropriate one the paths specified
in `InacessibleDirectories=`.

Based on Luca's patch from https://github.com/elogind/elogind/pull/3327

6 years agotreewide: use stdio_unset_cloexec() function
Alexander Kuleshov [Sat, 2 Jul 2016 17:42:01 +0000 (23:42 +0600)]
treewide: use stdio_unset_cloexec() function

6 years agobasic/fd-util: introduce stdio_unset_cloexec() function
Alexander Kuleshov [Sat, 2 Jul 2016 17:38:47 +0000 (23:38 +0600)]
basic/fd-util: introduce stdio_unset_cloexec() function

There are some places in the elogind which are use the same pattern:

    fd_cloexec(STDIN_FILENO, false);
    fd_cloexec(STDOUT_FILENO, false);
    fd_cloexec(STDERR_FILENO, false);

to unset CLOEXEC for standard file descriptors. This patch introduces
the stdio_unset_cloexec() function to hide this and make code cleaner.

6 years agosd-bus: Fix a read after free error in bus-match. (#3624) (#3625)
Weng Xuetian [Wed, 29 Jun 2016 20:22:12 +0000 (13:22 -0700)]
sd-bus: Fix a read after free error in bus-match. (#3624) (#3625)

The loop on bus_match_run should break and return immediately if
bus->match_callbacks_modified is true. Otherwise the loop may access
free'd data.

6 years agoDrop parentheses in two places
Zbigniew Jędrzejewski-Szmek [Tue, 28 Jun 2016 19:12:01 +0000 (15:12 -0400)]
Drop parentheses in two places

6 years agoAdded Indonesian translation (#3615)
Andika Triwidada [Tue, 28 Jun 2016 08:14:27 +0000 (15:14 +0700)]
Added Indonesian translation (#3615)

6 years agobasic/strv: introduce STRV_IGNORE macro (#3601)
0xAX [Mon, 27 Jun 2016 21:26:07 +0000 (00:26 +0300)]
basic/strv: introduce STRV_IGNORE macro (#3601)

to hide casting of '-1' strings and make code cleaner.

6 years agobasic: pass flags to the fnmatch (#3606)
Evgeny Vereshchagin [Mon, 27 Jun 2016 12:47:37 +0000 (15:47 +0300)]
basic: pass flags to the fnmatch (#3606)

Fixes:
```
$ systemctl list-unit-files 'hey\*'

0 unit files listed.

$ systemctl list-unit-files | grep hey
hey\x7eho.service                          static
```

6 years agobasic/strv: use SWAP_TWO() macro (#3602)
0xAX [Sun, 26 Jun 2016 10:37:00 +0000 (13:37 +0300)]
basic/strv: use SWAP_TWO() macro (#3602)

6 years agotree-wide: some work-arounds for gcc false positives regarding uninitialized variables
Lennart Poettering [Tue, 21 Jun 2016 11:20:02 +0000 (13:20 +0200)]
tree-wide: some work-arounds for gcc false positives regarding uninitialized variables

6 years agocore: log the right set of the supported controllers (#3558)
Evgeny Vereshchagin [Mon, 20 Jun 2016 18:40:46 +0000 (21:40 +0300)]
core: log the right set of the supported controllers (#3558)

Jun 16 05:12:08 elogind[1]: Controller 'io' supported: yes
Jun 16 05:12:08 elogind[1]: Controller 'memory' supported: yes
Jun 16 05:12:08 elogind[1]: Controller 'pids' supported: yes

instead of

Jun 16 04:06:50 elogind[1]: Controller 'memory' supported: yes
Jun 16 04:06:50 elogind[1]: Controller 'devices' supported: yes
Jun 16 04:06:50 elogind[1]: Controller 'pids' supported: yes

6 years agoprocess-util: fix two bugs in get_process_cmdline() (#3555)
Lennart Poettering [Thu, 16 Jun 2016 20:46:44 +0000 (22:46 +0200)]
process-util: fix two bugs in get_process_cmdline() (#3555)

See:

https://github.com/elogind/elogind/pull/3529#issuecomment-226421007

6 years agosystemctl: make sure we terminate the bus connection first, and then close the pager...
Lennart Poettering [Thu, 16 Jun 2016 13:29:16 +0000 (15:29 +0200)]
systemctl: make sure we terminate the bus connection first, and then close the pager (#3550)

If "systemctl -H" is used, let's make sure we first terminate the bus
connection, and only then close the pager. If done in this order ssh will get
an EOF on stdin (as we speak D-Bus through ssh's stdin/stdout), and then
terminate. This makes sure the standard error we were invoked on is released by
ssh, and only that makes sure we don't deadlock on the pager which waits for
all clients closing its input pipe.

(Similar fixes for the various other xyzctl tools that support both pagers and
-H)

Fixes: #3543
6 years agosd-bus: make sure bus_map_all_properties() handle booleans right
Lennart Poettering [Wed, 15 Jun 2016 20:41:56 +0000 (22:41 +0200)]
sd-bus: make sure bus_map_all_properties() handle booleans right

sd-bus generally exposes bools as "int" instead of "bool" in the public API.
This is relevant when unmarshaling booleans, as the relevant functions expect
an int* pointer and no bool* pointer. Since sizeof(bool) is not necessarily the
same as sizeof(int) this is problematic and might result in memory corruption.

Let's fix this, and make sure bus_map_all_properties() handles booleans as
ints, as the rest of sd-bus, and make all users of it expect the right thing.

6 years agostring-table: make sure DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN() handles NULL string...
Lennart Poettering [Wed, 15 Jun 2016 20:25:48 +0000 (22:25 +0200)]
string-table: make sure DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN() handles NULL strings nicely

xyz_from_string() functions defined with DEFINE_STRING_TABLE_LOOKUP() properly
handle NULL strings already. make sure the equivalent functions defined with
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN() do the same.

6 years agosocket-util: Run the fallback when the kernel complains about the null buffer (#3541)
Kai Ruhnau [Wed, 15 Jun 2016 10:33:24 +0000 (12:33 +0200)]
socket-util: Run the fallback when the kernel complains about the null buffer (#3541)

Calling recv with a NULL buffer returns EFAULT instead of EOPNOTSUPP on
older kernels (3.14).

Fixes #3407

Signed-off-by: Kai Ruhnau <kai.ruhnau@target-sg.com>
6 years agotree-wide: htonl() is weird, let's use htobe32() instead (#3538)
Lennart Poettering [Tue, 14 Jun 2016 23:26:01 +0000 (01:26 +0200)]
tree-wide: htonl() is weird, let's use htobe32() instead (#3538)

Super-important change, yeah!

6 years agoutil-lib: rework get_process_cmdline() (#3529)
Lennart Poettering [Tue, 14 Jun 2016 21:52:29 +0000 (23:52 +0200)]
util-lib: rework get_process_cmdline() (#3529)

This reworks get_process_cmdline() quite substantially, fixing the following:

- Fixes:
  https://github.com/elogind/elogind/pull/3512/commits/a4e3bf4d7ac2de51191ce136ee9361ba319e106c#r66837630

- The passed max_length is also applied to the "comm" name, if comm_fallback is
  set.

- The right thing happens if max_length == 1 is specified

- when the cmdline "foobar" is abbreviated to 6 characters the result is not
  "foobar" instead of "foo...".

- trailing whitespace are removed before the ... suffix is appended. The 7
  character abbreviation of "foo barz" is hence "foo..." instead of "foo ...".

- leading whitespace are suppressed from the cmdline

- a comprehensive test case is added

6 years agocore: set $JOURNAL_STREAM to the dev_t/ino_t of the journal stream of executed services
Lennart Poettering [Tue, 14 Jun 2016 14:50:45 +0000 (16:50 +0200)]
core: set $JOURNAL_STREAM to the dev_t/ino_t of the journal stream of executed services

This permits services to detect whether their stdout/stderr is connected to the
journal, and if so talk to the journal directly, thus permitting carrying of
metadata.

As requested by the gtk folks: #2473

6 years agobuild: fix missing symbol for old kernel headers (#3530)
Andrew Jeddeloh [Tue, 14 Jun 2016 09:09:06 +0000 (02:09 -0700)]
build: fix missing symbol for old kernel headers (#3530)

Fix issue where IN6_ADDR_GEN_MODE_STABLE_PRIVACY is undefined but
IFLA_INET6_ADDR_GEN_MODE is defined and thus the former does not get
fixed in missing.h. This occurs with kernel headers new enough to have
the IFLA_INET6_ADDR_GEN_MODE but old enough to not yet have
IN6_ADDR_GEN_MODE_STABLE_PRIVACY (e.g. 3.18).

6 years agounit-name: remove spurious newline
Lennart Poettering [Mon, 13 Jun 2016 16:47:42 +0000 (18:47 +0200)]
unit-name: remove spurious newline

6 years agocore: parse `rd.rescue` and `rd.emergency` as initrd-specific shorthands (#3488)
Ivan Shapovalov [Mon, 13 Jun 2016 14:28:42 +0000 (18:28 +0400)]
core: parse `rd.rescue` and `rd.emergency` as initrd-specific shorthands (#3488)

Typing `rd.rescue` is easier than `rd.elogind.unit=rescue.target`.

6 years agoutil-lib: drop trailing non-printable characters from cmdline (#3512)
Max Prokhorov [Mon, 13 Jun 2016 01:13:42 +0000 (04:13 +0300)]
util-lib: drop trailing non-printable characters from cmdline (#3512)

If max_length is equal or greater than cmdline length all trailing non-printable
characters are dropped. If max_length is 0 it should do the same.

This should also fix cmdline truncation if the last character is not '\0'.

Fixes #3469.

6 years agoprocess-util: remove broken support for pid==0
Zbigniew Jędrzejewski-Szmek [Mon, 13 Jun 2016 00:57:41 +0000 (20:57 -0400)]
process-util: remove broken support for pid==0

Our functions that query /proc/pid/ support using pid==0 to mean
self. get_process_id also seemed to support that, but it was not implemented
correctly: the result should be in *uid, not returned, and also it gave
completely bogus result when called from get_process_gid(). But afaict,
get_process_{uid,gid} were never called with pid==0, so it's not an actual
bug. Remove the broken code to avoid confusion.

6 years agoFixed a small typo in a comment (#3514)
Alex Gaynor [Sun, 12 Jun 2016 14:42:13 +0000 (10:42 -0400)]
Fixed a small typo in a comment (#3514)

6 years agoEnsure kdbus isn't used (#3501)
Dave Reisner [Fri, 10 Jun 2016 13:50:16 +0000 (09:50 -0400)]
Ensure kdbus isn't used (#3501)

Delete the dbus1 generator and some critical wiring. This prevents
kdbus from being loaded or detected. As such, it will never be used,
even if the user still has a useful kdbus module loaded on their system.

Sort of fixes #3480. Not really, but it's better than the current state.

6 years agonetworkd: added support for vrf interfaces (#3316)
Andreas Rammhold [Thu, 9 Jun 2016 23:57:51 +0000 (01:57 +0200)]
networkd: added support for vrf interfaces (#3316)

6 years agobus_util: add support to map double (#3479)
Susant Sahani [Thu, 9 Jun 2016 15:41:35 +0000 (21:11 +0530)]
bus_util: add support to map double (#3479)

Now we don't support parsing double at map_basic.
when trying to  use bus_message_map_all_properties with a double
this fails. Let's add it.

6 years agoutil: introduce physical_memory_scale() to unify how we scale by physical memory
Lennart Poettering [Wed, 8 Jun 2016 18:45:32 +0000 (20:45 +0200)]
util: introduce physical_memory_scale() to unify how we scale by physical memory

The various bits of code did the scaling all different, let's unify this,
given that the code is not trivial.

6 years agoutil-lib: introduce parse_percent() for parsing percent specifications
Lennart Poettering [Wed, 8 Jun 2016 17:25:38 +0000 (19:25 +0200)]
util-lib: introduce parse_percent() for parsing percent specifications

And port a couple of users over to it.

6 years agologind: minor cleanup and use IN_SET() in manager_handle_action()
Franck Bui [Wed, 8 Jun 2016 16:16:42 +0000 (18:16 +0200)]
logind: minor cleanup and use IN_SET() in manager_handle_action()

6 years agologind: really handle *KeyIgnoreInhibited options in logind.conf
Franck Bui [Wed, 8 Jun 2016 16:08:56 +0000 (18:08 +0200)]
logind: really handle *KeyIgnoreInhibited options in logind.conf

6 years agomissing include added for build with -DDEBUG (#3424)
Tobias Jungel [Fri, 3 Jun 2016 10:33:12 +0000 (12:33 +0200)]
missing include added for build with -DDEBUG (#3424)

6 years agocore: pass Unit into cgroup_context_apply() and use log_unit*()
Tejun Heo [Thu, 2 Jun 2016 17:02:49 +0000 (13:02 -0400)]
core: pass Unit into cgroup_context_apply() and use log_unit*()

cgroup_context_apply() and friends take CGroupContext and cgroup path as input
and has no way of getting back to the associated Unit and thus uses raw cgroup
path for logging.  This makes the log messages difficult to track down.
There's no reason to avoid passing in Unit into these functions.  Pass in Unit
and use log_unit*() instead.

While at it, make cgroup_context_apply(), which has no outside users, static.
Also, drop cgroup path from log messages where the path itself isn't too
interesting and can be easily obtained from the unit.

6 years agoutil-lib: add accessors for unaligned native endian words
Lennart Poettering [Thu, 2 Jun 2016 16:12:16 +0000 (18:12 +0200)]
util-lib: add accessors for unaligned native endian words

6 years agonetworkd: add support to configure VLAN on bridge ports
Tobias Jungel [Wed, 1 Jun 2016 13:18:21 +0000 (15:18 +0200)]
networkd: add support to configure VLAN on bridge ports

6 years agopager: don't start pager if the terminal is explicitly set to TERM=dumb
Lennart Poettering [Mon, 30 May 2016 16:23:54 +0000 (18:23 +0200)]
pager: don't start pager if the terminal is explicitly set to TERM=dumb

As suggested here:

https://bugs.freedesktop.org/show_bug.cgi?id=64737#c8

This adds a new call terminal_is_dumb() and makes use of this where
appropriate.

6 years agotree-wide: check colors_enabled() before outputting ANSI color strings
Lennart Poettering [Mon, 30 May 2016 16:23:08 +0000 (18:23 +0200)]
tree-wide: check colors_enabled() before outputting ANSI color strings

6 years agoutil-lib: make localed's nonempty() generic, rename it to empty_to_null() and make...
Lennart Poettering [Mon, 30 May 2016 15:59:43 +0000 (17:59 +0200)]
util-lib: make localed's nonempty() generic, rename it to empty_to_null() and make use of it everywhere

6 years agoutil-lib: Add sparc64 support for process creation (#3348)
Michael Karcher [Mon, 30 May 2016 00:03:51 +0000 (02:03 +0200)]
util-lib: Add sparc64 support for process creation (#3348)

The current raw_clone function takes two arguments, the cloning flags and
a pointer to the stack for the cloned child. The raw cloning without
passing a "thread main" function does not make sense if a new stack is
specified, as it returns in both the parent and the child, which will fail
in the child as the stack is virgin. All uses of raw_clone indeed pass NULL
for the stack pointer which indicates that both processes should share the
stack address (so you better don't pass CLONE_VM).

This commit refactors the code to not require the caller to pass the stack
address, as NULL is the only sensible option. It also adds the magic code
needed to make raw_clone work on sparc64, which does not return 0 in %o0
for the child, but indicates the child process by setting %o1 to non-zero.
This refactoring is not plain aesthetic, because non-NULL stack addresses
need to get mangled before being passed to the clone syscall (you have to
apply STACK_BIAS), whereas NULL must not be mangled. Implementing the
conditional mangling of the stack address would needlessly complicate the
code.

raw_clone is moved to a separete header, because the burden of including
the assert machinery and sched.h shouldn't be applied to every user of
missing_syscalls.h

6 years agologin: Fix policy for org.freedesktop.login1.set-self-linger (#3365) (#3373)
Michael Biebl [Sat, 28 May 2016 09:03:03 +0000 (11:03 +0200)]
login: Fix policy for org.freedesktop.login1.set-self-linger (#3365) (#3373)

We need to explicitly define authorizations for allow_inactive and
allow_active. Otherwise one is getting "Access denied" when run from a
local console:

$ loginctl enable-linger
Could not enable linger: Access denied

6 years agocore: add cgroup memory controller support on the unified hierarchy (#3315)
Tejun Heo [Fri, 27 May 2016 16:10:18 +0000 (09:10 -0700)]
core: add cgroup memory controller support on the unified hierarchy (#3315)

On the unified hierarchy, memory controller implements three control knobs -
low, high and max which enables more useable and versatile control over memory
usage.  This patch implements support for the three control knobs.

* MemoryLow, MemoryHigh and MemoryMax are added for memory.low, memory.high and
  memory.max, respectively.

* As all absolute limits on the unified hierarchy use "max" for no limit, make
  memory limit parse functions accept "max" in addition to "infinity" and
  document "max" for the new knobs.

* Implement compatibility translation between MemoryMax and MemoryLimit.

v2:

- Fixed missing else's in config_parse_memory_limit().
- Fixed missing newline when writing out drop-ins.
- Coding style updates to use "val > 0" instead of "val".
- Minor updates to documentation.

6 years agonspawn: a bench of special fileystems that should not be shifted
Djalal Harouni [Thu, 26 May 2016 20:38:25 +0000 (22:38 +0200)]
nspawn: a bench of special fileystems that should not be shifted

Add some special filesystems that should not be shifted, most of them
relate to the host and not to containers.

6 years agonetworkd: set IFLA_INET6_ADDR_GEN_MODE as per stable_secret
Tom Yan [Wed, 25 May 2016 12:04:01 +0000 (20:04 +0800)]
networkd: set IFLA_INET6_ADDR_GEN_MODE as per stable_secret

Although networkd has option (LinkLocalAddressing=) to toggle IPv6LL autoconfiguration, when it is enabled, the address is autoconfigured by the kernel, but not networkd.

Therefore, we do not statically set IFLA_INET6_ADDR_GEN_MODE to IN6_ADDR_GEN_MODE_EUI64, but dynamically depending on whether stable_secret is set, just as what the kernel does by default.

Note that this does NOT affect the global addresses configured by networkd.

6 years agoRevert "rules: allow users to access frame buffer devices" (#3333)
Zbigniew Jędrzejewski-Szmek [Tue, 24 May 2016 09:32:30 +0000 (05:32 -0400)]
Revert "rules: allow users to access frame buffer devices" (#3333)

This reverts commit 483d8bbb4c0190f419bf9fba57fb0feb1a56bea6.

In [1] Michel Dänzer and Daniel Vetter wrote:
>> The scenario you describe isn't possible if the Wayland compositor
>> directly uses the KMS API of /dev/dri/card*, but it may be possible if
>> the Wayland compositor uses the fbdev API of /dev/fb* instead (e.g. if
>> weston uses its fbdev backend).
>
> Yeah, if both weston and your screen grabber uses native fbdev API you can
> now screenshot your desktop. And since fbdev has no concept of "current
> owner of the display hw" like the drm master, I think this is not fixable.
> At least not just in userspace. Also even with native KMS compositors
> fbdev still doesn't have the concept of ownership, which is why it doesn't
> bother clearing it's buffer before KMS takes over. I agree that this
> should be reverted or at least hidden better.

TBH, I think that privilege separation between processes running under the same
UID is tenuous. Even with drm, in common setups any user process can ptrace the
"current owner of the display" and call DROP_MASTER or do whatever. It *is*
possible to prevent that, e.g. by disabling ptrace using yama.ptrace_scope, or
selinux, and so on, but afaik this is not commonly done. E.g. all Fedora
systems pull in elfutils-default-yama-scope.rpm through dependencies which sets
yama.ptrace_scope=0. And even assuming that ptrace was disabled, it is trivial
to modify files on disk, communicate through dbus, etc; there is just to many
ways for a non-sandboxed process to interact maliciously with the display shell
to close them all off. To achieve real protection, some sort of sandboxing
must be implemented, and in that case there is no need to rely on access mode
on the device files, since much more stringent measures have to be implemented
anyway.

The situation is similar for framebuffer devices. It is common to add
framebuffer users to video group to allow them unlimited access to /dev/fb*.
Using uaccess would be better solution in that case. Also, since there is no
"current owner" limitation like in DRM, processes running under the same UID
should be able to access /proc/<pid-of-display-server>/fd/* and gain access to
the devices. Nevertheless, weston implements a suid wrapper to access the
devices and then drop privileges, and this patch would make this daemon
pointless. So if the weston developers feel that this change reduces security,
I prefer to revert it.

[1] https://lists.freedesktop.org/archives/wayland-devel/2016-May/029017.html

6 years agotreewide: fix typos
Torstein Husebø [Thu, 12 May 2016 09:23:35 +0000 (11:23 +0200)]
treewide: fix typos

6 years agoask-password: ask for passphrases not only on the first console of /dev/console
Werner Fink [Wed, 18 Nov 2015 11:28:30 +0000 (12:28 +0100)]
ask-password: ask for passphrases not only on the first console of /dev/console

but also on all other consoles.  This does help on e.g. mainframes
where often a serial console together with other consoles are
used.  Even rack based servers attachted to both a serial console
as well as having a virtual console do sometimes miss a connected
monitor.

To be able to ask on all terminal devices of /dev/console the devices
are collected. If more than one device are found, then on each of the
terminals a inquiring task for passphrase is forked and do not return
to the caller.

Every task has its own session and its own controlling terminal.
If one of the tasks does handle a password, the remaining tasks
will be terminated.

Also let contradictory options on the command of
elogind-tty-ask-password-agent fail.

Spwan for each device of the system console /dev/console a own process.
Replace the system call wait() with with system call waitid().
Use SIGTERM instead of SIGHUP to get unresponsive childs down.

Port the collect_consoles() function forward to a pulbic and strv
based function "get_kernel_consoles()" in terminal-util.c and use this
in tty-ask-password-agent.c.

6 years agoPrep v229.5: Make musl-libc utmp/wtmp stubs visible.
Sven Eden [Mon, 12 Jun 2017 11:29:24 +0000 (13:29 +0200)]
Prep v229.5: Make musl-libc utmp/wtmp stubs visible.

6 years agoPrep v229.5: Move parse-printf-format.? back to src/basic it is needed there.
Sven Eden [Mon, 12 Jun 2017 10:19:09 +0000 (12:19 +0200)]
Prep v229.5: Move parse-printf-format.? back to src/basic it is needed there.

6 years agoPrep v230: Update loginctl help text
Sven Eden [Fri, 9 Jun 2017 08:49:26 +0000 (10:49 +0200)]
Prep v230: Update loginctl help text

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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

6 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

6 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.

6 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.

6 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.

6 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)

6 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.

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

6 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.

6 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.

6 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.

6 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>
6 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.

6 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

6 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.

6 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

6 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.

6 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.

6 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.

6 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>
6 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