Commit graph

3769 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 7d1e91d1a9 shared/unit-file: add a function to validate unit alias symlinks
It turns out most possible symlinks are invalid, because the type has to match,
and template units can only be linked to template units.

I'm not sure if the existing code made the same checks consistently. At least
I don't see the same rules expressed in a single place.
2019-07-30 13:51:21 +02:00
Zbigniew Jędrzejewski-Szmek e5369d1a8f shared/install: typo 2019-07-29 20:28:49 +02:00
Zbigniew Jędrzejewski-Szmek 5cfa33e0bc Create src/shared/unit-file.[ch] for unit-file related ops
So far we put such functinos in install.[ch], but that is tied too closely
to enable/disable. Let's start moving things to a place with a better name.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 47a0011186 shared/dropin: rename function for clarity
The caller looks for directories and is called "..._find_dirs()". Here, there
is no "finding" going on, so I found the old name confusing.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek f1b4b94cae shared/dropin: use TAKE_PTR in one more place 2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 3c4e303136 basic/set: constify operations which don't modify Set
No functional change, but it's nicer to the reader.
2019-07-19 16:51:14 +02:00
Zbigniew Jędrzejewski-Szmek 043fdc4010 pid1: kill unit_file_find_dropin_paths() helper
It had two users, but it is just a very thin wrapper around
unit_file_find_dropin_paths(), so using it seems more complicated than directly
invoking unit_file_find_dropin_paths() twice.
2019-07-17 14:27:23 +02:00
Lennart Poettering 52f4b5ac8a
Merge pull request #12675 from yuwata/network-set-dns
resolvectl: support to modify interfaces managed by networkd
2019-07-17 12:07:39 +02:00
Jakob Unterwurzacher d34a40082d mount-util: bind_remount: avoid calling statvfs
The commit
"util: Do not clear parent mount flags when setting up namespaces"
introduced a statvfs call read the flags of the original mount
and have them applied to the bind mount.

This has two problems:

(1) The mount flags returned by statvfs(2) do not match the flags
accepted by mount(2). For example, the value 4096 means ST_RELATIME
when returned by statvfs(2), but means MS_BIND when passed to mount(2).

(2) A call to statvfs blocks indefinitely when ran against a disconnected
network drive ( https://github.com/systemd/systemd/issues/12667 ).

We already use libmount to parse `/proc/self/mountinfo` but did not use the
mount flag information from there. This patch changes that to use the mount
flags parsed by libmount instead of calling statvfs. Only if getting the
flags through libmount fails we call statvfs.

Fixes https://github.com/systemd/systemd/issues/12667
2019-07-17 11:37:09 +02:00
Anita Zhang 31cd5f63ce core: ExecCondition= for services
Closes #10596
2019-07-17 11:35:02 +02:00
Yu Watanabe 00d28db322 resolve: expose dns_server_address_valid() 2019-07-17 06:59:12 +09:00
Lennart Poettering c1b71f3a61
Merge pull request #13074 from poettering/format-tree-many
table_add_many() improvements
2019-07-16 16:03:54 +02:00
Lennart Poettering 4119ad492f
Merge pull request #13073 from poettering/variety-galore
Variety galore
2019-07-16 15:59:31 +02:00
Zbigniew Jędrzejewski-Szmek 0f18289954
Merge pull request #13062 from yuwata/analyze-use-table
systemd-analyze: use Table
2019-07-16 13:28:34 +02:00
Lennart Poettering 6268974f88 format-table: add ability to set cell attributes within table_add_many()
table_add_many() is so much shorter and easier to read than
table_add_cell() with its accessors. Let's teach table_add_many() more
tricks, so that reverting to table_add_cell() is not needed that often
anymore.
2019-07-16 12:43:46 +02:00
Lennart Poettering dc0e9c9ba6 format-table: fix parameter name 2019-07-16 12:42:19 +02:00
Lennart Poettering 525e9b7991 shared: no need to check result of strndupa() 2019-07-16 12:40:22 +02:00
Lennart Poettering 9228fef0d6 tree-wide: use empty-to-root a bit more 2019-07-16 12:40:22 +02:00
Lennart Poettering f200a3564c
Merge pull request #13063 from keszybz/cgroup-path-fixes
Cgroup path fixes
2019-07-16 11:53:31 +02:00
Yu Watanabe 8cec0a5c32 tree-wide: drop duplicated blank lines
```
$ for i in */*.[ch] */*/*.[ch]; do sed -e '/^$/ {N; s/\n$//g}' -i $i; done
$ git checkout HEAD -- basic/linux shared/linux
```
2019-07-15 18:41:27 +02:00
Zbigniew Jędrzejewski-Szmek 107c20518b systemctl: emit warning when we get an invalid process entry from pid1 and continue
Output looks like this:
Invalid process description in GetUnitProcesses reply: cgroup="machine.slice/machine-rawhide.scope/payload/system.slice/systemd-journald.service" pid=638367 command="/usr/lib/systemd/systemd-journald", ignoring: Invalid argument
2019-07-15 18:39:05 +02:00
Yu Watanabe c5bbb2b5be format-table: add TABLE_TIMESTAMP_UTC and _RELATIVE 2019-07-16 00:44:14 +09:00
Yu Watanabe ba99f19c0d format-table: add TABLE_TIMESPAN_MSEC 2019-07-16 00:09:39 +09:00
Yu Watanabe f7f196adfa
Merge pull request #13037 from poettering/shutdown-log-fixes
Shutdown log fixes
2019-07-13 23:00:12 +09:00
Lennart Poettering 6a47f2a714 sysctl: add sysctl_writef() helper 2019-07-13 11:05:07 +02:00
Lennart Poettering 2caa38e99f tree-wide: some more [static] related fixes
let's add [static] where it was missing so far

Drop [static] on parameters that can be NULL.

Add an assert() around parameters that have [static] and can't be NULL
hence.

Add some "const" where it was forgotten.
2019-07-12 16:40:10 +02:00
Lennart Poettering 27dd6e1b12
Merge pull request #13022 from keszybz/coverity-cleanups
Coverity cleanups
2019-07-12 07:37:44 +02:00
Lennart Poettering b910cc72c0 tree-wide: get rid of strappend()
It's a special case of strjoin(), so no need to keep both. In particular
as typing strjoin() is even shoert than strappend().
2019-07-12 14:31:12 +09:00
Zbigniew Jędrzejewski-Szmek 8e9d1eece6 shared/ask-password-api: backspace all chars at once
We'd call loop_write() separately for each char. Let's be nice to
serial console users, and write the full string in one go.

Coverity was complaining that we're not checking the return value
from loop_write(). Rework the code a bit and add voidify.
CID#1402323.
2019-07-12 00:35:05 +02:00
Lennart Poettering 66855de739 tree-wide: make use of errno_or_else() everywhere 2019-07-11 23:20:31 +02:00
Lennart Poettering 10859c4902
Merge pull request #12176 from poettering/clean-dir2
add "systemctl clean" operation for clearing out StateDirectory=, CacheDirectory=, … of a service unit
2019-07-11 15:12:02 +02:00
Lennart Poettering 2eb1c19881 json: always allocate at least sizeof(JsonVariant) bytes
ubsan apparently doesn't like us being too smart here. Given the
difference is just a few bytes, let's avoid the noise.

Fixes: #13020
2019-07-11 15:10:33 +02:00
Lennart Poettering 3572d3df8f shared: add generic logic for waiting for a unit to enter some state
This is a generic implementation of a client-side logic of waiting until
a unit enters or leaves some state.

This is a more generic implementation of the WaitContext logic currently
in systemctl.c, and is supposed to replace it (a later commit does
this). It's similar to bus-wait-for-jobs.c and we probably should fold
that one into it later on.

This code is more powerful and cleaner than the WaitContext logic
however. In addition to waiting for a unit to exit this also allows us
to wait for a unit to leave the "maintainance" state.

This commit only implements the generic logic, and adds no users of it
yet.
2019-07-11 12:18:51 +02:00
Yu Watanabe bb08b2a940
Merge pull request #13010 from poettering/fsck-usr-wants
generator: downgrade Requires= → Wants= of fsck from /usr mount unit
2019-07-11 15:13:51 +09:00
Lennart Poettering 08945b59d1
Merge pull request #12926 from keszybz/urlify-logs
Urlify CONFIG_FILE and improve SYSTEMD_LOG_LOCATION
2019-07-11 00:00:34 +02:00
Lennart Poettering bdd0f4b6d1
Merge pull request #13009 from keszybz/efi-feature-xbootldr
sd-boot feature xbootldr
2019-07-11 00:00:12 +02:00
Lennart Poettering 6f209cb01d
Merge pull request #12965 from keszybz/auto-erase
_cleanup_(erase_and_freep)
2019-07-10 16:20:50 +02:00
Lennart Poettering a082157282
Merge pull request #13005 from keszybz/fix-gcc-warning
Fix two gcc warnings
2019-07-10 16:20:31 +02:00
Lennart Poettering afacf3fc8a generator: downgrade Requires= → Wants= of fsck from /usr mount unit
Fixes #5099
2019-07-10 16:19:31 +02:00
Lennart Poettering cbdc9cfe2b core: spaces rock 2019-07-10 16:19:31 +02:00
Zbigniew Jędrzejewski-Szmek 91b08bb00f boot,shared: share the definitions of EFI_LOADER_FEATURE macros
This means the the code needs to be kept compatible in the shared header,
but I think that still nicer than having two places to declare the same
things.

I added src/boot to -I, so that efi/foo.h needs to be used. This reduces
the potential for accidentally including the wrong header.
2019-07-10 14:59:48 +02:00
Lennart Poettering ba40f0399e
Merge pull request #12939 from yuwata/lgtm-fixes
make LGTM quiet
2019-07-10 14:57:14 +02:00
Zbigniew Jędrzejewski-Szmek 79dc477f2f shared/logs-show: urlify CONFIG_FILE in verbose mode
Now all short-*, verbose, with-unit modes are handled. cat, export, json-* are
not, but those are usually used for post-processing, so I don't think it'd be
useful there.
2019-07-10 14:20:09 +02:00
Zbigniew Jędrzejewski-Szmek 76f7cc3fe4 shared/logs-show: urlify CONFIG_FILE in short mode
v2:
- check that the filename is terminated by ':', ' ', or EOS
- fix grep highlight overlap check
2019-07-10 14:19:26 +02:00
Zbigniew Jędrzejewski-Szmek e693a93235 Use _cleanup(free_and_erasep) where appropriate
Replaces #12959.
2019-07-10 11:39:03 +02:00
Zbigniew Jędrzejewski-Szmek 706fb34851 shared/dm-util: use strncpy_exact() to silence gcc
With gcc-9.1.1-2.fc31.x86_64 and -Doptimization=2:
../src/shared/dm-util.c: In function ‘dm_deferred_remove’:
../src/shared/dm-util.c:35:9: warning: ‘strncpy’ specified bound 128 equals destination size [-Wstringop-truncation]
   35 |         strncpy(dm.name, name, sizeof(dm.name));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

gcc is plain wrong here, because we checked strlen(name) a few lines above, so
there can be no truncation and even the terminator always fits. But let's avoid
the warning.
2019-07-10 10:32:39 +02:00
Zbigniew Jędrzejewski-Szmek 6490a017e2
Merge pull request #12964 from yuwata/network-bridge-vlan-issue-12958
network: fix BridgeVLAN issue
2019-07-05 13:58:21 +02:00
Yu Watanabe fb721f084c network: re-implement parse_vid_range() 2019-07-05 16:35:06 +09:00
Lennart Poettering 7e69d90c8d varlink: add varlink server to event loop only if there is one 2019-07-04 22:53:49 +02:00
Yu Watanabe d14be488a7 firewall-util: use fixed size array for chain name
xt_chainlabel is defined as
```
typedef char xt_chainlabel[32];
```
2019-07-05 02:45:00 +09:00