Commit graph

2885 commits

Author SHA1 Message Date
Lennart Poettering f612f8fb93 ask-password: pretty flags enum definition a bit 2018-02-14 00:13:26 +01:00
Lennart Poettering daa557208d tty-ask-password-agent: don't open terminal multiple times
We already have the terminal open, hence pass the fd we got to
ask_password_tty(), so that it doesn't have to reopen it a second time.

This is mostly an optimization, but it has the nice benefit of making us
independent from RLIMIT_NOFILE issues and so on, as we don't need to
allocate another fd needlessly.
2018-02-14 00:11:16 +01:00
Lennart Poettering 088dcd8e41 ask-password: derive pollfd array from enum
It's prettier that way!
2018-02-14 00:03:05 +01:00
Lennart Poettering c9eb4a0054 ask-password: round up when determining sleep time
We should rather sleep to much than too little. This otherwise might
result in a busy loop, because we slept too little and then recheck
again coming to the conclusion we need to go to sleep again, and so on.
2018-02-14 00:03:05 +01:00
Lennart Poettering 70dee4755a ask-password: let's use structure initialization properly 2018-02-14 00:03:04 +01:00
Lennart Poettering ac7a9674e4 ask-password: let's (void) cast where appropriate 2018-02-14 00:03:04 +01:00
Lennart Poettering a497a2966e ask-password: bypass clean-up if we don't need it 2018-02-13 23:56:57 +01:00
Lennart Poettering 0f13392851 ask-password: don't use ttyfd if it is not set 2018-02-13 23:55:58 +01:00
Zbigniew Jędrzejewski-Szmek 0d6671b2ef shared/path-lookup: rename user control dirs to "user.control"
$ diff -u <(old/systemd-analyze --user unit-paths) <(new/systemd-analyze --user unit-paths)|colordiff
--- /proc/self/fd/14	2018-02-08 14:36:34.190046129 +0100
+++ /proc/self/fd/15	2018-02-08 14:36:34.190046129 +0100
@@ -1,5 +1,5 @@
-/home/zbyszek/.config/systemd/system.control
-/run/user/1000/systemd/system.control
+/home/zbyszek/.config/systemd/user.control
+/run/user/1000/systemd/user.control
 /run/user/1000/systemd/transient
 ...

Strictly speaking, online upgrades of user instances through daemon-reexec will
be broken. We can get away with this since
a) reexecs of the user instance are not commonly done, at least package upgrade
   scripts don't do this afawk.
b) cgroups aren't delegateable on cgroupsv1 there's little reason to use "systemctl
   set-property" for --user mode
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 7e684baf90 shared/path-lookup: rearrange paths in --global mode to match --user mode
It's not good if the paths are in different order. With --user, we expect
more paths, but it must be a strict superset, and the order for the ones
that appear in both sets must be the same.

$  diff -u <(build/systemd-analyze --global unit-paths) <(build/systemd-analyze --user unit-paths)|colordiff
--- /proc/self/fd/14	2018-02-08 14:11:45.425353107 +0100
+++ /proc/self/fd/15	2018-02-08 14:11:45.426353116 +0100
@@ -1,6 +1,17 @@
+/home/zbyszek/.config/systemd/system.control
+/run/user/1000/systemd/system.control
+/run/user/1000/systemd/transient
+/run/user/1000/systemd/generator.early
+/home/zbyszek/.config/systemd/user
 /etc/systemd/user
+/run/user/1000/systemd/user
 /run/systemd/user
+/run/user/1000/systemd/generator
+/home/zbyszek/.local/share/systemd/user
+/home/zbyszek/.local/share/flatpak/exports/share/systemd/user
+/var/lib/flatpak/exports/share/systemd/user
 /usr/local/share/systemd/user
 /usr/share/systemd/user
 /usr/local/lib/systemd/user
 /usr/lib/systemd/user
+/run/user/1000/systemd/generator.late

A test is added so that we don't regress on this.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 7b6344d35f path-lookup: include paths from --global in --user search path too
This doesn't matter that much, because set-property --global does not work,
so at least those paths wouldn't be used automatically. It is still possible
to create such snippets manually, so we better fix this.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek c59479e790 path-lookup: fix confusion between persistent_control and persistent_config
persistent_config would not appear in the search path at all, hence
those overrides would not work at all.
2018-02-09 12:27:34 +01:00
Alan Jenkins 2428aaf8a2 seccomp: allow x86-64 syscalls on x32, used by the VDSO (fix #8060)
The VDSO provided by the kernel for x32, uses x86-64 syscalls instead of
x32 ones.

I think we can safely allow this; the set of x86-64 syscalls should be
very similar to the x32 ones.  The real point is not to allow *x86*
syscalls, because some of those are inconveniently multiplexed and we're
apparently not able to block the specific actions we want to.
2018-02-02 18:12:34 +00:00
Alan Jenkins 5c19ff79de seccomp-util: fix alarming debug message (#8002, #8001)
Booting with `systemd.log_level=debug` and looking in `dmesg -u` showed
messages like this:

    systemd[433]: Failed to add rule for system call n/a() / 156, ignoring:
    Numerical argument out of domain

This commit fixes it to:

    systemd[449]: Failed to add rule for system call _sysctl() / 156,
    ignoring: Numerical argument out of domain

Some of the messages could be even more misleading, e.g. we were reporting
that utimensat() / 320 was skipped as non-existent on x86, when actually
the syscall number 320 is kexec_file_load() on x86 .

The problem was that syscall NRs are looked up (and correctly passed to
libseccomp) as native syscall NRs.  But we forgot that when we tried to
go back from the syscall NR to the name.

I think the natural way to write this would be
seccomp_syscall_resolve_num(nr), however there is no such function.
I couldn't work out a short comment that would make this clearer.  FWIW
I wrote it up as a ticket for libseccomp instead.
https://github.com/seccomp/libseccomp/issues/104
2018-01-31 17:20:14 +00:00
Lennart Poettering 7755083256
Merge pull request #7881 from keszybz/pcre
Add new --grep option to journalctl
2018-01-28 15:29:10 +01:00
Zbigniew Jędrzejewski-Szmek b4766d5f15 journalctl: add highlighting for matched substring
Red is used for highligting, the same as grep does. Except when the line is
highlighted red already, because it has high priority, in which case plain ansi
highlight is used for the matched substring.

Coloring is implemented for short and cat outputs, and not for other types.
I guess we could also add it for verbose output in the future.
2018-01-28 14:50:01 +01:00
Yu Watanabe 68a4b89ca3 bus-util: fix format of NextElapseUSecRealtime= and LastTriggerUSec=
Before this, `systemctl show` for calendar type timer unit outputs
something like below.
```
NextElapseUSecRealtime=48y 3w 3d 15h
NextElapseUSecMonotonic=0
LastTriggerUSec=48y 3w 3d 3h 41min 44.093095s
LastTriggerUSecMonotonic=0
```
As both NextElapseUSecRealtime= and LastTriggerUSec= are not timespan
but timestamp, this makes format these values by `format_timestamp()`.
2018-01-25 14:49:24 +01:00
Nicolas Chauvet a3a3b6131e gpt-auto: discard boot0/1 hw partitions along rpmb
/dev/mmcblk0boot0 is a partition found in eMMC
This is not relevant for mounting

This complement the previous fix as reported in
https://github.com/systemd/systemd/issues/5806

Signed-off-by: Nicolas Chauvet <kwizart@gmail.com>
2018-01-25 14:25:27 +01:00
Lennart Poettering db4a47e9fe coccinelle: O_NDELAY → O_NONBLOCK
Apparently O_NONBLOCK is the modern name used in most documentation and
for most cases in our sources. Let's hence replace the old alias
O_NDELAY and stick to O_NONBLOCK everywhere.
2018-01-24 11:09:29 +01:00
Lennart Poettering 81b1dc271f coccinelle: let's use STRLEN() rather strlen() at one more place 2018-01-24 11:07:47 +01:00
Lennart Poettering 8a44b0b849
Merge pull request #7834 from jkloetzke/disable-watchdog
core: add "disable watchdog " function
2018-01-23 15:58:17 +01:00
Armin Widegreen 4f5e172341 journal: Fix journal dumping for json, cat and export output
Incorporating the fix from d00f1d57 into other output formats of journalctl.

If journal files are corrupted, e.g. not cleanly closed, some journal
entries can not be read by output options other than 'short' (default).
If such entries has been identified, they will now just be skipped.
2018-01-22 18:08:52 +01:00
Jan Klötzke 43ce15ac30 bus-util: add bool property setter 2018-01-22 18:06:56 +01:00
Yu Watanabe 5caf49360b efivars: include errno.h when EFI support is disabled (#7900)
Fixes #7898.
2018-01-17 20:25:42 +11:00
Lennart Poettering dccca82b1a log: minimize includes in log.h
log.h really should only include the bare minimum of other headers, as
it is really pulled into pretty much everything else and already in
itself one of the most basic pieces of code we have.

Let's hence drop inclusion of:

1. sd-id128.h because it's entirely unneeded in current log.h
2. errno.h, dito.
3. sys/signalfd.h which we can replace by a simple struct forward
   declaration
4. process-util.h which was needed for getpid_cached() which we now hide
   in a funciton log_emergency_level() instead, which nicely abstracts
   the details away.
5. sys/socket.h which was needed for struct iovec, but a simple struct
   forward declaration suffices for that too.

Ultimately this actually makes our source tree larger (since users of
the functionality above must now include it themselves, log.h won't do
that for them), but I think it helps to untangle our web of includes a
tiny bit.

(Background: I'd like to isolate the generic bits of src/basic/ enough
so that we can do a git submodule import into casync for it)
2018-01-11 14:44:31 +01:00
Lennart Poettering ad5d4b1703 cocci: use strempty() at more places
This shortens the code by a few lines.
2018-01-10 17:11:19 +01:00
Zbigniew Jędrzejewski-Szmek 2269954112 Merge pull request #7191 from Mic92/systemd
The change in netdev.c done in the merge is necessary to avoid crashing in
cleanup. This is a follow-up for f3c33b234d.
2018-01-09 14:35:54 +01:00
Jörg Thalheim e5719363f5 networkd: add support for wireguard interface type
More information may be found at wireguard.com.
2018-01-09 14:00:49 +01:00
Lennart Poettering d7afd945b5 networkd,resolved: make use of watch_bind feature to connect to the bus
The changes both networkd and resolved to make use of the watch_bind
feature of sd-bus to connect to the system bus. This way, both daemons
can be started during early boot, and automatically and instantly
connect to the system bus as it becomes available.

This replaces prior code that used a time-based retry logic to connect
to the bus.
2018-01-05 13:58:32 +01:00
Lennart Poettering 75152a4d6a tree-wide: install matches asynchronously
Let's remove a number of synchronization points from our service
startups: let's drop synchronous match installation, and let's opt for
asynchronous instead.

Also, let's use sd_bus_match_signal() instead of sd_bus_add_match()
where we can.
2018-01-05 13:58:32 +01:00
Lennart Poettering 665dfe9318 io-util: make flush_fd() return how many bytes where flushed
This is useful so that callers know whether anything at all and how much
was flushed.

This patches through users of this functions to ensure that the return
values > 0 which may be returned now are not propagated in public APIs.

Also, users that ignore the return value are changed to do so explicitly
now.
2018-01-05 13:55:08 +01:00
John Lin 7c59ab4ba1 install: search preset files in /run (#7715)
According to systemd.preset(5), presets files in /run should take
effect. However, before this patch, preset files in /run were
ignored.
2018-01-05 13:15:42 +01:00
Lennart Poettering 3e641e361d sd-bus: port one use of SO_PEERCRED by getpeercred() 2018-01-04 13:28:24 +01:00
Lennart Poettering be39f6ee31 process-util: add new FORK_NEW_MOUNTNS flag to safe_fork()
That way we can move one more code location to use safe_fork()
2018-01-04 13:27:27 +01:00
Lennart Poettering 3f60395254 pager: let's move static variables up, to the rest of them
let's keep static variables together, and before the function
definitions.
2018-01-04 13:27:27 +01:00
Lennart Poettering 85afeae88c pager,agent: insist that we are called from the main thread
We maintain static process-wide variables in these subsystems without
locking, hence let's refuse operation unless we are called from the main
thread (which we do anyway) just as a safety precaution.
2018-01-04 13:27:27 +01:00
Lennart Poettering 2e87a1fde9 tree-wide: make use of wait_for_terminate_and_check() at various places
Using wait_for_terminate_and_check() instead of wait_for_terminate()
let's us simplify, shorten and unify the return value checking and
logging of waitid().  Hence, let's use it all over the place.
2018-01-04 13:27:27 +01:00
Lennart Poettering b6e1fff13d process-util: add another fork_safe() flag for enabling LOG_ERR/LOG_WARN logging 2018-01-04 13:27:26 +01:00
Lennart Poettering fb92330ccc
Merge pull request #7759 from yuwata/dbus-api
DBus-API: add more options in transient units
2018-01-03 18:41:32 +01:00
Lennart Poettering 7f9ac71c76
Merge pull request #7705 from keszybz/redo-linking
Redo linking
2018-01-03 18:37:00 +01:00
Zbigniew Jędrzejewski-Szmek 5e3cec87be meson: use a convenience lib for journal user sources
Instead of compiling those files twice, once for libsystemd and once for
libshared, compile once as a static archive and then link into both.
This reduce the meson target for man=no compile to 1291.
2018-01-03 12:09:46 +01:00
Zbigniew Jędrzejewski-Szmek a8e559d4c6 meson: link libsystemd_static in libshared instead of recompiling
This is similar to the great-grandpa commit. This time the number
of meson targets compilation without man is reduced from 1347 to 1302.
2018-01-03 12:09:46 +01:00
Zbigniew Jędrzejewski-Szmek 34e221a58b Move gcrypt-util to basic/
We were including gcrypt-util.[ch] by hand in the few places where it
was used. Create a convenience library to avoid compiling the same
files multiple times.

v2:
- use a separate static library instead of mergin into libbasic
2018-01-03 12:09:45 +01:00
Zbigniew Jędrzejewski-Szmek 2d4ceca8a5 meson: link libbasic and libshared_static into libshared
gcrypt_util_sources had to be moved because otherwise they appeared twice
in libshared.so halfproducts, causing an error.

-fvisibility=default is added to libbasic, libshared_static so that the symbols
appear properly in the exported symbol list in libshared.

The advantage is that files are not compiled twice. When configured with -Dman=false,
the ninja target list is reduced from 1588 to 1347 targets. The difference in compilation
time is small (<10%). I think this is because of -O0 and ccache and multiple cores, and
in different settings the compilation time could be reduced. The main advantage is that
errors and warnings are not reported twice.
2018-01-03 12:09:14 +01:00
Yu Watanabe 3d63c7495a bus-unit-util: support more options set to transient unit 2018-01-03 02:32:46 +09:00
Yu Watanabe 0cf6628e54 bus-unit-util: use struct __useless_struct_to_allow_trailing_semicolon__ in DEFINE_BUS_APPEND_PARSE{,_PTR} macro 2018-01-03 02:32:36 +09:00
Yu Watanabe 83606b73f6 nsflags: add namespace_flag_to_string_many_with_check()
The function will be used in later commits.
2018-01-02 02:23:43 +09:00
Yu Watanabe d8f37c89a2 condition: introduce condition_takes_path()
The function will be used in later commits.
2018-01-02 02:23:26 +09:00
Mike Gilbert 521251d275 sysctl: use raw file descriptor in sysctl_write (#7753)
The kernel returns specific error codes which may be lost if we use the
libc buffered io functions.

Fixes: https://github.com/systemd/systemd/issues/7744
2017-12-30 12:16:49 +01:00
Lennart Poettering 68c58c67b5 condition: extend ConditionKernelVersion= with relative version checks
Now that we have str_verscmp() in our source tree anyway, let's make it
generic and reuse it for ConditionKernelVersion=.
2017-12-26 17:43:29 +01:00