chiark / gitweb /
elogind.git
5 years agologin: do not wall message on cancelling shutdown when Manager.enable_wall_messages...
Yu Watanabe [Mon, 7 May 2018 01:16:04 +0000 (10:16 +0900)]
login: do not wall message on cancelling shutdown when Manager.enable_wall_messages is false

Fixes #8904.

(cherry picked from commit 6e78fa4afd474dae984f3ee4a8477c623296a519)

5 years agovirt: if we detect Xen by DMI, trust that over CPUID
Lennart Poettering [Mon, 30 Apr 2018 10:23:03 +0000 (12:23 +0200)]
virt: if we detect Xen by DMI, trust that over CPUID

Apparently Xen sometimes lies about its identity when queried via CPUID.
Let's hence prefer DMI tests for CPUID

Fixes: #8844
(cherry picked from commit f2fe2865cd19cd4318b82d01b9b62d22b1697b3a)

5 years agomeson: drop 'name' argument in cc.has_argument() (#8878)
Yu Watanabe [Wed, 2 May 2018 08:05:51 +0000 (17:05 +0900)]
meson: drop 'name' argument in cc.has_argument() (#8878)

(cherry picked from commit b0903bb585d2158f78a4cf603fde4aed5474e2b9)

5 years agoadd __nr_statx defines for extra architectures (#8872)
Adam Duskett [Wed, 2 May 2018 08:04:50 +0000 (04:04 -0400)]
add __nr_statx defines for extra architectures (#8872)

This includes:
 - arm
 - arm64
 - alpha
 - powerpc64
 - sparc

Taken from kernel 4.16.6

(cherry picked from commit 773c84349d80c7a6f818f5909a160ddb7337987f)

5 years agobasic/log: always ignore errno from the enviornment (#8841)
Zbigniew Jędrzejewski-Szmek [Fri, 27 Apr 2018 16:00:58 +0000 (18:00 +0200)]
basic/log: always ignore errno from the enviornment (#8841)

This extends the change done in b29f6480ec to other logging functions.

This actually fixes some bugs in callers of log_struct(), for example
config_parse_alias() called 'return log_syntax(..., 0, ...)' which could result
in a bogus non-zero return value.

Calls to log_object() and log_format_iovec() — which is only used by
server_driver_message() — appear correct.

(cherry picked from commit d1a1f0aaf0d2f08c60d1e0d32e646439d99f58dc)

5 years agocgroup-util: fix enabling of controllers (#8816)
Antique [Thu, 26 Apr 2018 10:37:35 +0000 (12:37 +0200)]
cgroup-util: fix enabling of controllers (#8816)

If enabling controller for some reason fails we need to clear error
for the FILE stream.  Enabling remaining controllers would otherwise
fail because write_string_stream_ts() checks for ferror(f) and returns
-EIO if there is one.

Broken by commit <77fa610b22>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 96aa6591d1103b8cca9a4db80ba478a18bdf3e9a)

5 years agomeson: drop 'name' argument in cc.has_argument() (#8823)
Yu Watanabe [Thu, 26 Apr 2018 08:53:10 +0000 (17:53 +0900)]
meson: drop 'name' argument in cc.has_argument() (#8823)

This fixes the following warning with clang and meson-0.46.0,
```
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
Compiler for C supports arguments -Wno-typedef-redefinition: YES
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
WARNING: Passed invalid keyword argument "name".
WARNING: This will become a hard error in the future.
Compiler for C supports arguments -Wno-gnu-variable-sized-type-not-at-end: YES
```

(cherry picked from commit 8ac42236b09d2f21f962bf72fcbeee24502f959f)

5 years agoman: fix description of --value option for loginctl (#8820)
Yu Watanabe [Thu, 26 Apr 2018 07:51:11 +0000 (16:51 +0900)]
man: fix description of --value option for loginctl (#8820)

(cherry picked from commit ad628501b95b83ac6c0b42bb69db7e1b38c0ff13)

5 years agofileio.c: fix incorrect mtime
Chris Lesiak [Tue, 24 Apr 2018 14:50:42 +0000 (09:50 -0500)]
fileio.c: fix incorrect mtime

A regression was introduced that caused the mtime of /etc/.updated
and /var/.updated to be the current time when systemd-update-done
ran instead of being copied from /usr.

This was nearly fixed, but due to fflush being called after mtime
was carefully set, it was overwritten with the current time.

Regression introduced in 872c40396384f9fa89b01baf4e739d28ed590299

A fix was just missed in 39c38d773fbe2b4f76ff29ecd3344640efb9a86c

Fixes #8806

(cherry picked from commit be83711c7eb6a09e0d0c529c427cebcae87c0c1f)

5 years agobasic/log: do not use global errno in log_*_errno()
Zbigniew Jędrzejewski-Szmek [Tue, 24 Apr 2018 11:57:38 +0000 (13:57 +0200)]
basic/log: do not use global errno in log_*_errno()

Quoting https://github.com/systemd/systemd/pull/8760#discussion_r183321060:

> When we originally added the errno patching we went for a "best of both
> worlds" approach, i.e. that we override errno if an error is specified, but
> if no error is specified (i.e. 0 is passed as error code) then we use the
> previously set errno, similar in style how plain `printf()` would do it. In
> retrospect I think we almost never purposefully made use of the second,
> i.e. the plain `printf()` logic, but we multiple times ran into this case
> accidentally and introduced a bug. Hence yes, it probably makes sense to
> switch this over, and consistently ignore the `errno` already set and always
> override it with the error passed in. The only problem I see with that is: I
> wonder if there might be a case or two lurking somewhere where we actually
> made use of the "best of both worlds" approach, and if so, if we can detect
> where... (But then again, even if there is, and we fail to find those cases,
> maybe that's not all bad, as it's just a few new bugs against probably fixing
> many more old and future bugs, if you follow what I mean).

I scanned our codebase, and found some bugs in the value passed to log_*_errno,
but no intentional cases of error=0 being passed.

(cherry picked from commit b29f6480eca0550ba65d30fbece8dd4d4bfe666d)

5 years agobasic/audit-util: always log the reason when disabling audit logs
Zbigniew Jędrzejewski-Szmek [Tue, 24 Apr 2018 11:46:58 +0000 (13:46 +0200)]
basic/audit-util: always log the reason when disabling audit logs

This state is cached, and it's seems OK to log at least once.

(cherry picked from commit 13bb68bbe37f0b39cd45234b09fb1a1da8302020)

5 years agoISO-C compatibility: Remove empty initializer (#8713)
Leonard [Thu, 12 Apr 2018 19:31:19 +0000 (21:31 +0200)]
ISO-C compatibility: Remove empty initializer (#8713)

ISO-C doesn't allow empty initializers, so replace it by explicitly
initializing to zero.

Also add braces because x is a union and we initialize a subobject, so
a compiler might warn about suggesting braces.  Shut that up.

(cherry picked from commit d579a56c397a1aeaa490032a9f7aabd82124f1c8)

5 years agotmpfiles: add a new return code for "operational failure" when processing
Zbigniew Jędrzejewski-Szmek [Thu, 29 Mar 2018 14:19:33 +0000 (16:19 +0200)]
tmpfiles: add a new return code for "operational failure" when processing

Things can fail, and we have no control over it:
- file system issues (immutable bits, file system errors, MAC refusals, etc)
- kernel refusing certain arguments when writing to /proc/sys or /sys
Let's add a new code for the case where we parsed configuration but failed
to execute it because of external errors.

(cherry picked from commit bb9947be2fa308d198b63b30e494ade5d68e5109)

5 years agocore: skip the removal of cgroups in the TEST_RUN_MINIMAL mode (#8622)
Evgeny Vereshchagin [Tue, 3 Apr 2018 13:04:22 +0000 (16:04 +0300)]
core: skip the removal of cgroups in the TEST_RUN_MINIMAL mode (#8622)

When `systemd` is run in the TEST_RUN_MINIMAL mode, it doesn't really
set up cgroups, so it shouldn't try to remove anything.

Closes https://github.com/systemd/systemd/issues/8474.

(cherry picked from commit f6c63f6fc90040f0017a7cc37f3a05d5b86226d7)

5 years agosystemd-inhibit: ignore signal interrupt from keyboard (#8569)
Christian Hesse [Wed, 28 Mar 2018 19:58:10 +0000 (21:58 +0200)]
systemd-inhibit: ignore signal interrupt from keyboard (#8569)

By default both processes, systemd-inhibit and the forked one, receive
the signals. Pressing Ctrl+C on the keyboard results in SIGINT being
sent to the processes, followed by SIGTERM being sent to the forked
process when systemd-inhibit exits. This can cause trouble when the
forked process does not clean up properly but exit immediately.

Instead make systemd-inhibit ignore SIGINT, leaving it to the forked
process to clean up and exit.

(cherry picked from commit 106f12a08fcacef713438fc055872592399deeed)

5 years agostat-util: fix fd_is_network_ns()
Lennart Poettering [Fri, 23 Mar 2018 08:47:04 +0000 (09:47 +0100)]
stat-util: fix fd_is_network_ns()

This was broken in 77f9fa3b8ea46c27e5a5e9270f71bf1b4000c3e0. My fault.

Fixes: #8543
(cherry picked from commit 29f74559d4dc6ea41232233d32f1a92bcee43626)

5 years agosd-bus: drop fd_nonblock() calls that are implied by rearrange_stdio() (#8514)
Lennart Poettering [Wed, 21 Mar 2018 10:46:49 +0000 (11:46 +0100)]
sd-bus: drop fd_nonblock() calls that are implied by rearrange_stdio() (#8514)

(cherry picked from commit 68b525d1d1e8153cbc2e2354fa650aa165f7a434)

5 years agomeson: add note about coreutils version with ln --relative
Zbigniew Jędrzejewski-Szmek [Fri, 9 Mar 2018 07:56:23 +0000 (08:56 +0100)]
meson: add note about coreutils version with ln --relative

https://bugs.freedesktop.org/show_bug.cgi?id=90799
(cherry picked from commit cd001016a166bb849c454e7b5cdb58053f34935b)

5 years agobasic/macros: rename noreturn into _noreturn_ (#8456)
Franck Bui [Thu, 15 Mar 2018 05:23:46 +0000 (06:23 +0100)]
basic/macros: rename noreturn into _noreturn_ (#8456)

"noreturn" is reserved and can be used in other header files we include:

  [   16s] In file included from /usr/include/gcrypt.h:30:0,
  [   16s]                  from ../src/journal/journal-file.h:26,
  [   16s]                  from ../src/journal/journal-vacuum.c:31:
  [   16s] /usr/include/gpg-error.h:1544:46: error: expected ‘,’ or ‘;’ before ‘)’ token
  [   16s]  void gpgrt_log_bug (const char *fmt, ...)    GPGRT_ATTR_NR_PRINTF(1,2);

Here we include grcrypt.h (which in turns include gpg-error.h) *after* we
"noreturn" was defined in macro.h.

(cherry picked from commit 848e863acc51ecfb0f3955c498874588201d9130)

5 years agotests: make / private after creating a mount namespace
Evegeny Vereshchagin [Fri, 9 Mar 2018 01:10:42 +0000 (01:10 +0000)]
tests: make / private after creating a mount namespace

so that the test never affects the root namespace.

(cherry picked from commit c58fd466a313a1f93df1792822e358c67990bcdf)

5 years agocore: ignore errors from cg_create_and_attach() in test mode (#8401)
Michal Sekletar [Fri, 9 Mar 2018 22:30:32 +0000 (23:30 +0100)]
core: ignore errors from cg_create_and_attach() in test mode (#8401)

Reproducer:

$ meson build && cd build
$ ninja
$ sudo useradd test
$ sudo su test
$ ./systemd --system --test
...
Failed to create /user.slice/user-1000.slice/session-6.scope/init.scope control group: Permission denied
Failed to allocate manager object: Permission denied

Above error message is caused by the fact that user test didn't have its
own session and we tried to set up init.scope already running as user
test in the directory owned by different user.

Let's try to setup cgroup hierarchy, but if that fails return error only
when not running in the test mode.

Fixes #8072

(cherry picked from commit aa77e234fce7413b7dd64f99ea51450f2e2e9dbd)

5 years agomeson: avoid warning about comparison of bool and string
Zbigniew Jędrzejewski-Szmek [Fri, 9 Mar 2018 13:21:08 +0000 (14:21 +0100)]
meson: avoid warning about comparison of bool and string

meson.build:2907: WARNING: Trying to compare values of different types (bool, str) using ==.
The result of this is undefined and will become a hard error in a future Meson release.

(cherry picked from commit af4d7860c4e757f34a02ca73a0b14c73c18f8b30)

5 years agobasic/cgroup-util: remove unused variable
Zbigniew Jędrzejewski-Szmek [Tue, 6 Mar 2018 08:37:11 +0000 (09:37 +0100)]
basic/cgroup-util: remove unused variable

(cherry picked from commit eef03d70c1bedb3aabd4e2bcf10ab1f2678443bf)

5 years agocore: do not free heap-allocated strings (#8391)
Yu Watanabe [Thu, 8 Mar 2018 13:21:54 +0000 (22:21 +0900)]
core: do not free heap-allocated strings (#8391)

Fixes #8387.

(cherry picked from commit 5cbaad2f6795088db56063d20695c6444595822f)

5 years agosd-bus: do not try to close already closed fd (#8392)
Yu Watanabe [Thu, 8 Mar 2018 13:19:35 +0000 (22:19 +0900)]
sd-bus: do not try to close already closed fd (#8392)

Fixes #8376, which is introduced by 2b33ab0957f453a06b58e4bee482f2c2d4e100c1.

(cherry picked from commit 280029d18f470a64403d68717eef1be5274ff8af)

5 years agoNEWS: fix typos in v238 section (#8369)
Tomasz Torcz [Tue, 6 Mar 2018 08:35:47 +0000 (09:35 +0100)]
NEWS: fix typos in v238 section (#8369)

(cherry picked from commit 07a35e846b7986d3c02eca99fa291f6869035c58)

5 years agoAdd locale.h header, needed by freelocale()
Danilo Spinella [Mon, 11 Jun 2018 21:10:36 +0000 (23:10 +0200)]
Add locale.h header, needed by freelocale()

Without locale.h, there is an implicit declaration of function `freelocale`,
which is reported as error by -Werror=implicit-function-declaration.

5 years agoPrep v238: Make a real distinction between 'halt' and 'poweroff'.
Sven Eden [Tue, 12 Jun 2018 06:03:27 +0000 (08:03 +0200)]
Prep v238: Make a real distinction between 'halt' and 'poweroff'.

5 years agoPrep v238: Fix cg_path_decode_unit() to understand elogind session naming.
Sven Eden [Mon, 11 Jun 2018 15:49:21 +0000 (17:49 +0200)]
Prep v238: Fix cg_path_decode_unit() to understand elogind session naming.

(cherry picked from commit d8949c3072a4b984d6fa964178a2d8d945ecbcb6)

5 years agoPrep v238: Fix elogind_daemonize(), it failed due to some misunderstandings on my...
Sven Eden [Fri, 8 Jun 2018 14:45:25 +0000 (16:45 +0200)]
Prep v238: Fix elogind_daemonize(), it failed due to some misunderstandings on my side.

(cherry picked from commit 1c9629692145891f10a36227749470d87979dd0b)

5 years agologind-user.c: As we need special.h elsewhere now, use it here, too.
Sven Eden [Fri, 8 Jun 2018 06:35:24 +0000 (08:35 +0200)]
logind-user.c: As we need special.h elsewhere now, use it here, too.

(cherry picked from commit a96cb75c17b008312fca8f81bc2a126f8a87850c)

5 years agopam_elogind.c: Remove renames by mask, check_tree.pl can handle this now.
Sven Eden [Fri, 8 Jun 2018 06:30:56 +0000 (08:30 +0200)]
pam_elogind.c: Remove renames by mask, check_tree.pl can handle this now.

(cherry picked from commit 6964ec46218d41d699690ed590026249969b2257)

5 years agomeson.build: remove unnecessary `ln --relative` check
Kylie McClain [Thu, 7 Jun 2018 04:23:07 +0000 (00:23 -0400)]
meson.build: remove unnecessary `ln --relative` check

`ln --relative` is used by tools/meson-make-symlink.sh, which is never once
ran during the build process for elogind. additionally, it incurrs a
dependency on GNU coreutils (or any other `ln` that has the non-standard
`--relative` extension), so there's no real need to check for it.

5 years agoAdd https://github.com/Yamakuzure/pwx-elogind-migration-tools.git as submodule 'pwx'
Sven Eden [Wed, 6 Jun 2018 06:04:06 +0000 (08:04 +0200)]
Add https://github.com/Yamakuzure/pwx-elogind-migration-tools.git as submodule 'pwx'

5 years agoRename pwx to pwx_local as a backup.
Sven Eden [Wed, 6 Jun 2018 06:03:09 +0000 (08:03 +0200)]
Rename pwx to pwx_local as a backup.

5 years agopwx/last_mutual_commits.csv: Add last mutual before branching out v238-stable
Sven Eden [Tue, 5 Jun 2018 17:15:47 +0000 (19:15 +0200)]
pwx/last_mutual_commits.csv: Add last mutual before branching out v238-stable

5 years agoPrep v238: Uncomment now needed headers and unmask now needed functions in src/test...
Sven Eden [Tue, 5 Jun 2018 17:08:31 +0000 (19:08 +0200)]
Prep v238: Uncomment now needed headers and unmask now needed functions in src/test (6/6)

5 years agoPrep v238: Uncomment now needed headers and unmask now needed functions in src/shared...
Sven Eden [Tue, 5 Jun 2018 17:08:31 +0000 (19:08 +0200)]
Prep v238: Uncomment now needed headers and unmask now needed functions in src/shared (5/6)

5 years agoPrep v238: Uncomment now needed headers and unmask now needed functions in src/login...
Sven Eden [Tue, 5 Jun 2018 17:08:31 +0000 (19:08 +0200)]
Prep v238: Uncomment now needed headers and unmask now needed functions in src/login (4/6)

5 years agoPrep v238: Uncomment now needed headers and unmask now needed functions in src/libelo...
Sven Eden [Tue, 5 Jun 2018 17:08:31 +0000 (19:08 +0200)]
Prep v238: Uncomment now needed headers and unmask now needed functions in src/libelogind (3/6)

5 years agoPrep v238: Uncomment now needed headers and unmask now needed functions in src/core...
Sven Eden [Tue, 5 Jun 2018 17:08:31 +0000 (19:08 +0200)]
Prep v238: Uncomment now needed headers and unmask now needed functions in src/core (2/6)

5 years agoPrep v238: Uncomment now needed headers and unmask now needed functions in src/basic...
Sven Eden [Tue, 5 Jun 2018 17:08:31 +0000 (19:08 +0200)]
Prep v238: Uncomment now needed headers and unmask now needed functions in src/basic (1/6)

5 years agoPrep v238: Apply some upstream fixes to the sections elogind pendants.
Sven Eden [Tue, 5 Jun 2018 17:06:28 +0000 (19:06 +0200)]
Prep v238: Apply some upstream fixes to the sections elogind pendants.

5 years agoPrep v238: Remove obsolete sources and add missing new ones.
Sven Eden [Tue, 5 Jun 2018 17:03:51 +0000 (19:03 +0200)]
Prep v238: Remove obsolete sources and add missing new ones.

5 years agoPrep v238: removed superfluous files that slithered in during upstream commit migration.
Sven Eden [Fri, 1 Jun 2018 18:23:08 +0000 (20:23 +0200)]
Prep v238: removed superfluous files that slithered in during upstream commit migration.

5 years agoPrep v238: Fixed meson.build files in src/shared and src/test
Sven Eden [Fri, 1 Jun 2018 18:22:28 +0000 (20:22 +0200)]
Prep v238: Fixed meson.build files in src/shared and src/test

5 years agoPrep v238: Applied some upstream updates to src/libelogind (5/5)
Sven Eden [Fri, 1 Jun 2018 18:21:49 +0000 (20:21 +0200)]
Prep v238: Applied some upstream updates to src/libelogind (5/5)

5 years agoPrep v238: Applied some upstream updates to src/core (4/5)
Sven Eden [Fri, 1 Jun 2018 18:21:35 +0000 (20:21 +0200)]
Prep v238: Applied some upstream updates to src/core (4/5)

5 years agoPrep v238: Applied some upstream updates to src/basic (3/5)
Sven Eden [Fri, 1 Jun 2018 18:21:25 +0000 (20:21 +0200)]
Prep v238: Applied some upstream updates to src/basic (3/5)

5 years agoPrep v238: Updated root build files (2/5)
Sven Eden [Fri, 1 Jun 2018 18:21:05 +0000 (20:21 +0200)]
Prep v238: Updated root build files (2/5)

5 years agoPrep v238: Applied some upstream updates to man (1/5)
Sven Eden [Fri, 1 Jun 2018 18:20:09 +0000 (20:20 +0200)]
Prep v238: Applied some upstream updates to man (1/5)

5 years agoPrep v238: Move CODING_STYLE to doc/ mirroring upstream
Sven Eden [Fri, 1 Jun 2018 18:07:42 +0000 (20:07 +0200)]
Prep v238: Move CODING_STYLE to doc/ mirroring upstream

6 years agocheck_tree.pl: A few minor cleanups.
Sven Eden [Wed, 30 May 2018 15:46:30 +0000 (17:46 +0200)]
check_tree.pl: A few minor cleanups.

6 years agoSave last mutual commit for migration to v238 tag.
Sven Eden [Wed, 30 May 2018 05:59:31 +0000 (07:59 +0200)]
Save last mutual commit for migration to v238 tag.

6 years agoNEWS: bump version and add contributors
Zbigniew Jędrzejewski-Szmek [Mon, 5 Mar 2018 16:13:38 +0000 (17:13 +0100)]
NEWS: bump version and add contributors

6 years agomeson: bump so revision and systemd version in preparation for v238
Zbigniew Jędrzejewski-Szmek [Mon, 5 Mar 2018 16:12:48 +0000 (17:12 +0100)]
meson: bump so revision and systemd version in preparation for v238

6 years agomailmap: one more person
Zbigniew Jędrzejewski-Szmek [Mon, 5 Mar 2018 16:08:01 +0000 (17:08 +0100)]
mailmap: one more person

6 years agologin: remember that fds received from PID1 need to be removed eventually
Alan Jenkins [Sat, 3 Mar 2018 18:44:39 +0000 (18:44 +0000)]
login: remember that fds received from PID1 need to be removed eventually

Remember to set sd->pushed_fd when we receive an fd from PID1 on startup,
the same as we set it when we send an fd to PID1.

6 years agologin: fix FDNAME in call to sd_pid_notify_with_fds()
Alan Jenkins [Sat, 3 Mar 2018 18:37:50 +0000 (18:37 +0000)]
login: fix FDNAME in call to sd_pid_notify_with_fds()

$ git grep FDNAME
logind-session-device.c: ... "FDNAME=session-", sd->session->id);
logind-session-device.c: ... "FDNAME=session", sd->session->id);

Oops.

Fixes #8343.  Or at least a more minimal reproducer.  Xorg still
dies when logind is restarted, but the Xorg message says this
is entirely deliberate.

(This could also be the reason I hit #8035, instead of the race
condition I originally suggested).

6 years agoNEWS: update for v238
Zbigniew Jędrzejewski-Szmek [Mon, 5 Mar 2018 09:25:17 +0000 (10:25 +0100)]
NEWS: update for v238

6 years agoman: just use unicode for an mdash
Zbigniew Jędrzejewski-Szmek [Mon, 5 Mar 2018 08:31:17 +0000 (09:31 +0100)]
man: just use unicode for an mdash

6 years agoupdate TODO
Lennart Poettering [Fri, 2 Mar 2018 15:25:27 +0000 (16:25 +0100)]
update TODO

6 years agofd-util: drop stdio_unset_cloexec(), it's not used anymore
Lennart Poettering [Wed, 28 Feb 2018 22:24:50 +0000 (23:24 +0100)]
fd-util: drop stdio_unset_cloexec(), it's not used anymore

6 years agosd-bus: let's better not invade stdio territory when duplicating fds
Lennart Poettering [Wed, 28 Feb 2018 22:36:33 +0000 (23:36 +0100)]
sd-bus: let's better not invade stdio territory when duplicating fds

6 years agotree-wide: port various places over to use new rearrange_stdio()
Lennart Poettering [Wed, 28 Feb 2018 22:32:49 +0000 (23:32 +0100)]
tree-wide: port various places over to use new rearrange_stdio()

6 years agoterminal-util: port some generic code over to rearrange_stdio()
Lennart Poettering [Wed, 28 Feb 2018 20:21:33 +0000 (21:21 +0100)]
terminal-util: port some generic code over to rearrange_stdio()

6 years agofd-util: add new call rearrange_stdio()
Lennart Poettering [Wed, 28 Feb 2018 09:00:26 +0000 (10:00 +0100)]
fd-util: add new call rearrange_stdio()

Quite often we need to set up a number of fds as stdin/stdout/stderr of
a process we are about to start. Add a generic implementation for a
routine doing that that takes care to do so properly:

1. Can handle the case where stdin/stdout/stderr where previously
   closed, and the fds to set as stdin/stdout/stderr hence likely in the
   0..2 range.  handling this properly is nasty, since we need to first
   move the fds out of this range in order to later move them back in, to
   make things fully robust.

2. Can optionally open /dev/null in case for one or more of the fds, in
   a smart way, sharing the open file if possible between multiple of
   the fds.

3. Guarantees that O_CLOEXEC is not set on the three fds, even if the fds
   already were in the 0..2 range and hence possibly weren't moved.

6 years agoupdate TODO
Lennart Poettering [Wed, 28 Feb 2018 19:21:57 +0000 (20:21 +0100)]
update TODO

6 years agococcinelle: add reallocarray() coccinelle script
Lennart Poettering [Tue, 27 Feb 2018 18:09:22 +0000 (19:09 +0100)]
coccinelle: add reallocarray() coccinelle script

Let's systematically make use of reallocarray() whereever we invoke
realloc() with a product of two values.

6 years agomeson: use dashes in colour names
Zbigniew Jędrzejewski-Szmek [Fri, 2 Mar 2018 08:09:29 +0000 (09:09 +0100)]
meson: use dashes in colour names

6 years agoAdd build-time option to change the color of the "OK" status text
Alexander F Rødseth [Thu, 1 Mar 2018 12:12:02 +0000 (13:12 +0100)]
Add build-time option to change the color of the "OK" status text

6 years agoOrganize the ANSI codes and add missing colors
Alexander F Rødseth [Thu, 1 Mar 2018 17:23:05 +0000 (18:23 +0100)]
Organize the ANSI codes and add missing colors

For consistency.

6 years agologind: fix typo in comment
Lennart Poettering [Fri, 2 Mar 2018 10:56:15 +0000 (11:56 +0100)]
logind: fix typo in comment

6 years agologind: open device if needed
Lennart Poettering [Fri, 2 Mar 2018 10:55:51 +0000 (11:55 +0100)]
logind: open device if needed

Fixes: #8291
6 years agologind: cast away return value we don't care about
Lennart Poettering [Fri, 2 Mar 2018 10:55:33 +0000 (11:55 +0100)]
logind: cast away return value we don't care about

6 years agologind: voidify a function we never check the return value of
Lennart Poettering [Fri, 2 Mar 2018 10:55:16 +0000 (11:55 +0100)]
logind: voidify a function we never check the return value of

6 years agomount-setup: change bpf mount mode to 0700 (#8334)
Lennart Poettering [Fri, 2 Mar 2018 11:55:24 +0000 (12:55 +0100)]
mount-setup: change bpf mount mode to 0700 (#8334)

After discussing with the kernel folks, we agreed to default to 0700 for
this. Better safe than sorry.

6 years agoRemove /sbin from paths if split-bin is false (#8324)
Zbigniew Jędrzejewski-Szmek [Thu, 1 Mar 2018 20:48:36 +0000 (21:48 +0100)]
Remove /sbin from paths if split-bin is false (#8324)

Follow-up for 157baa87e4.

6 years agomeson: support both separate and merged sbin-bin directories
Zbigniew Jędrzejewski-Szmek [Thu, 1 Mar 2018 09:28:29 +0000 (10:28 +0100)]
meson: support both separate and merged sbin-bin directories

Follow-up for ba7f4ae6178309dc937e10cf7dce0eca9dafb8de.

By default, we detect if the real root has a separate /usr/sbin directory, but
this can be overrides with -Dsplit-bin=true|false. The check assumes that
/usr/sbin is split if it is not a symlink, so it'll return a false negative
with some more complicated setups. But that's OK, in those cases this should be
configured explicitly.

This will copy the structure of the directories in the root file system to
$DESTDIR. If a directory is a directory in $DESTDIR but a symlink in the root
file system, this script will fail. This means that it's not possible to reuse
a $DESTDIR from between ba7f4ae61 and this patch.

6 years agomeson: autodetect split-usr
Zbigniew Jędrzejewski-Szmek [Thu, 1 Mar 2018 10:49:42 +0000 (11:49 +0100)]
meson: autodetect split-usr

Also move the status from "features" to the paths section. This is more of an
anti-feature.

6 years agoprocfs-util: drop unnecessary zero initializations (#8321)
Lennart Poettering [Thu, 1 Mar 2018 10:27:06 +0000 (11:27 +0100)]
procfs-util: drop unnecessary zero initializations (#8321)

Follow-up for #8149.

6 years agobasic/cgroup-util: simplify cg_get_keyed_attribute(), add test
Zbigniew Jędrzejewski-Szmek [Thu, 1 Mar 2018 08:30:55 +0000 (09:30 +0100)]
basic/cgroup-util: simplify cg_get_keyed_attribute(), add test

I didn't like the nested loop where we'd count what we have acquired already,
since we should always know that.

6 years agoupdate TODO
Lennart Poettering [Fri, 9 Feb 2018 18:43:35 +0000 (19:43 +0100)]
update TODO

6 years agocore: turn on memory/cpu/tasks accounting by default for the root slice
Lennart Poettering [Fri, 9 Feb 2018 18:07:01 +0000 (19:07 +0100)]
core: turn on memory/cpu/tasks accounting by default for the root slice

The kernel exposes the necessary data in /proc anyway, let's expose it
hence by default.

With this in place "systemctl status -- -.slice" will show accounting
data out-of-the-box now.

6 years agocore: hook up /proc queries for the root slice, too
Lennart Poettering [Fri, 9 Feb 2018 18:05:59 +0000 (19:05 +0100)]
core: hook up /proc queries for the root slice, too

Do what we already prepped in cgtop for the root slice in PID 1 too:
consult /proc for the data we need.

6 years agocgroup-util: rework cg_get_keyed_attribute() a bit
Lennart Poettering [Fri, 9 Feb 2018 17:35:52 +0000 (18:35 +0100)]
cgroup-util: rework cg_get_keyed_attribute() a bit

Let's make sure we don't clobber the return parameter on failure, to
follow our coding style. Also, break the loop early if we have all
attributes we need.

This also changes the keys parameter to a simple char**, so that we can
use STRV_MAKE() for passing the list of attributes to read.

This also makes it possible to distuingish the case when the whole
attribute file doesn't exist from one key in it missing. In the former
case we return -ENOENT, in the latter we now return -ENXIO.

6 years agoprocfs-util: add APIs to get consumed CPU time and used memory from /proc
Lennart Poettering [Fri, 9 Feb 2018 16:32:26 +0000 (17:32 +0100)]
procfs-util: add APIs to get consumed CPU time and used memory from /proc

This is preparation for emulating the "usage_usec" keyed attribute of
the "cpu.stat" property of the root cgroup from data in /proc. Similar,
for emulating the "memory.current" attribute.

6 years agocore: don't process dbus unit and job queue when there are already too many messages...
Lennart Poettering [Tue, 13 Feb 2018 17:30:34 +0000 (18:30 +0100)]
core: don't process dbus unit and job queue when there are already too many messages pending

We maintain a queue of units and jobs that we are supposed to generate
change/new notifications for because they were either just created or
some of their property has changed. Let's throttle processing of this
queue a bit: as soon as > 1K of bus messages are queued for writing
let's skip processing the queue, and then recheck on the next
iteration again.

Moreover, never process more than 100 units in one go, return to the
event loop after that. Both limits together should put effective limits
on both space and time usage of the function, delaying further
operations until a later moment, when the queue is empty or the the
event loop is sufficiently idle again.

This should keep the number of generated messages much lower than
before on busy systems or where some client is hanging.

Note that this also means a bad client can slow down message dispatching
substantially for up to 90s if it likes to, for all clients. But that
should be acceptable as we only allow trusted bus clients, anyway.

Fixes: #8166
6 years agosd-bus: add APIs to query the current read and write queue size
Lennart Poettering [Tue, 13 Feb 2018 17:27:05 +0000 (18:27 +0100)]
sd-bus: add APIs to query the current read and write queue size

6 years agoprocess-util: don't install atfork() handler more than once
Lennart Poettering [Mon, 26 Feb 2018 19:50:57 +0000 (20:50 +0100)]
process-util: don't install atfork() handler more than once

6 years agoutil: add new safe_close_above_stdio() wrapper
Lennart Poettering [Mon, 26 Feb 2018 14:41:38 +0000 (15:41 +0100)]
util: add new safe_close_above_stdio() wrapper

At various places we only want to close fds if they are not
stdin/stdout/stderr, i.e. fds 0, 1, 2. Let's add a unified helper call
for that, and port everything over.

6 years agomeson: install compat symlinks for systemctl and systemd (#8300)
Zbigniew Jędrzejewski-Szmek [Wed, 28 Feb 2018 09:20:48 +0000 (10:20 +0100)]
meson: install compat symlinks for systemctl and systemd (#8300)

v2:
- init is a symlink to systemd, not systemctl!

6 years agodoc: add a new doc/ directory, and move two markdown docs into them
Lennart Poettering [Mon, 26 Feb 2018 10:48:46 +0000 (11:48 +0100)]
doc: add a new doc/ directory, and move two markdown docs into them

I figure sooneror later we'll have more of these docs, hence let's give
them a clean place to be.

This leaves NEWS and README/README.md as well as the LICENSE texts in
the root directory of the project since that appears to be customary for
Free Software projects.

6 years agorules: add a missing comma in 70-uaccess.rules since it improves readability
Franck Bui [Fri, 23 Feb 2018 15:49:17 +0000 (16:49 +0100)]
rules: add a missing comma in 70-uaccess.rules since it improves readability

rule-syntax-check.py failed with the following error:

$ ./test/rule-syntax-check.py ./src/login/70-uaccess.rules
Invalid line ./src/login/70-uaccess.rules:31: SUBSYSTEM=="sound", TAG+="uaccess"   OPTIONS+="static_node=snd/timer", OPTIONS+="static_node=snd/seq"
  clause: TAG+="uaccess"   OPTIONS+="static_node=snd/timer"

The comma is actually optional but the script makes it mandatory which seems a
good thing since it improves readability.

6 years agomissing_syscall: add pkey_mprotect for ppc (#8292)
Zbigniew Jędrzejewski-Szmek [Tue, 27 Feb 2018 12:33:00 +0000 (13:33 +0100)]
missing_syscall: add pkey_mprotect for ppc (#8292)

Accurate for both ppc and ppc64 according to https://fedora.juszkiewicz.com.pl/syscalls.html.

6 years agokhash: try to detect broken AF_ALG support in centos kernels
Lennart Poettering [Mon, 26 Feb 2018 12:46:58 +0000 (13:46 +0100)]
khash: try to detect broken AF_ALG support in centos kernels

Fixes: #8278
6 years agosd-login: make use of _cleanup_close_ where possible
Lennart Poettering [Mon, 26 Feb 2018 17:45:45 +0000 (18:45 +0100)]
sd-login: make use of _cleanup_close_ where possible

6 years agologind: make sure we don't trip up on half-initialized session devices
Lennart Poettering [Mon, 26 Feb 2018 17:34:49 +0000 (18:34 +0100)]
logind: make sure we don't trip up on half-initialized session devices

Fixes: #8035
6 years agologind: check file is device node before using .st_rdev
Lennart Poettering [Mon, 26 Feb 2018 17:34:43 +0000 (18:34 +0100)]
logind: check file is device node before using .st_rdev

6 years agologind: let's pack a few struct fields we can pack
Lennart Poettering [Mon, 26 Feb 2018 17:34:13 +0000 (18:34 +0100)]
logind: let's pack a few struct fields we can pack