]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
5 years agobasic/user-util: properly protect use of gshadow
Yann E. MORIN [Wed, 21 Nov 2018 17:09:04 +0000 (18:09 +0100)] 
basic/user-util: properly protect use of gshadow

Commit 100d5f6ee6 (user-util: add new wrappers for [...] database
files), ammended by commit 4f07ffa8f5 (Use #if instead of #ifdef for
ENABLE_GSHADOW) moved code from sysuser to basic/user-util.

In doing so, the combination of both commits properly propagated the
ENABLE_GSHADOW conditions around the function manipulating gshadow, but
they forgot to protect the inclusion of the gshadow.h header.

Fix that to be able to build on C libraries that do not provide gshadow
(e.g. uClibc-ng, where it does not exist.)

5 years agoMerge pull request #9961 from fbuihuu/logind-fix-vt-reinit-race
Lennart Poettering [Wed, 21 Nov 2018 16:28:23 +0000 (17:28 +0100)] 
Merge pull request #9961 from fbuihuu/logind-fix-vt-reinit-race

Logind fix vt reinit race

5 years agoRevert 5fdf2d51c244288ac41443d1bd81365fab7b7b81
Zbigniew Jędrzejewski-Szmek [Wed, 21 Nov 2018 09:21:28 +0000 (10:21 +0100)] 
Revert 5fdf2d51c244288ac41443d1bd81365fab7b7b81

This reverts 5fdf2d51c244288ac41443d1bd81365fab7b7b81, except for one improved
log message.

Fixes #10613.

Checking if resume= is configured is a good idea, but it turns out we cannot do
it reliably:
- the code only supported boot options with sd-boot, and it's not very widely
  used. This means that for most systemd we could only check the current
  commandline, not the next one.
- Various systems resume without, e.g. Debian has
  /etc/initramfs-tools/conf.d/resume in the initramfs.

Making those checks better would be possible with enough effort, but there'll
be always new systems that boot in a slightly different way and we would need
to keep adding new cases. Longer term, we want to rely on autodetecting the
resume partition, and then checks like this will not be necessary at all. It is
quite clear from the number of bug reports that the number of poeple impacted
by this is quite high now, so let's just drop this.

5 years agologind: stop managing VT switches if no sessions are registered on that VT 9961/head
Franck Bui [Mon, 27 Aug 2018 21:16:10 +0000 (23:16 +0200)] 
logind: stop managing VT switches if no sessions are registered on that VT

When no sessions are registered on a given VT (anymore), we should always let
the kernel processes VT switching (instead of simply emitting a warning)
otherwise the requests sent by the kernel are simply ignored making the VT
switch requested by users simply impossible.

Even if it shouldn't happen, this case was encountered in issue #9754, so
better to be safe than sorry.

5 years agoterminal-util: introduce vt_release() helper
Franck Bui [Mon, 27 Aug 2018 20:42:00 +0000 (22:42 +0200)] 
terminal-util: introduce vt_release() helper

5 years agologind: become the controlling terminal process before restoring VT
Franck Bui [Mon, 27 Aug 2018 20:13:21 +0000 (22:13 +0200)] 
logind: become the controlling terminal process before restoring VT

Basically when a session ends, logind notices and restores VT_AUTO so the
kernel takes back VT-switching over.

logind achieves that by watching the process that took control of the session
(via the "TakeControl" D-Bus method), aka "the watched process", which can
be different from the one that initially opened the VT aka "the terminal
controlling process".

In this case the terminal controlling process can exit after the watched one
did and while logind is restoring the VT.

Even if logind took care to re-open the VT in case the VT was already in HUP
state, it wasn't enough because the terminal controlling process could have
exited right after, leaving the VT in HUP state and in VT_PROCESS mode making
further VT-switching impossible.

This patch fixes this situation by forcing logind to become the terminal
controlling process.

Fixes: #9754.
5 years agoterminal-util: introduce vt_restore() helper
Franck Bui [Mon, 27 Aug 2018 20:33:44 +0000 (22:33 +0200)] 
terminal-util: introduce vt_restore() helper

5 years agologind: make session_restore_vt() static
Franck Bui [Thu, 23 Aug 2018 16:03:04 +0000 (18:03 +0200)] 
logind: make session_restore_vt() static

It's only used in logind-session.c.

5 years agogenerators: drop umask calls
Zbigniew Jędrzejewski-Szmek [Wed, 21 Nov 2018 09:12:00 +0000 (10:12 +0100)] 
generators: drop umask calls

systemd already sets the umask (see e3b8d0637dd755b3426f3363b2cdad63f738116c). When
running under systemd, we don't need to set it. And when *not* running under
systemd, for example during development, there is no reason to override the user
config. Let's just drop those calls.

$ git grep -e 'umask\(' -l 'src/*generator*' |xargs perl -i -0pe 's|^[^\n]*umask\([^\n]+\n\n||gms'

5 years agocore: Detect initial timer state from serialized data
Michal Koutný [Fri, 2 Nov 2018 19:56:08 +0000 (20:56 +0100)] 
core: Detect initial timer state from serialized data

We keep a mark whether a single-shot timer was triggered in the caller's
variable initial. When such a timer elapses while we are
serializing/deserializing the inner state, we consider the timer
incorrectly as elapsed and don't trigger it later.

This patch exploits last_trigger timestamp that we already serialize,
hence we can eliminate the argument initial completely.

A reproducer for OnBootSec= timers:
        cat >repro.c <<EOD
        /*
         * Compile: gcc repro.c -o repro
         * Run: ./repro
         */
        #include <errno.h>
        #include <fcntl.h>
        #include <stdio.h>
        #include <stdlib.h>
        #include <sys/stat.h>
        #include <sys/types.h>
        #include <time.h>
        #include <unistd.h>

        int main(int argc, char *argv[]) {
         char command[1024];
         int pause;

         struct timespec now;

         while (1) {
         usleep(rand() % 200000); // prevent periodic repeats
                clock_gettime(CLOCK_MONOTONIC, &now);
         printf("%i\n", now.tv_sec);

         system("rm -f $PWD/mark");
         snprintf(command, 1024, "systemd-run --user --on-boot=%i --timer-property=AccuracySec=100ms "
         "touch $PWD/mark", now.tv_sec + 1);
         system(command);
         system("systemctl --user list-timers");
         pause = (1000000000 - now.tv_nsec)/1000 - 70000; // fiddle to hit the middle of reloading
         usleep(pause > 0 ? pause : 0);
         system("systemctl --user daemon-reload");
         sync();
         sleep(2);
         if (open("./mark", 0) < 0)
         if (errno == ENOENT) {
         printf("mark file does not exist\n");
         break;
         }
         }

         return 0;
        }
        EOD

5 years agoMerge pull request #10866 from yuwata/libudev-util-cleanups
Lennart Poettering [Wed, 21 Nov 2018 10:15:35 +0000 (11:15 +0100)] 
Merge pull request #10866 from yuwata/libudev-util-cleanups

libudev-util: several cleanups and tests

5 years agoMerge pull request #10860 from keszybz/more-cleanup-2
Lennart Poettering [Wed, 21 Nov 2018 10:07:31 +0000 (11:07 +0100)] 
Merge pull request #10860 from keszybz/more-cleanup-2

Do more stuff from main macros

5 years agotest: add tests for util_resolve_subsys_kernel() 10866/head
Yu Watanabe [Wed, 21 Nov 2018 08:29:34 +0000 (17:29 +0900)] 
test: add tests for util_resolve_subsys_kernel()

5 years agolibudev: make util_resolve_subsys_kernel() return negative errno
Yu Watanabe [Wed, 21 Nov 2018 08:27:38 +0000 (17:27 +0900)] 
libudev: make util_resolve_subsys_kernel() return negative errno

This also replaces udev_device by sd_device in the function.

5 years agoudev/scsi_id: fix buffer length
Yu Watanabe [Wed, 21 Nov 2018 07:42:37 +0000 (16:42 +0900)] 
udev/scsi_id: fix buffer length

5 years agotest: add tests for util_replace_whitespace()
Yu Watanabe [Wed, 21 Nov 2018 07:17:29 +0000 (16:17 +0900)] 
test: add tests for util_replace_whitespace()

5 years agolibudev-util: make util_replace_whitespace() not count leading white spaces
Yu Watanabe [Wed, 21 Nov 2018 07:17:36 +0000 (16:17 +0900)] 
libudev-util: make util_replace_whitespace() not count leading white spaces

5 years agoudevd: define main through macro 10860/head
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 15:43:19 +0000 (16:43 +0100)] 
udevd: define main through macro

This removes the call to log_close(), and refactors how fork() is done. Now
the parent also goes through normal cleanup. This isn't necessary to use the
macro, but it feels cleaner this way.

5 years agoudevadm: define main through macro
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 15:41:38 +0000 (16:41 +0100)] 
udevadm: define main through macro

This removes a call to log_close(). I don't think this should matter.
The call to mac_selinux_init() is moved after parse_argv(). We probably
don't need selinux when printing help().

5 years agoCall mac_selinux_close() from main func macros, convert user-sessions and test-udev
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 15:40:49 +0000 (16:40 +0100)] 
Call mac_selinux_close() from main func macros, convert user-sessions and test-udev

5 years agosystemctl: define main through macro and call ask_password_agent_close() from the...
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 09:22:26 +0000 (10:22 +0100)] 
systemctl: define main through macro and call ask_password_agent_close() from the macro

This doesn't save us anything, but I like consistency.

5 years agolibudev-util: make util_replace_*() return size_t
Yu Watanabe [Wed, 21 Nov 2018 07:35:20 +0000 (16:35 +0900)] 
libudev-util: make util_replace_*() return size_t

5 years agolibudev-util: add assertions
Yu Watanabe [Wed, 21 Nov 2018 07:32:54 +0000 (16:32 +0900)] 
libudev-util: add assertions

5 years agocore: run env generators with non-zero umask
Lennart Poettering [Tue, 20 Nov 2018 18:14:24 +0000 (19:14 +0100)] 
core: run env generators with non-zero umask

For PID 1 we adjust the umask to 0, but generators should not run that
way, given that they might be implemented as shell scripts and such.
Let's hence explicitly adjust the umask for them.

We already do this for unit generators. Let's do this for env
generators, too.

5 years agotests: skip test_exec_ambientcapabilities on Travis CI under ASan
Evgeny Vereshchagin [Tue, 20 Nov 2018 14:47:11 +0000 (15:47 +0100)] 
tests: skip test_exec_ambientcapabilities on Travis CI under ASan

Let's not bother contributors with spurious failures nobody can't
seem to reproduce. There is an issue about that where we're trying
to figure out what's going on: https://github.com/systemd/systemd/issues/10696.

5 years agoMerge pull request #10853 from poettering/thaw-containers
Lennart Poettering [Tue, 20 Nov 2018 18:35:30 +0000 (19:35 +0100)] 
Merge pull request #10853 from poettering/thaw-containers

main: don't freeze PID 1 in containers, exit with non-zero instead

5 years agoMerge pull request #10858 from poettering/tmpfiles-fixlets
Lennart Poettering [Tue, 20 Nov 2018 18:09:37 +0000 (19:09 +0100)] 
Merge pull request #10858 from poettering/tmpfiles-fixlets

more tmpfiles fixlets

5 years agoportablectl: make "arg_host" const
Yu Watanabe [Tue, 20 Nov 2018 09:36:19 +0000 (18:36 +0900)] 
portablectl: make "arg_host" const

5 years agomount-tool: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 09:30:13 +0000 (18:30 +0900)] 
mount-tool: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agomodules-load: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 09:24:47 +0000 (18:24 +0900)] 
modules-load: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agomachinectl: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 09:21:01 +0000 (18:21 +0900)] 
machinectl: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agoshared/main-func: also close the polkit agent automatically
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 14:52:40 +0000 (15:52 +0100)] 
shared/main-func: also close the polkit agent automatically

The agent is closed after the static destuctors but before the pager.
No users of DEFINE_MAIN_FUNCTION* were using a polkit agent, so this makes no
functional difference.

5 years agoSplit out pretty-print.c and move pager.c and main-func.h to shared/
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 14:42:57 +0000 (15:42 +0100)] 
Split out pretty-print.c and move pager.c and main-func.h to shared/

This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).

5 years agomachine-id: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 09:17:53 +0000 (18:17 +0900)] 
machine-id: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agologinctl: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 09:15:33 +0000 (18:15 +0900)] 
loginctl: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agolocale: make "arg_host" const
Yu Watanabe [Tue, 20 Nov 2018 09:08:33 +0000 (18:08 +0900)] 
locale: make "arg_host" const

5 years agohostnamed: use DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 09:03:50 +0000 (18:03 +0900)] 
hostnamed: use DEFINE_MAIN_FUNCTION() macro

This also renames context_free() to context_clear().

5 years agohibernate-resume-generator: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 09:00:13 +0000 (18:00 +0900)] 
hibernate-resume-generator: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agofstab-generator: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 08:56:47 +0000 (17:56 +0900)] 
fstab-generator: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agofirstboot: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 08:52:57 +0000 (17:52 +0900)] 
firstboot: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agodissect: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 08:46:14 +0000 (17:46 +0900)] 
dissect: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agobless-boot: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 08:39:25 +0000 (17:39 +0900)] 
bless-boot: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agocryptsetup: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 08:18:08 +0000 (17:18 +0900)] 
cryptsetup: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agocgls: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 06:47:27 +0000 (15:47 +0900)] 
cgls: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agomain: don't freeze PID 1 in containers, exit with non-zero instead 10853/head
Lennart Poettering [Tue, 20 Nov 2018 12:16:48 +0000 (13:16 +0100)] 
main: don't freeze PID 1 in containers, exit with non-zero instead

After all we have a nice way to propagate total failures, hence let's
use it.

5 years agomain: use EXIT_EXCEPTION instead of EXIT_FAILURE at two more exceptional places
Lennart Poettering [Tue, 20 Nov 2018 16:03:35 +0000 (17:03 +0100)] 
main: use EXIT_EXCEPTION instead of EXIT_FAILURE at two more exceptional places

5 years agonspawn: use EXIT_EXCEPTION where appropriate
Lennart Poettering [Tue, 20 Nov 2018 15:58:42 +0000 (16:58 +0100)] 
nspawn: use EXIT_EXCEPTION where appropriate

5 years agoexit-status: introduce EXIT_EXCEPTION mapping to 255
Lennart Poettering [Tue, 20 Nov 2018 15:55:51 +0000 (16:55 +0100)] 
exit-status: introduce EXIT_EXCEPTION mapping to 255

5 years agocgls: add const
Yu Watanabe [Tue, 20 Nov 2018 06:42:48 +0000 (15:42 +0900)] 
cgls: add const

5 years agobusctl: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 06:40:36 +0000 (15:40 +0900)] 
busctl: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agobootctl: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 06:35:07 +0000 (15:35 +0900)] 
bootctl: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agobacklight: use DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 06:16:08 +0000 (15:16 +0900)] 
backlight: use DEFINE_MAIN_FUNCTION() macro

5 years agoask-password: use static destructor and DEFINE_MAIN_FUNCTION() macro
Yu Watanabe [Tue, 20 Nov 2018 06:14:16 +0000 (15:14 +0900)] 
ask-password: use static destructor and DEFINE_MAIN_FUNCTION() macro

5 years agoanalyze: use static destructors
Yu Watanabe [Tue, 20 Nov 2018 06:13:16 +0000 (15:13 +0900)] 
analyze: use static destructors

5 years agobinfmt: define main through macro
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 09:04:35 +0000 (10:04 +0100)] 
binfmt: define main through macro

5 years agodelta: define main through macro
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 09:02:43 +0000 (10:02 +0100)] 
delta: define main through macro

5 years agonetworkctl: define main through macro
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 08:57:30 +0000 (09:57 +0100)] 
networkctl: define main through macro

5 years agoportablectl: define main through macro
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 08:56:57 +0000 (09:56 +0100)] 
portablectl: define main through macro

5 years agolocalectl: define main through macro
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 08:56:18 +0000 (09:56 +0100)] 
localectl: define main through macro

5 years agocoredumpctl: fix "leak" of bus connection
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 08:54:31 +0000 (09:54 +0100)] 
coredumpctl: fix "leak" of bus connection

$ valgrind --show-leak-kinds=all --leak-check=full build/coredumpctl dump --output /tmp/ff
...
==16431== HEAP SUMMARY:
==16431==     in use at exit: 3,680 bytes in 13 blocks
==16431==   total heap usage: 831 allocs, 818 frees, 197,776 bytes allocated
==16431==
==16431== 2 bytes in 1 blocks are still reachable in loss record 1 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4C4D5AD: strdup (strdup.c:42)
==16431==    by 0x49B2387: bus_message_parse_fields (bus-message.c:5300)
==16431==    by 0x49A23AF: bus_message_from_malloc (bus-message.c:560)
==16431==    by 0x49C459B: bus_socket_make_message (bus-socket.c:1099)
==16431==    by 0x49C4C5B: bus_socket_read_message (bus-socket.c:1213)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CFA2C: sd_bus_call (sd-bus.c:2176)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 9 bytes in 1 blocks are still reachable in loss record 2 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4939067: malloc_multiply (alloc-util.h:78)
==16431==    by 0x493921D: hexmem (hexdecoct.c:62)
==16431==    by 0x49C2B75: bus_socket_start_auth_client (bus-socket.c:626)
==16431==    by 0x49C2D78: bus_socket_start_auth (bus-socket.c:665)
==16431==    by 0x49C3B09: bus_socket_connect (bus-socket.c:915)
==16431==    by 0x49CBB08: bus_start_address (sd-bus.c:1103)
==16431==    by 0x49CBFEA: sd_bus_start (sd-bus.c:1187)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==
==16431== 9 bytes in 1 blocks are still reachable in loss record 3 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4C4D5AD: strdup (strdup.c:42)
==16431==    by 0x497364E: free_and_strdup (string-util.c:1013)
==16431==    by 0x49C9FB1: hello_callback (sd-bus.c:547)
==16431==    by 0x49D0A3A: process_reply (sd-bus.c:2498)
==16431==    by 0x49D13E0: process_message (sd-bus.c:2677)
==16431==    by 0x49D165F: process_running (sd-bus.c:2739)
==16431==    by 0x49D20DD: bus_process_internal (sd-bus.c:2957)
==16431==    by 0x49D21E8: sd_bus_process (sd-bus.c:2984)
==16431==    by 0x49CF21E: bus_ensure_running (sd-bus.c:2053)
==16431==    by 0x49CF51F: sd_bus_call (sd-bus.c:2095)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==
==16431== 24 bytes in 1 blocks are still reachable in loss record 4 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x495CB0D: malloc_multiply (alloc-util.h:78)
==16431==    by 0x495CB2A: prioq_new (prioq.c:35)
==16431==    by 0x495CC02: prioq_ensure_allocated (prioq.c:60)
==16431==    by 0x49CEF84: sd_bus_call_async (sd-bus.c:1995)
==16431==    by 0x49CA0E6: bus_send_hello (sd-bus.c:581)
==16431==    by 0x49CC019: sd_bus_start (sd-bus.c:1196)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==
==16431== 38 bytes in 1 blocks are still reachable in loss record 5 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4C4D5AD: strdup (strdup.c:42)
==16431==    by 0x497364E: free_and_strdup (string-util.c:1013)
==16431==    by 0x49C7F97: sd_bus_set_address (sd-bus.c:269)
==16431==    by 0x49CC314: bus_set_address_system (sd-bus.c:1262)
==16431==    by 0x49CC3E0: sd_bus_open_system_with_description (sd-bus.c:1281)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 64 bytes in 1 blocks are still reachable in loss record 6 of 13
==16431==    at 0x4838748: malloc (vg_replace_malloc.c:298)
==16431==    by 0x483AD63: realloc (vg_replace_malloc.c:826)
==16431==    by 0x4902663: greedy_realloc (alloc-util.c:55)
==16431==    by 0x49C7D7D: sd_bus_new (sd-bus.c:255)
==16431==    by 0x49CC398: sd_bus_open_system_with_description (sd-bus.c:1271)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 64 bytes in 1 blocks are still reachable in loss record 7 of 13
==16431==    at 0x4838748: malloc (vg_replace_malloc.c:298)
==16431==    by 0x483AD63: realloc (vg_replace_malloc.c:826)
==16431==    by 0x4902663: greedy_realloc (alloc-util.c:55)
==16431==    by 0x49CE54E: bus_rqueue_make_room (sd-bus.c:1786)
==16431==    by 0x49C44FC: bus_socket_make_message (bus-socket.c:1087)
==16431==    by 0x49C4C5B: bus_socket_read_message (bus-socket.c:1213)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CE6AF: dispatch_rqueue (sd-bus.c:1814)
==16431==    by 0x49D162E: process_running (sd-bus.c:2733)
==16431==    by 0x49D20DD: bus_process_internal (sd-bus.c:2957)
==16431==    by 0x49D21E8: sd_bus_process (sd-bus.c:2984)
==16431==    by 0x49CF21E: bus_ensure_running (sd-bus.c:2053)
==16431==
==16431== 65 bytes in 1 blocks are still reachable in loss record 8 of 13
==16431==    at 0x483AB1A: calloc (vg_replace_malloc.c:752)
==16431==    by 0x496E5D6: getpeersec (socket-util.c:969)
==16431==    by 0x49C291C: bus_get_peercred (bus-socket.c:594)
==16431==    by 0x49C2CB2: bus_socket_start_auth (bus-socket.c:650)
==16431==    by 0x49C3B09: bus_socket_connect (bus-socket.c:915)
==16431==    by 0x49CBB08: bus_start_address (sd-bus.c:1103)
==16431==    by 0x49CBFEA: sd_bus_start (sd-bus.c:1187)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==
==16431== 181 bytes in 1 blocks are still reachable in loss record 9 of 13
==16431==    at 0x483AD19: realloc (vg_replace_malloc.c:826)
==16431==    by 0x49C4791: bus_socket_read_message (bus-socket.c:1143)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CFA2C: sd_bus_call (sd-bus.c:2176)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 256 bytes in 1 blocks are still reachable in loss record 10 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x496E740: getpeergroups (socket-util.c:998)
==16431==    by 0x49C29BD: bus_get_peercred (bus-socket.c:599)
==16431==    by 0x49C2CB2: bus_socket_start_auth (bus-socket.c:650)
==16431==    by 0x49C3B09: bus_socket_connect (bus-socket.c:915)
==16431==    by 0x49CBB08: bus_start_address (sd-bus.c:1103)
==16431==    by 0x49CBFEA: sd_bus_start (sd-bus.c:1187)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==
==16431== 256 bytes in 1 blocks are still reachable in loss record 11 of 13
==16431==    at 0x4838748: malloc (vg_replace_malloc.c:298)
==16431==    by 0x483AD63: realloc (vg_replace_malloc.c:826)
==16431==    by 0x495D1A0: prioq_put (prioq.c:162)
==16431==    by 0x49CF0EA: sd_bus_call_async (sd-bus.c:2023)
==16431==    by 0x49CA0E6: bus_send_hello (sd-bus.c:581)
==16431==    by 0x49CC019: sd_bus_start (sd-bus.c:1196)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==
==16431== 856 bytes in 1 blocks are still reachable in loss record 12 of 13
==16431==    at 0x483AB1A: calloc (vg_replace_malloc.c:752)
==16431==    by 0x49A1F33: bus_message_from_header (bus-message.c:458)
==16431==    by 0x49A22B1: bus_message_from_malloc (bus-message.c:535)
==16431==    by 0x49C459B: bus_socket_make_message (bus-socket.c:1099)
==16431==    by 0x49C4C5B: bus_socket_read_message (bus-socket.c:1213)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CFA2C: sd_bus_call (sd-bus.c:2176)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 1,856 bytes in 1 blocks are still reachable in loss record 13 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x49C6EDF: malloc_multiply (alloc-util.h:78)
==16431==    by 0x49C7C81: sd_bus_new (sd-bus.c:235)
==16431==    by 0x49CC398: sd_bus_open_system_with_description (sd-bus.c:1271)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== LEAK SUMMARY:
==16431==    definitely lost: 0 bytes in 0 blocks
==16431==    indirectly lost: 0 bytes in 0 blocks
==16431==      possibly lost: 0 bytes in 0 blocks
==16431==    still reachable: 3,680 bytes in 13 blocks
==16431==         suppressed: 0 bytes in 0 blocks
==16431==

5 years agocoredumpctl: define main through macro
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 08:50:07 +0000 (09:50 +0100)] 
coredumpctl: define main through macro

We want to propagate the return value from gdb, hence this commit makes
use of the liberalization of DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE()
in previous commit.

5 years agocoredumpctl: open output file only before writing
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 08:27:19 +0000 (09:27 +0100)] 
coredumpctl: open output file only before writing

We would open the file very early, which is not nice, if we e.g. fail when
parsing later options. Let's do the usual thing and just open it just before
writing, and close immediately after writing.

5 years agobasic/main-func: propagate all positive return values
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 08:49:42 +0000 (09:49 +0100)] 
basic/main-func: propagate all positive return values

This changes DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE() to propagate positive
return values as they were, i.e. stops mapping them all to EXIT_FAILURE. This
was suggested in review, but I thought that we only ever return EXIT_FAILURE,
so we don't need to propagate multiple return values.

I was wrong. Turns out that we already *do* have multiple positive return
values, when we call external binaries and propagate the result. systemd-inhibit
is one example, and b453c447e0fb4a1e9eccd42120731c1700220b21 actually broke
this propagation. This commit fixes it.

In systemd-fsck we have the opposite case: we have only one failure value, and the
code needs to be adjusted, so that it keeps returning EXIT_FAILURE.

All other users of DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE() return <= 1, and
are unaffected by this change.

5 years agotimedatectl: define main through macro
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 08:18:21 +0000 (09:18 +0100)] 
timedatectl: define main through macro

pager_close() is called from DEFINE_MAIN_FUNCTION().

5 years agobasic/main-func: also close the pager automatically
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 13:03:46 +0000 (14:03 +0100)] 
basic/main-func: also close the pager automatically

We generally want to close the pager last. This patch closes the pager last,
after the static destuctor calls. This means that they can do logging and such
like during normal program runtime.

5 years agobasic/main-func: unify the two macros
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 12:54:12 +0000 (13:54 +0100)] 
basic/main-func: unify the two macros

No functional change.

5 years agosysctl: use STATIC_DESTRUCTOR_REGISTER() to free arg_prefixes
Lennart Poettering [Tue, 20 Nov 2018 10:29:54 +0000 (11:29 +0100)] 
sysctl: use STATIC_DESTRUCTOR_REGISTER() to free arg_prefixes

5 years agosysctl: use _cleanup_ in one more occasion
Lennart Poettering [Tue, 20 Nov 2018 10:29:02 +0000 (11:29 +0100)] 
sysctl: use _cleanup_ in one more occasion

5 years agosysctl: port to use DEFINE_MAIN_FUNCTION()
Lennart Poettering [Tue, 20 Nov 2018 10:28:19 +0000 (11:28 +0100)] 
sysctl: port to use DEFINE_MAIN_FUNCTION()

5 years agoinhibit: fix return value in error path
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 08:41:32 +0000 (09:41 +0100)] 
inhibit: fix return value in error path

5 years agotmpfiles: also order glob child/parent relationships 10858/head
Lennart Poettering [Tue, 20 Nov 2018 15:32:23 +0000 (16:32 +0100)] 
tmpfiles: also order glob child/parent relationships

This is necessary so that "r" can be nested and are always executed in
the same order.

Fixes: #10191
5 years agotmpfiles: fix typo
Lennart Poettering [Tue, 20 Nov 2018 15:32:19 +0000 (16:32 +0100)] 
tmpfiles: fix typo

5 years agotmpfiles: label phases explicitly
Lennart Poettering [Tue, 20 Nov 2018 15:15:09 +0000 (16:15 +0100)] 
tmpfiles: label phases explicitly

5 years agotmpfiles: behind → below in log msgs
Lennart Poettering [Tue, 20 Nov 2018 14:56:55 +0000 (15:56 +0100)] 
tmpfiles: behind → below in log msgs

As suggested here:

https://github.com/systemd/systemd/pull/10538#pullrequestreview-176710207

5 years agoman: minor fixes
Lennart Poettering [Tue, 20 Nov 2018 14:56:22 +0000 (15:56 +0100)] 
man: minor fixes

As suggested here:

https://github.com/systemd/systemd/pull/10538#pullrequestreview-176710207

5 years agoMerge pull request #10850 from poettering/log-setup
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 12:36:45 +0000 (13:36 +0100)] 
Merge pull request #10850 from poettering/log-setup

reduce some logging boilerplate

5 years agoveritysetup-generator: treat '-' and '_' as equivalent
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 10:48:48 +0000 (11:48 +0100)] 
veritysetup-generator: treat '-' and '_' as equivalent

5 years agoMerge pull request #10538 from poettering/tmpfiles-reorder
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 12:00:28 +0000 (13:00 +0100)] 
Merge pull request #10538 from poettering/tmpfiles-reorder

tmpfiles: remove children before their parents plus other fixlets

5 years agoMerge pull request #10831 from keszybz/less-libbasic
Lennart Poettering [Tue, 20 Nov 2018 11:44:30 +0000 (12:44 +0100)] 
Merge pull request #10831 from keszybz/less-libbasic

Move various files that don't need to be in basic/ to shared/

5 years agolog: introduce new helper call log_setup_service() 10850/head
Lennart Poettering [Tue, 20 Nov 2018 10:18:22 +0000 (11:18 +0100)] 
log: introduce new helper call log_setup_service()

Let's reduce the common boilerplate and have a single setup function
used by all service code to setup logging.

5 years agogenerators: introduce a common implementation for the log setup boilerplate
Lennart Poettering [Mon, 19 Nov 2018 20:32:11 +0000 (21:32 +0100)] 
generators: introduce a common implementation for the log setup boilerplate

5 years agoMerge pull request #10787 from yuwata/libudev-cleanups
Zbigniew Jędrzejewski-Szmek [Tue, 20 Nov 2018 09:42:19 +0000 (10:42 +0100)] 
Merge pull request #10787 from yuwata/libudev-cleanups

libudev: drop unused private functions

5 years agojournal: fix sort order of header includes 10831/head
Zbigniew Jędrzejewski-Szmek [Mon, 19 Nov 2018 12:29:16 +0000 (13:29 +0100)] 
journal: fix sort order of header includes

5 years agoCODING_STYLE: fix rules for STRLEN and recommend strjoina more strongly
Zbigniew Jędrzejewski-Szmek [Mon, 19 Nov 2018 12:24:34 +0000 (13:24 +0100)] 
CODING_STYLE: fix rules for STRLEN and recommend strjoina more strongly

Again, this mostly matches what is happening in the codebase already.

5 years agoCODING_STYLE: clarify the rules for the src/basic & src/shared split
Zbigniew Jędrzejewski-Szmek [Mon, 19 Nov 2018 12:14:21 +0000 (13:14 +0100)] 
CODING_STYLE: clarify the rules for the src/basic & src/shared split

The rule is changed from "put in basic unless there's a reason not to" to "put
in shared unless there's a reason not to", to match the change done in previous
commit. This minimizes libbasic. See previous commit for the reasons why this
is useful.

Previously, the guideline was based on whether the files in question use
"publicly exported APIs". This distinction is not particularly relevant. Let's
consider all other programs we compile: most of them use "publicly exported
APIs", usually linking to libsystemd-shared.so for the actual code. But those
programs are not forced to be in src/basic, and the distinction whether they
happen to use 'sd-*.h' or not is of no importance. The same is true for files
in src/shared/. If we didn't have publicly exported shared objects, we'd put
everything in libsystemd-shared.so. So let's only move things out of it that we
need to. Previous guideline was not "wrong", in the sense that it created *a*
split that was functional (no code in src/shared was required in the publicly
exported shared objects), but it put more files in basic/ then necessary.

Not much changes in practice, because (as previous commit shows), moving files
between libbasic.a and libsystemd-shared.so mostly just changes compilation
order.

The list of components which cannot use libsystemd-shared.so is adjusted.

5 years agomeson: drop libblkid from libbasic
Zbigniew Jędrzejewski-Szmek [Mon, 19 Nov 2018 10:35:33 +0000 (11:35 +0100)] 
meson: drop libblkid from libbasic

This doesn't seem to change anything, because libmount links to libblkid anyway.
But we don't need to include this dep directly in libbasic.

5 years agoMove various files that don't need to be in basic/ to shared/
Zbigniew Jędrzejewski-Szmek [Mon, 19 Nov 2018 10:12:28 +0000 (11:12 +0100)] 
Move various files that don't need to be in basic/ to shared/

This doesn't have much effect on the final build, because we link libbasic.a
into libsystemd-shared.so, so in the end, all the object built from basic/
end up in libsystemd-shared. And when the static library is linked into binaries,
any objects that are included in it but are not used are trimmed. Hence, the
size of output artifacts doesn't change:

$ du -sb /var/tmp/inst*
54181861 /var/tmp/inst1    (old)
54207441 /var/tmp/inst1s   (old split-usr)
54182477 /var/tmp/inst2    (new)
54208041 /var/tmp/inst2s   (new split-usr)

(The negligible change in size is because libsystemd-shared.so is bigger
by a few hundred bytes. I guess it's because symbols are named differently
or something like that.)

The effect is on the build process, in particular partial builds. This change
effectively moves the requirements on some build steps toward the leaves of the
dependency tree. Two effects:
- when building items that do not depend on libsystemd-shared, we
  build less stuff for libbasic.a (which wouldn't be used anyway,
  so it's a net win).
- when building items that do depend on libshared, we reduce libbasic.a as a
  synchronization point, possibly allowing better parallelism.

Method:
1. copy list of .h files from src/basic/meson.build to /tmp/basic
2. $ for i in $(grep '.h$' /tmp/basic); do echo $i; git --no-pager grep "include \"$i\"" src/basic/ 'src/lib*' 'src/nss-*' 'src/journal/sd-journal.c' |grep -v "${i%.h}.c";echo ;done | less

5 years agolibudev: coding style fixes 10787/head
Yu Watanabe [Mon, 29 Oct 2018 17:40:23 +0000 (02:40 +0900)] 
libudev: coding style fixes

5 years agolibudev-list: move libudev-list related definitions to libudev-list-internal.h
Yu Watanabe [Fri, 16 Nov 2018 02:44:17 +0000 (11:44 +0900)] 
libudev-list: move libudev-list related definitions to libudev-list-internal.h

This also rename libudev-private.h to libudev-util.h, and cleanups
several unnecessary headers from udev.h and libudev-util.h

5 years agolibudev: drop prototypes for nonexistent functions
Yu Watanabe [Mon, 29 Oct 2018 15:59:06 +0000 (00:59 +0900)] 
libudev: drop prototypes for nonexistent functions

5 years agolibudev-monitor: drop unused private functions
Yu Watanabe [Mon, 29 Oct 2018 15:54:12 +0000 (00:54 +0900)] 
libudev-monitor: drop unused private functions

5 years agolibudev-device: drop unused private functions
Yu Watanabe [Fri, 16 Nov 2018 02:30:01 +0000 (11:30 +0900)] 
libudev-device: drop unused private functions

5 years agoudev: move definition of READ_END and WRITE_END from libudev-private.h to udev.h
Yu Watanabe [Fri, 16 Nov 2018 02:28:07 +0000 (11:28 +0900)] 
udev: move definition of READ_END and WRITE_END from libudev-private.h to udev.h

5 years agoMerge pull request #10847 from evverx/journald-stream-fuzzer
Yu Watanabe [Tue, 20 Nov 2018 04:37:27 +0000 (13:37 +0900)] 
Merge pull request #10847 from evverx/journald-stream-fuzzer

tests: add a fuzzer for journald streams

5 years agozsh-completion: Add support for set-property (#10322)
Xuanwo [Tue, 20 Nov 2018 04:17:11 +0000 (12:17 +0800)] 
zsh-completion: Add support for set-property (#10322)

5 years agoMerge pull request #10801 from ssc-services/zsh-completion_machinectl_clone
Yu Watanabe [Tue, 20 Nov 2018 04:13:41 +0000 (13:13 +0900)] 
Merge pull request #10801 from ssc-services/zsh-completion_machinectl_clone

 zsh-completion: complete available, not running machines for `clone`

5 years agoMerge pull request #10835 from poettering/transient-env-fix
Yu Watanabe [Tue, 20 Nov 2018 03:53:51 +0000 (12:53 +0900)] 
Merge pull request #10835 from poettering/transient-env-fix

fix flushing out of transient env vars from PID1's Manager object

5 years agobootspec: introduce SYSTEMD_ESP_PATH for overriding where to look for the ESP (#10834)
Lennart Poettering [Tue, 20 Nov 2018 03:37:01 +0000 (04:37 +0100)] 
bootspec: introduce SYSTEMD_ESP_PATH for overriding where to look for the ESP (#10834)

5 years agoprocess-util: check for correct kill return value (#10841)
David Leeds [Tue, 20 Nov 2018 03:35:36 +0000 (19:35 -0800)] 
process-util: check for correct kill return value (#10841)

Code was not doing a wait() after kill() due to checking for a return value > 0, and was leaving zombie processes. This affected things like  sd-bus unixexec connections.

5 years agotree-wide: use __ prefixed gcc attributes (#10843)
Lennart Poettering [Tue, 20 Nov 2018 03:34:08 +0000 (04:34 +0100)] 
tree-wide: use __ prefixed gcc attributes (#10843)

As suggest here:

https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax

    "You may optionally specify attribute names with ‘__’ preceding and
    following the name. This allows you to use them in header files without
    being concerned about a possible macro of the same name. For example,
    you may use the attribute name __noreturn__ instead of noreturn. "