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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

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

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

2 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

2 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"

2 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}.

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

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

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

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

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

2 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

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

2 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()

2 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

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

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

2 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

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

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

2 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

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

2 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

2 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

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

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

2 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

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

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

2 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
```

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

2 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

2 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

2 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

2 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

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

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

2 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>
2 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!

2 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

2 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

2 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).

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

2 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`.

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

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

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

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

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

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

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

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

2 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()

2 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

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

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

2 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

2 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

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

2 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

2 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

2 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

2 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

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

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

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

2 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

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

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

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

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

2 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

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