Commit graph

3790 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 2e2ed88062 pid1,systemctl: allow symbolic exit code names 2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek 62b21e2e89 shared/bus-util: fix dbus serialization of {RestartPrevent,RestartForce,Success}ExitStatus
We were passing 1/4th of the size in bytes as argument. So depending
on the size of the array, either we'd only transfer a subset of values,
or we'd get an alignment error.
2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek 32131a3aaa bus-util: convert bus_log_{parse,create}_error into defines
With SYSTEMD_LOG_LOCATION=1, it is much more useful to see the location
where the call to bus_log_{parse,create}_error() was made, rather then
the one-line body of the helper function. Also, it's our internal code,
so having a one-line non-inline function doesn't make much sense anyway.
2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek 23d5dd1687 shared/exit-status: use Bitmap instead of Sets
I opted to embed the Bitmap structure directly in the ExitStatusSet.
This means that memory usage is a bit higher for units which don't define
this setting:

Service changes:
        /* size: 2720, cachelines: 43, members: 73 */
        /* sum members: 2680, holes: 9, sum holes: 39 */
        /* sum bitfield members: 7 bits, bit holes: 1, sum bit holes: 1 bits */
        /* last cacheline: 32 bytes */

        /* size: 2816, cachelines: 44, members: 73 */
        /* sum members: 2776, holes: 9, sum holes: 39 */
        /* sum bitfield members: 7 bits, bit holes: 1, sum bit holes: 1 bits */

But this way the code is simpler and we do less pointer chasing.
2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek 8594c8a552 shared/bitmap: constify various operators which don't modify bitmap 2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek f0d67dcddd shared/exit-status: add exit_status_from_string() 2019-07-29 15:54:53 +02:00
Zbigniew Jędrzejewski-Szmek e1714f0250 shared/exit-status: turn status level into a bitmask, add "test"
The "test" doesn't really test much automatically, but it is still useful
to look at the mappings.
2019-07-29 15:54:45 +02:00
Lennart Poettering c242a08279 efivars: modernize efi_get_variable() a bit
Primarily, make sure the return parameters are all individually
optional.
2019-07-25 17:10:51 +02:00
Lennart Poettering dfadc1f203 meson: reorder alphabetically 2019-07-24 09:07:33 +02:00
Lennart Poettering d1b014df9e local-addresses: filter out any routing tables but the main one
Fixes: #13132
2019-07-24 09:07:30 +02:00
Lennart Poettering 733cbd00b0 netlink: move local-addresses.[ch] to src/shared
This code is not part of the public API of sd-netlink, nor used by it
internally and hence should not be in the sd-netlink directory.

Also, move the test case for it to src/test/.
2019-07-24 09:06:50 +02:00
Zbigniew Jędrzejewski-Szmek afaae43bb1 timedated: add back support for ntp-units.d/
We removed support for foreign services (and ntp-units.d/) in b72ddf0f4.
Support for foreign services was added back in 5d280742, but through an
environment variable.

The problem with the env var approach is that it only works as a mechanism
to select one item, and doesn't work nicely as a mechinism to create a list
of items through drop-ins (because the env var can be easily overridden, but not
extended). Having a list of "ntp providers" is important to be able to reliably disable
all of them when that is requested.

Another problem is that nobody ever bothered to care about our new "standard".
ntp-units.d/ is a nice simple format that works and is already supported by
chrony and ntpd and timedatex. If we were to introduce and ask people to follow
a new standard, there should be some good reason for this. The idea with env
vars has lower functionality, requires systemd-specific syntax. We should just
re-adopt the format that we originally introduced and that seems to work for
everyone, and more on to more interesting problems.
2019-07-22 15:21:20 +02:00
Zbigniew Jędrzejewski-Szmek a505166845
Merge pull request #13096 from keszybz/unit-loading
Preparatory work for the unit loading rework
2019-07-19 21:47:10 +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 28f30f4051 shared/conf-parser: say "key name" not "lvalue", add dot
"lvalue" is our internal jargon. Let's try not to confuse non-programmers.
2019-07-18 11:39:40 +02:00
Zbigniew Jędrzejewski-Szmek 8be8ed8ce1 shared/conf-parser: emit a nicer warning for something like "======"
Urlich Windl wrote on the mailing list:
> I noticed that a line of "=======" in "[Service]" cases the message " Unknown lvalue '' in section 'Service'".

This now becomes:
/etc/systemd/system/eqeqeqeq.service:3: Missing key name before '=', ignoring line.
2019-07-18 11:39:38 +02:00
Zbigniew Jędrzejewski-Szmek 2d4fffb00b shared/conf-parser: be nice and ignore lines without "="
We generally don't treat syntax error as fatal, but in this case we would
completely refuse to load the file. I think we should treat the the same
as assignment outside of a section, or an unknown key name.
2019-07-18 11:39:25 +02:00
Lennart Poettering ea582a0f1b
Merge pull request #13047 from niedbalski/fix-5552-pr
resolved: add new option to only cache positive answers
2019-07-17 19:27:16 +02:00
Frantisek Sumsal c087dc0c35
Merge pull request #13093 from keszybz/two-assert-cc-cleanups
Two assert_cc cleanups
2019-07-17 15:53:35 +00:00
Jorge Niedbalski 37d7a7d984 resolved: switch cache option to a tri-state option (systemd#5552).
Change the resolved.conf Cache option to a tri-state "no, no-negative, yes" values.

If a lookup returns SERVFAIL systemd-resolved will cache the result for 30s (See 201d995),
however, there are several use cases on which this condition is not acceptable (See systemd#5552 comments)
and the only workaround would be to disable cache entirely or flush it , which isn't optimal.

This change adds the 'no-negative' option when set it avoids putting in cache
negative answers but still works the same heuristics for positive answers.

Signed-off-by: Jorge Niedbalski <jnr@metaklass.org>
2019-07-17 10:42:53 -04: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 76c887fdaa
Merge pull request #13092 from keszybz/coverity-fixes
Coverity fixes
2019-07-17 14:18:49 +02:00
Zbigniew Jędrzejewski-Szmek ab1a1ba5dc Drop trailing slash from assert_cc() definition
We use assert_cc(...); almost everywhere. Let's always require that.

https://github.com/systemd/systemd/issues/12997#issuecomment-510103988
2019-07-17 12:57:20 +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
Zbigniew Jędrzejewski-Szmek 8a07b4033e shared/conf-parser,networkd: EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE → EXTRACT_UNQUOTE
It's hard to even say what exactly this combination means. Escaping is
necessary when quoting to have quotes within the string. So the escaping of
quote characters is inherently tied to quoting. When unquoting, it seems
natural to remove escaping which was done for the quoting purposes. But with
both flags we would be expected to re-add this escaping after unqouting? Or
maybe keep the escaping which is not necessary for quoting but otherwise
present? This all seems too complicated, let's just forbid such usage and
always fully unescape when unquoting.
2019-07-17 11:35:04 +02:00
Zbigniew Jędrzejewski-Szmek 60b17d6fcd shared: fix assert call
Fixup for 3572d3df8f. Coverity CID#1403013.
2019-07-17 11:35:04 +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