1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00
Commit Graph

30950 Commits

Author SHA1 Message Date
Lennart Poettering
fbc5883523 path-lookup: LookupPathsFlags are a flags type, hence define it like one
We shouldn't rely on C's incremental assignment of values of enums for
bit fields. That'll work only between the first two flags, but for
everything following will break horrible. Hence, let's avoid any
ambiguity here, and let's clearly define the flags as shifts of 1.
2017-11-29 12:34:12 +01:00
Lennart Poettering
e9f4aabd80 systemctl: reword "needs-reload" message a bit
This message is displayed either when the unit file itself is newer than
what is loaded, but also when any of the drop-ins is newer. Say so in
the message, in order not to confuse the user unnecessarily.
2017-11-29 12:34:12 +01:00
Lennart Poettering
721060d446 core: allow changing the description for units dynamically at runtime
This makes "systemctl set-property foobar.service Description=waldo"
work.

See: #7245
2017-11-29 12:34:12 +01:00
Lennart Poettering
e74f76ca86 tree-wide: generate SD_BUS_ERROR_INVALID_ARGS when we get invalid arguments on bus calls
Let's make sure that when we return a D-Bus error, we return a native
one, if we generate it ourselves, and use errno-based error
synthetization only if we received an errno ourselves. Yes, this makes
things slightly longer, but is highly misleading as we propagate D-Bus
errors, and not errnos to the client.
2017-11-29 12:34:12 +01:00
Lennart Poettering
2e59b241ca core: add proper escaping to writing of drop-ins/transient unit files
This majorly refactors the transient unit file and drop-in writing
logic, so that we properly C-escape and specifier-escape (% → %%)
everything we write out, so that when we read it back again, specifiers
are parsed that aren't supposed to be parsed.

This renames unit_write_drop_in() and friends by unit_write_setting().
The name change is supposed to clarify that the functions are not only
used to write drop-in files, but also transient unit files.

The previous "mode" parameter to this function is replaced by a more
generic "flags", which knows additional flags for implicit C-style and
specifier escaping before writing things out. This can cover most
properties where either form of escaping is defined. For the cases where
this isn't sufficient, we add helpers unit_escape_setting() and
unit_concat_strv() for escaping individual strings or strvs properly.

While we are at it, we also prettify generation of transient unit files:
we try to reduce the number of section headers written out: previously
we'd write the right section header our for each setting. With this
change we do so only if the setting lives in a different section than
the one before.

(This should also be considered preparation for when we add proper APIs
to systemd to write normal, persistant unit files through the bus API)
2017-11-29 12:34:12 +01:00
Lennart Poettering
ddd59d0c7f logind: fix sysfs change trigger code
We can't create files in sysfs, hence don't bother. Also if we ignore
the return value, do so explicitly by casting to void.
2017-11-29 12:32:57 +01:00
Lennart Poettering
98bad05e75 generators: be more careful when writing unit settings that support specifier expansion
Let's always escape strings we receive from the user before writing them
out to unit file settings that suppor specifier expansion, so that user
strings are transported as-is.
2017-11-29 12:32:57 +01:00
Lennart Poettering
b238be1e0d core: enable specifier expansion for What=/Where=/Type=/SourcePath= too
Using specifiers in these settings isn't particularly useful by itself,
but it unifies behaviour a bit. It's kinda surprising that What= in
mount units resolves specifies, but Where= does not. Hence let's add
that too. Also, it's surprising Where=/What= in mount units behaves
differently than in automount and swap units, hence resolve specifiers
there too. Then, Type= in mount units is nowadays an arbitrary,
sometimes non-trivial string (think fuse!), hence let's also expand
specifiers there, to match the rest of the mount settings.

This has the benefit that when writing code that generates unit files,
less care has to be taken to check whether escaping of specifiers is
necessary or not: broadly everything that takes arbitrary user strings
now does specifier expansion, while enums/numerics/booleans do not.
2017-11-29 12:32:57 +01:00
Lennart Poettering
6c5def2ff2 core: process C-style escapes in UnsetEnvironment=
We process C-style escapes in Environment=, hence we should process it
in UnsetEnvironment= too, as the latter accepts assignments much like
the former, including arbitrary values specified by the user.
2017-11-29 12:32:56 +01:00
Lennart Poettering
613613f1ee core: use config_parse_unit_string_printf() for decoding RebootArgument=
All other cases where we accept a reboot argument are decoded with
config_parse_unit_string_printf() rather than
config_parse_unit_path_printf(), and that's really the only thing what
makes sense here, hence adjust this here, too.
2017-11-29 12:32:56 +01:00
Lennart Poettering
35838def32 CODING_STYLE: document the order in which unescaping + specifier expansion should be done 2017-11-29 12:32:56 +01:00
Lennart Poettering
36444d2213 specifier: unify specifier implementations for user-related specifiers
The code in install-printf.c and unit-printf.c for these is pretty much
the same and very generic. Let's move this all over to the generic
specifier.c, and share the implementations.
2017-11-29 12:32:56 +01:00
Lennart Poettering
e82f30d17f specifier: add helper for escaping '%' characters to avoid making them subject for expansion
This is ultimately just a wrapper around strreplace(), but it makes
things a bit more self-descriptive.
2017-11-29 12:32:56 +01:00
Lennart Poettering
9d73565ac0 string-util: update strreplace() a bit, use GREEDY_REALLOC() 2017-11-29 12:32:56 +01:00
Lennart Poettering
6171b8225f core: drop specifier expansion when parsing transient dbus properties
Specifier expansion (much like C escape handling) should be a helper for
writing unit files, but should be nothing we do on programatic APIs. For
those, the client can do the necessary replacements anyway, and we
really should be careful with doing such string processing of data we
get via lower level programmatic APIs.

We currently do specifier expansion only for the env var transient unit
APIs, no other properties do this. Let's remove it here too, to be fully
systematic.

Yes, in a way this is API breakage, but then again this API isn't
documented yet, and an outlier, hence let's clear this up now, before it
is too late.
2017-11-29 12:32:53 +01:00
Yu Watanabe
3235b4e70c
Merge pull request #7492 from keszybz/coverity-fixes
A few more cleanups based on coverity and valgrind
2017-11-29 12:50:49 +09:00
Zbigniew Jędrzejewski-Szmek
ae34a10bac udev/collect: use _cleanup_ in one more place
This doesn't make the code pretty, but it at least makes it a tiny bit shorter.
2017-11-28 21:34:50 +01:00
Zbigniew Jędrzejewski-Szmek
3176084ff2 udev/collect: remove dead conditional
Coverity rightly says that 'word' is assigned to 'ptr', and 'word'
was assigned from 'ptr' (yikes) right after a non-null check.
2017-11-28 21:34:50 +01:00
Zbigniew Jędrzejewski-Szmek
2504834861 journal: avoid undefined behaviour in float division by 0.0
Coverity says that's undefined. I'm pretty sure we always would get a nan, but
let's avoid (formally) undefined behaviour since that can cause compilers to do
strange things.
2017-11-28 21:34:50 +01:00
Zbigniew Jędrzejewski-Szmek
b921fcb2ac networkd: fix memleak of Rules
This was the issue mentioned in 93f9da6e0a.
2017-11-28 21:34:50 +01:00
Zbigniew Jędrzejewski-Szmek
f916819053 journal: use new helpers with journal_file_close
journal_file_close_set() is not necessary anymore.
2017-11-28 21:34:50 +01:00
Zbigniew Jędrzejewski-Szmek
1599f593d6 journal-remote: add helper function and use hashmap_free_with_destructor 2017-11-28 21:34:46 +01:00
Zbigniew Jędrzejewski-Szmek
6dd1c36839 cryptsetup-generator: add helper function and use hashmap_free_with_destructor 2017-11-28 21:34:41 +01:00
Zbigniew Jędrzejewski-Szmek
39ab16e397 coredump: fix typo and use hashmap_free_with_destructor 2017-11-28 21:34:34 +01:00
Zbigniew Jędrzejewski-Szmek
e85b096b43 machine-image: convert image_hashmap_free() to an static inline helper 2017-11-28 21:30:43 +01:00
Zbigniew Jędrzejewski-Szmek
224b0e7ad0 Add set/hashmap helpers for non-trivial freeing and use where straighforward
A macro is needed because otherwise we couldn't ensure type safety.
Some simple tests are included.
No functional change intended.
2017-11-28 21:30:30 +01:00
Zbigniew Jędrzejewski-Szmek
ec1d290903 Use hashmap_free_free where appropriate 2017-11-28 21:26:37 +01:00
Zbigniew Jędrzejewski-Szmek
5c4912ea61
Merge pull request #7490 from yuwata/test-basic
add more tests for basic functions
2017-11-28 18:15:30 +01:00
Susant Sahani
fbdb6605b5 networkd: Add comment for setting_mtu #7460 (#7489)
Follow up #7460
2017-11-28 17:24:52 +01:00
Lennart Poettering
4de8d3f59e
Merge pull request #7486 from keszybz/coverity-fixes
Fixes for issues spotted by coverity (and some cleanups)
2017-11-28 15:04:11 +01:00
Yu Watanabe
23cc81e7c2 test-cap-list: add more tests about capability_set_{from,to}_string() 2017-11-28 22:17:00 +09:00
Yu Watanabe
4c1a95fd84 test: move tests about cap_list_cap() from test-cap-list to test-capability 2017-11-28 22:14:54 +09:00
Yu Watanabe
db4bd5bd62 cap-list: check range of numeric value 2017-11-28 22:06:34 +09:00
Yu Watanabe
6b86b9e65d test-bitmap: add tests for bitmap_copy() 2017-11-28 20:34:36 +09:00
Yu Watanabe
ade0eb2190 test-architecture: add more tests 2017-11-28 20:34:32 +09:00
Yu Watanabe
f30788ee23 test-alloc-util: add tests for memdup_suffix0() and greedy_realloc() 2017-11-28 20:33:58 +09:00
Yu Watanabe
a4e6e06bc7 tests: add tests for empty string 2017-11-28 20:21:25 +09:00
Yu Watanabe
d40c54fe56 alloc-util: coding style fix 2017-11-28 20:21:15 +09:00
Lennart Poettering
b39367a1a7
Merge pull request #7398 from keszybz/udev-list
udev: use list.h instead of udev_list_node
2017-11-28 11:35:02 +01:00
Lennart Poettering
c9f034a10a
Merge pull request #7484 from poettering/sd-resolve-timeout
timeout sd-resolve tests
2017-11-28 11:33:38 +01:00
Zbigniew Jędrzejewski-Szmek
ba77dac291 pid1: improve syntax in error message 2017-11-28 09:26:14 +01:00
Zbigniew Jędrzejewski-Szmek
d387cfdddd pid1: clarify that min_max is always initialized
read_one_line_file() always returns <= 0, so the code was OK, but let's write
the check a bit differently to make it obvious that min_max is always set.
2017-11-28 09:26:14 +01:00
Zbigniew Jędrzejewski-Szmek
7beb3baf16 test-hostname-util: add assert_se's to make coverity happy 2017-11-28 09:26:14 +01:00
Zbigniew Jędrzejewski-Szmek
c47a9f909a test-process-util: add (void) cast to make coverity happy
The intent is for the call to succeed only when privileged, so make
that clear.
2017-11-28 09:25:39 +01:00
Zbigniew Jędrzejewski-Szmek
ca9b2b4dc1 test-fd-util: add assert_se to make coverity happy 2017-11-28 09:25:39 +01:00
Zbigniew Jędrzejewski-Szmek
b0fe73d740 udevadm-monitor: add some assert_se's to make coverity happy
We do that elsewhere and it's nice to be consistent.
2017-11-28 09:25:38 +01:00
Zbigniew Jędrzejewski-Szmek
595c66a3db core/umount: use _cleanup_ in one more place 2017-11-28 09:25:38 +01:00
Zbigniew Jędrzejewski-Szmek
1a96c8e1cc sd-resolve: check that name fits in the specified packet length
Coverity complained that we didn't check if the data is long enough.
2017-11-28 09:25:38 +01:00
Zbigniew Jędrzejewski-Szmek
8d44f5a637 shim: fix logically dead code
The alternate verification path could never be taken.

Found by coverity.
2017-11-28 09:25:38 +01:00
Zbigniew Jędrzejewski-Szmek
1e40b7490a networkd: remove dead code
Found by coverity.
2017-11-28 09:25:38 +01:00