chiark / gitweb /
2 years agocore: permit FDSTORE=1 messages with non-pollable fds
Lennart Poettering [Tue, 20 Jun 2017 21:30:30 +0000 (23:30 +0200)]
core: permit FDSTORE=1 messages with non-pollable fds

This also alters the documentation to recommend memfds rather than /run
for serializing state across reboots. That's because /run doesn't
actually have the same lifecycle as the fd store, as it is cleared out
on restarts.

Fixes: #5606

2 years agobasic/rm-rf: allow a symlink to / to be removed
Zbigniew Jędrzejewski-Szmek [Sat, 17 Jun 2017 16:41:08 +0000 (12:41 -0400)]
basic/rm-rf: allow a symlink to / to be removed

We open the target path with O_DIRECTORY|O_NOFOLLOW, and if that doesn't work,
we call unlink() on the path. In neither case we will follow the symlink, so
we can relax our check to also not follow symlinks.

Fixes #5864.

2 years agobasic/path-util: allow flags for path_equal_or_files_same
Zbigniew Jędrzejewski-Szmek [Sat, 17 Jun 2017 16:37:16 +0000 (12:37 -0400)]
basic/path-util: allow flags for path_equal_or_files_same

No functional change, just a new parameters and the tests that
AT_SYMLINK_NOFOLLOW works as expected.

2 years agoMake IDN support conditional
Waldemar Brodkorb [Thu, 15 Jun 2017 15:44:59 +0000 (17:44 +0200)]
Make IDN support conditional

[zj: rename HAVE_IDN to ENABLE_IDN]

2 years agoUse "dollar-single-quotes" to escape shell-sensitive strings
Zbigniew Jędrzejewski-Szmek [Sun, 11 Jun 2017 19:24:07 +0000 (15:24 -0400)]
Use "dollar-single-quotes" to escape shell-sensitive strings

Also called "ANSI-C Quoting" in info:(bash) ANSI-C Quoting.

The escaping rules are a POSIX proposal, and are described in There's a lot of back-and-forth on
the details of escaping of control characters, but we'll be only using a small
subset of the syntax that is common to all proposals and is widely supported.
Unfortunately dash and fish and maybe some other shells do not support it (see
the man page patch for a list).

This allows environment variables to be safely exported using show-environment
and imported into the shell. Shells which do not support this syntax will have
to do something like
    export $(systemctl show-environment|grep -v '=\$')
or whatever is appropriate in their case. I think csh and fish do not support
the A=B syntax anyway, so the change is moot for them.

Fixes #5536.

- also escape newlines (which currently disallowed in shell values, so this
  doesn't really matter), and tabs (as $'\t'), and ! (as $'!'). This way quoted
  output can be included directly in both interactive and noninteractive bash.

2 years agosd-bus: silence format warnings in kdbus code (#6072)
Zbigniew Jędrzejewski-Szmek [Sat, 3 Jun 2017 09:41:17 +0000 (05:41 -0400)]
sd-bus: silence format warnings in kdbus code (#6072)

The code is mostly correct, but gcc is trying to outsmart us, and emits a
warning for a "llu vs lu" mismatch, even though they are the same size (on alpha):

src/libelogind/sd-bus/bus-control.c: In function ‘kernel_get_list’:
src/libelogind/sd-bus/bus-control.c:267:42: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=]
                         if (asprintf(&n, ":1.%llu", name->id) < 0) {
src/libelogind/sd-bus/bus-control.c: In function ‘bus_get_name_creds_kdbus’:
src/libelogind/sd-bus/bus-control.c:714:47: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘__u64 {aka long unsigned int}’ [-Werror=format=]
                 if (asprintf(&c->unique_name, ":1.%llu", conn_info->id) < 0) {
This is hard to work around properly, because kdbus.h uses __u64 which is
defined-differently-despite-being-the-same-size then uint64_t. Thus the simple
solution of using %PRIu64 fails on amd64:

src/libelogind/sd-bus/bus-control.c:714:47: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘__u64 {aka long long unsigned int}’ [-Werror=format=]
                 if (asprintf(&c->unique_name, ":1.%"PRIu64, conn_info->id) < 0) {

Let's just avoid the whole issue for now by silencing the warning.
After the next release, we should just get rid of the kdbus code.

Fixes #5561.

2 years agologinctl: also use $XDG_SESSION_ID for session-status
Zbigniew Jędrzejewski-Szmek [Thu, 1 Jun 2017 02:42:14 +0000 (22:42 -0400)]
loginctl: also use $XDG_SESSION_ID for session-status

2 years agologinctl: use $XDG_SESSION_ID for "our" session
Zbigniew Jędrzejewski-Szmek [Thu, 1 Jun 2017 02:23:30 +0000 (22:23 -0400)]
loginctl: use $XDG_SESSION_ID for "our" session

Instead of always letting logind guess what the caller's session is, let's
give it the value from $XDG_SESSION_ID when it is present in the caller's

Nowadays terminal emulators are often running as services under elogind --user,
and not as part of an actual session, so all loginctl calls which depend on
logind guessing the session will fail. I don't see a reason not to honour

This applies to LockSession, UnlockSession, TerminateSession, ActivateSession,

Fixes #6032.

2 years agologind: nicer error message when we cannot guess the caller's session
Zbigniew Jędrzejewski-Szmek [Thu, 1 Jun 2017 02:10:15 +0000 (22:10 -0400)]
logind: nicer error message when we cannot guess the caller's session

Partial fix for #6032.

2 years agoman: update sd_get_seats(3)
Yu Watanabe [Wed, 31 May 2017 15:27:47 +0000 (00:27 +0900)]
man: update sd_get_seats(3)

2 years agosd-login: sd_get_machine_names(): do not return -EINVAL when output parameter is...
Yu Watanabe [Wed, 31 May 2017 15:12:32 +0000 (00:12 +0900)]
sd-login: sd_get_machine_names(): do not return -EINVAL when output parameter is NULL

Other functions in sd-login generally allow the output parameter to be NULL, in
which case only the number of items that would be stored in the array is returned.
Be nice and do the same here.

2 years agosd-login: treat missing /run/elogind/{seats,sessions,users} the same as empty
Yu Watanabe [Wed, 31 May 2017 14:48:47 +0000 (23:48 +0900)]
sd-login: treat missing /run/elogind/{seats,sessions,users} the same as empty

C.f. 0543105b0fb13e4243b71a78f62f81fb9dde5d51.
This makes if /run/elogind/{seats,sessions,users} are missing, then
sd_get_seats(), sd_get_sessions() and sd_get_uids() return 0, that is,
an empty list, instead of -ENOENT.

2 years agosd-login: translate -ENOMEDIUM to -ENODATA
Zbigniew Jędrzejewski-Szmek [Wed, 31 May 2017 00:21:45 +0000 (20:21 -0400)]
sd-login: translate -ENOMEDIUM to -ENODATA

The -ENOMEDIUM return value was introduced in v232-1001-g2977724b09,
('core: make hybrid cgroup unified mode keep compat /sys/fs/cgroup/elogind hierarchy'),
and would be returned by cg_pid_get_path_shifted(), but the documented and
expected return value is -ENODATA. Let's just catch ENXIO/ENOMEDIUM and translate
it to ENODATA in all cases.

Complements 171f8f591ff27ebb5ff475b7a9d1f13a846c9331, fixes #6012.

2 years agologn: tests - don't compare signed with unsigned
Tom Gundersen [Thu, 25 May 2017 14:11:04 +0000 (16:11 +0200)]
logn: tests - don't compare signed with unsigned

2 years agobasic/time-util: make parsing of dual_timestamp more strict
Zbigniew Jędrzejewski-Szmek [Fri, 19 May 2017 18:49:06 +0000 (14:49 -0400)]
basic/time-util: make parsing of dual_timestamp more strict

*scanf functions set errno on i/o error. For sscanf, this doesn't really apply,
so (based on the man page), it seems that errno is unlikely to be ever set to a
useful value. So just ignore errno. The error message includes the string that
was parsed, so it should be always pretty clear why parsing failed.

On the other hand, detect trailing characters and minus prefix that weren't
converted properly. This matches what our safe_ato* functions do. Add tests to
elucidate various edge cases.

2 years agotest-parse-util: verify that ato[ui] actually rejects trailing garbage
Zbigniew Jędrzejewski-Szmek [Fri, 19 May 2017 18:37:48 +0000 (14:37 -0400)]
test-parse-util: verify that ato[ui] actually rejects trailing garbage

2 years agoarchitecture: add Synopsys DesignWare ARC cores support (#5992)
Alexey Brodkin [Fri, 19 May 2017 14:55:24 +0000 (16:55 +0200)]
architecture: add Synopsys DesignWare ARC cores support (#5992)

DesignWare ARC Processors are a family of 32-bit CPUs from Synopsys
used extensively in SoCs of different vendors.

2 years agoFix includes (#5980)
Matija Skala [Fri, 19 May 2017 14:01:35 +0000 (16:01 +0200)]
Fix includes (#5980)

Needed on musl.

2 years agocore: open /proc/self/mountinfo early to allow mounts over /proc (#5985)
Timothée Ravier [Fri, 19 May 2017 12:38:40 +0000 (14:38 +0200)]
core: open /proc/self/mountinfo early to allow mounts over /proc (#5985)

Enable masking the /proc folder using the 'InaccessiblePaths' unit

This also slightly simplify mounts setup as the bind_remount_recursive
function will only open /proc/self/mountinfo once.

This is based on the suggestion at:

2 years agotimesync/timesyncd-manager: fix format-specifier issues
Matija Skala [Fri, 19 May 2017 12:36:12 +0000 (14:36 +0200)]
timesync/timesyncd-manager: fix format-specifier issues

timex::time::tv_usec and timex::freq can have different sizes
depending on the host architecture. On x32 in particular,
it is 8 bytes long while the long int type is only 4 bytes
long. Hence, using li as a format specifier will trigger
a format error. Thus, introduce a new format specifier
PRI_TIMEX which is defined as PRIi64 on x32 and li
everywhere else.

2 years agosd-login: fix querying machines when machined is not running
Zbigniew Jędrzejewski-Szmek [Fri, 19 May 2017 11:52:00 +0000 (07:52 -0400)]
sd-login: fix querying machines when machined is not running

We should not leak the internal error from missing directory and treat
that case the same as no machines.

2 years agosd-login,test-login: return -ENODATA from sd_pid_get_unit too
Zbigniew Jędrzejewski-Szmek [Fri, 19 May 2017 02:32:19 +0000 (22:32 -0400)]
sd-login,test-login: return -ENODATA from sd_pid_get_unit too

After all, we might be running on a non-elogind system.

2 years agosd-login: fix return value of sd_pid_get_user_unit
Zbigniew Jędrzejewski-Szmek [Fri, 19 May 2017 02:11:08 +0000 (22:11 -0400)]
sd-login: fix return value of sd_pid_get_user_unit

E.g. "/user.slice/user-1000.slice/session-15.scope" would cause -ENXIO to be

2 years agosd-login: fix return value of sd_pid_get_session
Zbigniew Jędrzejewski-Szmek [Fri, 19 May 2017 01:55:44 +0000 (21:55 -0400)]
sd-login: fix return value of sd_pid_get_session

We'd return -ENXIO, even thoug -ENODATA is documented.

2 years agosd-login: read list of uids of sessions from UIDS not ACTIVE_SESSIONS
Zbigniew Jędrzejewski-Szmek [Fri, 19 May 2017 00:58:23 +0000 (20:58 -0400)]
sd-login: read list of uids of sessions from UIDS not ACTIVE_SESSIONS

As described by Luke Shumaker:

  sd_seat_get_sessions looks at /run/elogind/seats/${seat_name}:SESSIONS to get
  the list of sessions (which I believe is correct), and at
  /run/elogind/seats/${seat_name}:ACTIVE_SESSIONS for the list of users (which
  I believe is incorrect); I believe that it should look at the UIDS field for
  the list of users. As far as I can tell, the ACTIVE_SESSIONS field is never
  even present in the seats file. I also believe that this has been broken
  since the function was first committed almost 6 years ago.

Fixes #5743.

2 years agosd-login: always return two arrays of same length from sd_seat_get_sessions
Zbigniew Jędrzejewski-Szmek [Fri, 19 May 2017 00:48:09 +0000 (20:48 -0400)]
sd-login: always return two arrays of same length from sd_seat_get_sessions

sd_seat_get_sessions returns two arrays, that in principle should always match:
the session names and corresponding uids. The second array could be shorter only
if parsing or uid conversion fails. But in that case there is no way to tell
*which* uid is wrong, so they are *all* useless. It's better to simplify things and
just return an error if parsing fails.

2 years agoman: extend documentation on sd_bus_add_match a bit()
Lennart Poettering [Thu, 18 May 2017 16:24:17 +0000 (18:24 +0200)]
man: extend documentation on sd_bus_add_match a bit()

Explain briefly how the concept of "sd_bus_slot" works.

This recently came up on the mailing list, hence let's document this for
the next time.

2 years agoenv-util: fix memory leak (#5962)
Ronny Chevalier [Sun, 14 May 2017 14:30:40 +0000 (16:30 +0200)]
env-util: fix memory leak (#5962)

If cunescape succeeds, but the assignment is not valid, uce is not freed.

2 years agotest-conf-parser: add valid and invalid utf8 test for config_parse_path
Ronny Chevalier [Sun, 14 May 2017 11:19:11 +0000 (13:19 +0200)]
test-conf-parser: add valid and invalid utf8 test for config_parse_path

2 years agoconf-parser: fix wrong argument given to log_syntax_invalid_utf8
Ronny Chevalier [Sun, 14 May 2017 11:19:11 +0000 (13:19 +0200)]
conf-parser: fix wrong argument given to log_syntax_invalid_utf8

The condition is on "word", hence we give word instead of rvalue.

An assert would be triggered if !utf8_is_valid(word) is true and
rvalue == NULL, since log_syntax_invalid_utf8 calls utf8_escape_invalid
which calls assert(str).

A test case has been added to test with valid and invalid utf8.

2 years agotree-wide: drop assert.h includes
Zbigniew Jędrzejewski-Szmek [Sat, 13 May 2017 15:44:51 +0000 (11:44 -0400)]
tree-wide: drop assert.h includes

We provide an independent reimplementation in macro.h, and that's the one
we want to use. Including the system header is unnecessary and confusing.

2 years agotree-wide: when %m is used in log_*, always specify errno explicitly
Zbigniew Jędrzejewski-Szmek [Sat, 13 May 2017 15:26:55 +0000 (11:26 -0400)]
tree-wide: when %m is used in log_*, always specify errno explicitly

All those uses were correct, but I think it's better to be explicit.
Using implicit errno is too error prone, and with this change we can require
(in the sense of a style guideline) that the code is always specified.

Helpful query: git grep -n -P 'log_[^s][a-z]+\(.*%m'

2 years agotest-login: make the test non-manual
Zbigniew Jędrzejewski-Szmek [Fri, 12 May 2017 18:25:17 +0000 (14:25 -0400)]
test-login: make the test non-manual

test-login.c is largely rewritten to use _cleanup_ and give more meaningful
messages (function names are used instead of creative terms like "active
session", so that when something unexpected is returned, it's much easier to
see what function is responsible).

The monitoring part is only activated if '-m' is passed on the command line.

It runs against the information from /run/elogind/ in the live system, but that
should be OK: logind/sd-login interface is supposed to be stable and both
backwards and forwards compatible.

If not running in a login session, some tests are skipped.

Those two changes together mean that it's possible to run test-login in the
test suite.

Tests for sd_pid_get_{unit,user_unit,slice} are added.

2 years agosd-bus: fix c++ compatibility (#5941)
Matthijs van Duin [Thu, 11 May 2017 22:55:26 +0000 (00:55 +0200)]
sd-bus: fix c++ compatibility (#5941)

g++ annoyingly requires a non-empty struct-initializer to initialize all
struct members, in order of declaration.

Signed-off-by: Matthijs van Duin <>
2 years agobasic/fileio: extend atomic file writing with timestamp setting
Zbigniew Jędrzejewski-Szmek [Thu, 11 May 2017 14:23:36 +0000 (10:23 -0400)]
basic/fileio: extend atomic file writing with timestamp setting

There should be no functional change.

2 years agoAdd short-iso-precise for journalctl output (#5884)
Ian Wienand [Mon, 8 May 2017 00:23:49 +0000 (10:23 +1000)]
Add short-iso-precise for journalctl output (#5884)

This adds a short-iso-precise option for journalctl output.  It is similar to
short-iso, but includes microseconds.

2 years agoMark python scripts executable
Zbigniew Jędrzejewski-Szmek [Sun, 7 May 2017 15:35:32 +0000 (11:35 -0400)]
Mark python scripts executable

Since all our python scripts have a proper python3 shebang, there is no benefit
to letting meson autodetect them. On linux, meson will just uses exec(), so the
shebang is used anyway. The only difference should be in how meson reports the
script and that the detection won't fail for (most likely misconfigured)
non-UTF8 locales.

Closes #5855.

2 years agoman: fix links to external man pages
Zbigniew Jędrzejewski-Szmek [Sun, 7 May 2017 15:29:40 +0000 (11:29 -0400)]
man: fix links to external man pages

linkchecker ftw!

2 years agoRevert "selinux: split up mac_selinux_have() from mac_selinux_use()"
Gary Tierney [Tue, 2 May 2017 16:42:19 +0000 (17:42 +0100)]
Revert "selinux: split up mac_selinux_have() from mac_selinux_use()"

This reverts commit 6355e75610a8d47fc3ba5ab8bd442172a2cfe574.

The previously mentioned commit inadvertently broke a lot of SELinux related
functionality for both unprivileged users and elogind instances running as
MANAGER_USER.  In particular, setting the correct SELinux context after a User=
directive is used would fail to work since we attempt to set the security
context after changing UID.  Additionally, it causes activated socket units to
be mislabeled for elogind --user processes since setsockcreatecon() would never
be called.

Reverting this fixes the issues with labeling outlined above, and reinstates
SELinux access checks on unprivileged user services.

2 years agocore: introduce cg_mask_from_string()/cg_mask_to_string()
Franck Bui [Tue, 2 May 2017 07:59:17 +0000 (09:59 +0200)]
core: introduce cg_mask_from_string()/cg_mask_to_string()

2 years agoconfig parser: Introduce config_parse_ip_port
Susant Sahani [Thu, 27 Apr 2017 05:11:46 +0000 (10:41 +0530)]
config parser: Introduce config_parse_ip_port

2 years agoimprove readability (#5814)
Matija Skala [Thu, 27 Apr 2017 00:08:52 +0000 (02:08 +0200)]
improve readability (#5814)

2 years agoparse-util: introduce parse_dev() helper
Franck Bui [Wed, 26 Apr 2017 16:18:03 +0000 (18:18 +0200)]
parse-util: introduce parse_dev() helper

2 years agologind: when setting a new controller, don't prepare the VT if logind is restarted
Franck Bui [Wed, 26 Apr 2017 12:20:41 +0000 (14:20 +0200)]
logind: when setting a new controller, don't prepare the VT if logind is restarted

When assigning a new session controller to a session, the VT is prepared so the
controller can expect the VT to be in a good default state.

However when logind is restarted and a session controller already took control
of a session, there's no need to prepare th VT otherwise logind may screw up
the VT state set by the controller.

This patch prevents the preparation of the VT in this case.

2 years agotmpfiles: use safe_glob()
Zbigniew Jędrzejewski-Szmek [Wed, 26 Apr 2017 03:50:35 +0000 (23:50 -0400)]
tmpfiles: use safe_glob()

This filters out "." and ".." from glob results. Fixes #5655 and #5644.

Any judgements on whether the path is "safe" are removed. We will not remove
"/" under any name (including "/../" and such), but we will remove stuff that
is specified using paths that include "//", "/./" and "/../". Such paths can be
created when joining strings automatically, or for other reasons, and people
generally know what ".." and "." is.

Tests are added to make sure that the helper functions behave as expected.

2 years agobasic: add readdir_no_dot and safe_glob functions
Zbigniew Jędrzejewski-Szmek [Wed, 26 Apr 2017 03:44:34 +0000 (23:44 -0400)]
basic: add readdir_no_dot and safe_glob functions

safe_glob filters out "." and "..".

This converts all users of glob_extend() and glob_exists() to safe_glob.

2 years agotest-sizeof: print the size of an enum
Zbigniew Jędrzejewski-Szmek [Wed, 26 Apr 2017 01:14:59 +0000 (21:14 -0400)]
test-sizeof: print the size of an enum

2 years agobus: report builtins in GetManagedObjects() (#5799)
David Herrmann [Wed, 26 Apr 2017 00:36:30 +0000 (02:36 +0200)]
bus: report builtins in GetManagedObjects() (#5799)

We already report builtin interfaces with InterfacesAdded and InterfacesRemoved. However,
we never reported them in GetManagedObjects(). This might end up confusing callers that
want to use those interfaces (or simply rely on the interface count to be coherent).

Report the builtins for all objects that are queried.

2 years agoconfig parser: Introduce config_parse_uint8
Susant Sahani [Tue, 25 Apr 2017 13:11:50 +0000 (18:41 +0530)]
config parser: Introduce config_parse_uint8

2 years agofix parenthesis in pager.c (#5798)
Matija Skala [Tue, 25 Apr 2017 12:44:29 +0000 (14:44 +0200)]
fix parenthesis in pager.c (#5798)

- result of dup2 should be compared against 0
- making parenthesis around comparisons just to be sure

2 years agoExport sd_bus_message_append_ap. It is renamed to sd_bus_message_appendv to follow...
Federico [Tue, 25 Apr 2017 07:32:24 +0000 (09:32 +0200)]
Export sd_bus_message_append_ap. It is renamed to sd_bus_message_appendv to follow elogind naming conventions. (#5753)

Moreover, man page for sd_bus_message_append is updated with reference to new exposed function.
Makefile-man is updated too, to reflect new alias.

2 years agoAdd Geneve netlink properties to missing.h
Susant Sahani [Tue, 25 Apr 2017 04:13:41 +0000 (09:43 +0530)]
Add Geneve netlink properties to missing.h

2 years agoredirect stdout/stderr back when closing the pager (#5661)
Matija Skala [Mon, 24 Apr 2017 16:30:50 +0000 (18:30 +0200)]
redirect stdout/stderr back when closing the pager (#5661)

2 years agoshared/extract-word: replace enum with unsigned int to avoid undefined behaviour
Zbigniew Jędrzejewski-Szmek [Sat, 22 Apr 2017 23:04:02 +0000 (19:04 -0400)]
shared/extract-word: replace enum with unsigned int to avoid undefined behaviour

../src/basic/extract-word.c:255:22: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs]
        va_start(ap, flags);
../src/basic/extract-word.c:244:77: note: parameter of type 'ExtractFlags' (aka 'enum ExtractFlags') is declared here
int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) {
../src/basic/extract-word.c:286:22: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Wvarargs]
        va_start(ap, flags);
../src/basic/extract-word.c:244:77: note: parameter of type 'ExtractFlags' (aka 'enum ExtractFlags') is declared here
int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) {
2 warnings generated.

I think the relevant part of C99 is Enumeration specifiers:

Each enumerated type shall be compatible with char, a signed integer type, or
an unsigned integer type. The choice of type is implementation-defined, but
shall be capable of representing the values of all the members of the


The parameter parmN is the identifier of the rightmost parameter in the
variable parameter list in the function definition (the one just before the
...). If the parameter parmN is declared with the register storage class, with
a function or array type, or with a type that is not compatible with the type
that results after application of the default argument promotions, the behavior
is undefined.

This might cause a real issue if the compiler chooses something that is not an
integer for ExtractFlags. Rework the code to avoid the warning, but add an
assert_cc in a large-valued ExtractFlags element is ever defined and the type
is bumped to something wider than an int.

2 years agobasic/log: expose log_dispatch
Zbigniew Jędrzejewski-Szmek [Fri, 21 Apr 2017 16:52:54 +0000 (12:52 -0400)]
basic/log: expose log_dispatch

This is useful when we want to avoid printf formatting on the message.
It's nicer than using log_struct with "%s" as the format, because printf
is slow and with a large message (like from a backtrace) this would require
extra unnecessary memory.

I'm not exposing all the fields in the wrapper: only level and errno.
Those are the most likely to be useful.

2 years agotree-wide: mark log_struct with _printf_ and fix fallout
Zbigniew Jędrzejewski-Szmek [Thu, 20 Apr 2017 18:15:28 +0000 (14:15 -0400)]
tree-wide: mark log_struct with _printf_ and fix fallout

log_struct takes multiple format strings, each one followed by arguments.
The _printf_ annotation is not sufficiently flexible to express this,
but we can still annotate the first format string, though not its
arguments (because their number is unknown).

With the annotation, the places which specified the message id or similar
as the first pattern cause a warning from -Wformat-nonliteral. This can
be trivially fixed by putting the MESSAGE= first.

This change will help find issues where a non-literal is erroneously used
as the pattern.

2 years agobasic/log: fix _printf_ annotation on log_object_internalv
Zbigniew Jędrzejewski-Szmek [Thu, 20 Apr 2017 18:09:47 +0000 (14:09 -0400)]
basic/log: fix _printf_ annotation on log_object_internalv

Fixup for 4b58153dd22172d817055d2a09a0cdf3f4bd9db3.

I saw this because of a clang warning. With gcc the -Wformat-nonliteral warning
doesn't seem to work as expected.

In two places, a string constructed with strjoina is used as the pattern. This
is safe, because we're taking a pattern which was already marked with _printf_
and prepending a known value to it.  Those places are marked with #pragma to
silence the warning.

2 years agotest-exec-util: drop duplicate const
Zbigniew Jędrzejewski-Szmek [Wed, 19 Apr 2017 20:32:52 +0000 (16:32 -0400)]
test-exec-util: drop duplicate const

gcc-7 warns about this with -Wduplicate-decl-specifier.

2 years agobasic/random-util: add new header for getrandom()
Zbigniew Jędrzejewski-Szmek [Wed, 19 Apr 2017 20:13:27 +0000 (16:13 -0400)]
basic/random-util: add new header for getrandom()

There's some confusion: older man pages specify that linux/random.h
contains getrandom, but newer glibc has it in sys/random.h. Detect if
the newer header is available and include it. We still need the older
header for the flags.

2 years agotree-wide: fix wrong indent (#5757)
Yu Watanabe [Wed, 19 Apr 2017 06:48:29 +0000 (15:48 +0900)]
tree-wide: fix wrong indent (#5757)

Fixes wrong indent introduced by the commit 43688c49d1fdb585196d94e2e30bb29755fa591b.

2 years agobasic/missing.h: drop inclusion of macro.h
Zbigniew Jędrzejewski-Szmek [Tue, 18 Apr 2017 23:04:15 +0000 (19:04 -0400)]
basic/missing.h: drop inclusion of macro.h

It's not necessary for anything.

2 years agologinctl: fix typo causing ignoring multiple session IDs (#5732)
slodki [Thu, 13 Apr 2017 10:34:59 +0000 (12:34 +0200)]
loginctl: fix typo causing ignoring multiple session IDs (#5732)

Fixes #5733

2 years agobasic/def.h: drop TTY_GID definition
Zbigniew Jędrzejewski-Szmek [Thu, 6 Apr 2017 04:12:40 +0000 (00:12 -0400)]
basic/def.h: drop TTY_GID definition

We already provide a definition through the configuration system, this
one is duplicate.

2 years agologind: Stopped inhibitions should be considered inactive (#5698)
afrantzis [Wed, 5 Apr 2017 08:32:55 +0000 (11:32 +0300)]
logind: Stopped inhibitions should be considered inactive (#5698)

2 years agotest-sizeof: add some struct-timespec related fields
Zbigniew Jędrzejewski-Szmek [Thu, 30 Mar 2017 01:31:58 +0000 (21:31 -0400)]
test-sizeof: add some struct-timespec related fields

Might help with #5264.

2 years agotest-sizeof: do not link with libelogind-shared
Zbigniew Jędrzejewski-Szmek [Thu, 30 Mar 2017 01:31:21 +0000 (21:31 -0400)]
test-sizeof: do not link with libelogind-shared

This makes it much quicker to compile.

2 years agobasic: forbid rm_rf() to remove paths ending with ".." (#5653)
Jan Synacek [Wed, 29 Mar 2017 06:25:52 +0000 (08:25 +0200)]
basic: forbid rm_rf() to remove paths ending with ".." (#5653)

Fixes: #5644

2 years agologind: save/restore session devices and their respective file descriptors
Franck Bui [Thu, 16 Mar 2017 10:17:09 +0000 (11:17 +0100)]
logind: save/restore session devices and their respective file descriptors

This patch ensures that session devices are saved for each session.

In order to make the revokation logic work when logind is restarted, the
session devices are now saved in the session state files and their respective
file descriptors sent to PID1's fdstore in order to keep them open accross

This is mandatory in order to keep the revokation logic working. Indeed in case
of input-devices, the same file descriptors must be shared by logind and a
given session controller in order EVIOCREVOKE to work otherwise multiple
sessions can have device access in parallel.

This should be the only remaining and missing piece for making logind fully

Fixes: #1163

2 years agocheck for _POSIX_C_SOURCE instead of __USE_POSIX*
Matija Skala [Wed, 15 Mar 2017 13:16:40 +0000 (14:16 +0100)]
check for _POSIX_C_SOURCE instead of __USE_POSIX*

check for _GNU_SOURCE as well as sd_event_child_handler_t needs to be
defined correctly while compiling elogind

2 years agoassigning stdout and stderr is not allowed
Matija Skala [Wed, 15 Mar 2017 12:49:05 +0000 (13:49 +0100)]
assigning stdout and stderr is not allowed

2 years agofix includes
Matija Skala [Wed, 15 Mar 2017 12:21:10 +0000 (13:21 +0100)]
fix includes

linux/sockios.h is needed for the SIOCGSTAMPNS macro

xlocale.h is included indirectly in glibc and doesn't even exist in
other libcs

2 years agoheaders: check that __INCLUDE_LEVEL__ is defined before using it (#5575)
Zbigniew Jędrzejewski-Szmek [Mon, 13 Mar 2017 07:11:24 +0000 (03:11 -0400)]
headers: check that __INCLUDE_LEVEL__ is defined before using it (#5575)

That macro is a gcc extension, and while widely supported, not ubiquitous.
In particular the coverity scanner is having trouble with it.

2 years agoFix typo in function name (#5565)
Michal Sekletar [Fri, 10 Mar 2017 14:16:24 +0000 (15:16 +0100)]
Fix typo in function name (#5565)

2 years agomissing.h: add vxlan netlink properties
Susant Sahani [Wed, 8 Mar 2017 13:09:43 +0000 (18:39 +0530)]
missing.h: add vxlan netlink properties

2 years agosd-bus: drop kdbus-related docs (#5533)
AsciiWolf [Tue, 7 Mar 2017 06:51:35 +0000 (07:51 +0100)]
sd-bus: drop kdbus-related docs (#5533)

2 years agotest: skip instead of fail if crypto kmods are not available
Martin Pitt [Thu, 2 Mar 2017 22:42:01 +0000 (23:42 +0100)]
test: skip instead of fail if crypto kmods are not available

Package build machines may have module loading disabled, thus AF_ALG
sockets are not available. Skip the tests that cover those (khash and
id128) instead of failing them in this case.

Fixes #5524

2 years agoRip out setting of the log level from udev_new and put it in a new function
Zbigniew Jędrzejewski-Szmek [Thu, 23 Feb 2017 08:16:44 +0000 (03:16 -0500)]
Rip out setting of the log level from udev_new and put it in a new function

This function is internal to elogind code, so external users of libudev
will not see those log messages. I think this is better. If we want to
allow that, the function could be put in libudev and exported.

v2: check that the string is more than one char before stripping quotes

2 years agobasic/log: split max log level into multiple "realms"
Zbigniew Jędrzejewski-Szmek [Thu, 23 Feb 2017 03:57:34 +0000 (22:57 -0500)]
basic/log: split max log level into multiple "realms"

The single log level is split into an array of log levels. Which index in the
array is used can be determined for each compilation unit separately by setting
a macro before including log.h. All compilation units use the same index
(LOG_REALM_SYSTEMD), so there should be no functional change.

- the "realm" is squished into the level (upper bits that are not used by
  priority or facility), and unsquished later in functions in log.c.


2 years agoVersion 233.3 Release v233.3
Sven Eden [Fri, 21 Jul 2017 05:48:48 +0000 (07:48 +0200)]
Version 233.3 Release

2 years agoPrep v233.3: Add HAVE_UTMP information to basic/build.h
Sven Eden [Fri, 21 Jul 2017 05:46:20 +0000 (07:46 +0200)]
Prep v233.3: Add HAVE_UTMP information to basic/build.h

2 years agoPrep v233.3: Remove stray character.
Sven Eden [Fri, 21 Jul 2017 05:41:40 +0000 (07:41 +0200)]
Prep v233.3: Remove stray character.

2 years agoPrep v233.3: Add 'loginctl list' as a shorthand for list-sessions
Sven Eden [Thu, 20 Jul 2017 16:25:48 +0000 (18:25 +0200)]
Prep v233.3: Add 'loginctl list' as a shorthand for list-sessions

2 years agoPrep v233.3: Moved four functions, that did not need adaptation in elogind-dbus.c...
Sven Eden [Thu, 20 Jul 2017 16:16:13 +0000 (18:16 +0200)]
Prep v233.3: Moved four functions, that did not need adaptation in elogind-dbus.c, back to logind-dbus.c.

2 years agoPrep v233.3: Moved shutdown_or_sleep() and run_helper() to elogind-dbus.c, so elogind...
Sven Eden [Thu, 20 Jul 2017 15:16:50 +0000 (17:16 +0200)]
Prep v233.3: Moved shutdown_or_sleep() and run_helper() to elogind-dbus.c, so elogind-action.c is not needed any more.

2 years agoPrep v233.3: Apply upstream updates to systemctl commands we mimic.
Sven Eden [Thu, 20 Jul 2017 15:03:33 +0000 (17:03 +0200)]
Prep v233.3: Apply upstream updates to systemctl commands we mimic.

2 years agoPrep v233.3: Add a traget 'cccc' to
Sven Eden [Thu, 20 Jul 2017 06:24:36 +0000 (08:24 +0200)]
Prep v233.3: Add a traget 'cccc' to

2 years agoPrep v233.3: Add missing documentation for API functions exported by elogind. (unrevi...
Sven Eden [Wed, 19 Jul 2017 11:46:39 +0000 (13:46 +0200)]
Prep v233.3: Add missing documentation for API functions exported by elogind. (unreviewed)

2 years agoPrep v233.3: Add all possible coverage tests for elogind
Sven Eden [Wed, 19 Jul 2017 09:55:18 +0000 (11:55 +0200)]
Prep v233.3: Add all possible coverage tests for elogind

2 years agoPrep v233.3: Unmask various functions for future coverage tests.
Sven Eden [Tue, 18 Jul 2017 22:56:25 +0000 (00:56 +0200)]
Prep v233.3: Unmask various functions for future coverage tests.

These functions, although not used by elogind itself, are mostly tiny
and crucial for important tests to work.

2 years agoPrep v233.3: Update po files to not include files that do not exist in elogind.
Sven Eden [Tue, 18 Jul 2017 18:30:57 +0000 (20:30 +0200)]
Prep v233.3: Update po files to not include files that do not exist in elogind.

2 years agoPrep v233.3: Remove obsolete test-hash.c
Sven Eden [Tue, 18 Jul 2017 13:42:39 +0000 (15:42 +0200)]
Prep v233.3: Remove obsolete test-hash.c

2 years agoVersion 233.2 Release
Sven Eden [Tue, 18 Jul 2017 07:37:20 +0000 (09:37 +0200)]
Version 233.2 Release

2 years agoPrep v233.2: Mask unneeded functions and definitions in src/shared
Sven Eden [Mon, 17 Jul 2017 16:21:47 +0000 (18:21 +0200)]
Prep v233.2: Mask unneeded functions and definitions in src/shared

2 years agoPrep v233.2: Mask unneeded functions and definitions in src/basic
Sven Eden [Tue, 18 Jul 2017 06:04:37 +0000 (08:04 +0200)]
Prep v233.2: Mask unneeded functions and definitions in src/basic

2 years agoVersion 233.1 Release
Sven Eden [Mon, 17 Jul 2017 16:15:05 +0000 (18:15 +0200)]
Version 233.1 Release

2 years agoPrep v233: Add missing updates from upstream in src/systemd
Sven Eden [Mon, 17 Jul 2017 15:38:58 +0000 (17:38 +0200)]
Prep v233: Add missing updates from upstream in src/systemd

2 years agoPrep v233: Add missing updates from upstream in src/sleep
Sven Eden [Mon, 17 Jul 2017 15:38:46 +0000 (17:38 +0200)]
Prep v233: Add missing updates from upstream in src/sleep

2 years agoPrep v233: Add missing updates from upstream in src/login
Sven Eden [Mon, 17 Jul 2017 15:37:38 +0000 (17:37 +0200)]
Prep v233: Add missing updates from upstream in src/login

2 years agoPrep v233: Add missing updates from upstream in src/libelogind
Sven Eden [Mon, 17 Jul 2017 16:09:52 +0000 (18:09 +0200)]
Prep v233: Add missing updates from upstream in src/libelogind

2 years agoPrep v233: Add missing updates from upstream in src/core
Sven Eden [Mon, 17 Jul 2017 16:09:39 +0000 (18:09 +0200)]
Prep v233: Add missing updates from upstream in src/core