Commit Graph

158 Commits

Author SHA1 Message Date
Tobias Hunger 129635333d repart: Add UUID option to config files
Add a option to provide a UUID for the partition that will get
created and document that.
2020-05-25 15:48:59 +02:00
Rubens Figueiredo 4df4df5b56 network: allow setting VLAN protocol on bridges
Signed-off-by: Rubens Figueiredo <rubens.figueiredo@bisdn.de>
2020-05-14 17:59:57 +02:00
Lennart Poettering 14f594b995 fileio: fileno() can realistically return -1
An stdio FILE* stream usually refers to something with a file
descriptor, but that's just "usually". It doesn't have to, when taking
fmemopen() and similar into account. Most of our calls to fileno()
assumed the call couldn't fail. In most cases this was correct, but in
some cases where we didn't know whether we work on files or memory we'd
use the returned fd as if it was unconditionally valid while it wasn't,
and passed it to a multitude of kernel syscalls. Let's fix that, and do
something reasonably smart when encountering this case.

(Running test-fileio with this patch applied will remove tons of ioctl()
calls on -1).
2020-04-13 11:26:49 +02:00
Yu Watanabe 68c1ac1568 conf-parser: fix line number in error message
Fixes #14929.
2020-02-28 02:37:15 +09:00
Zbigniew Jędrzejewski-Szmek 5e176a4dee Merge pull request #14368 from poettering/repart 2020-01-23 19:07:02 +01:00
Yu Watanabe 5029912157 network,udev: use uint64_t for bit rate
Fixes #14620.
2020-01-21 16:51:19 +01:00
Lennart Poettering b57ebc6004 conf-parser: add parser for 32bit signed integers 2020-01-20 17:42:03 +01:00
Yu Watanabe a5053a158b udev: support AlternativeName= setting in .link file 2019-12-16 10:52:22 +09:00
Zbigniew Jędrzejewski-Szmek ddeb3f5d4b shared/conf-parser: allow sections to be silently ignored with new -Section syntax
If we ignore any uknown section, we will not be able to show any
warning if a typo in a section name is made. Let's reverse our
approach, and explicitly list sections to ignore instead.

I opted to make use the same section list for this, instead of adding a second
list, because this list is passed through to many functions and adding yet
another parameter to the long signature would be very noisy.
2019-11-22 15:27:22 +01:00
Zbigniew Jędrzejewski-Szmek f9761a89a8 shared/conf-parser: turn CONFIG_PARSE_REFUSE_BOM flag into a local variable
This is an internal implementation detail.
2019-11-22 13:11:35 +01:00
Yu Watanabe 455fa9610c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
Yu Watanabe f5947a5e92 tree-wide: drop missing.h 2019-10-31 17:57:03 +09:00
Zbigniew Jędrzejewski-Szmek adfafd88b2 Revert "shared/conf-parser,networkd: EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE → EXTRACT_UNQUOTE"
This reverts commit 8a07b4033e.
The tests are kept. test-networkd-conf is adjusted to pass.

This fixes #13276. I think current rules are extremely confusing, as the
case in test-networkd-conf shows. We apply some kinds of unescaping (relating
to quoting), but not others (related to escaping of special characters).
But fixing this is hard, because people have adjusted quoting to match
our rules, and if we make the rules "better", things might break in unexpected
places.
2019-08-19 09:54:06 +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
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 4ec8514142 Rename EXTRACT_QUOTES to EXTRACT_UNQUOTE
Whenever I see EXTRACT_QUOTES, I'm always confused whether it means to
leave the quotes in or to take them out. Let's say "unquote", like we
say "cunescape".
2019-06-28 11:35:05 +02:00
Yu Watanabe 0ef69585d8 conf-parser: fix continuation handling
Before this commit, empty lines cannot break continuation.
The bug was introduced by 9adbfeb38a.

Closes #12883.
2019-06-27 03:00:26 +09:00
Lennart Poettering d8b4d14df4 util: split out nulstr related stuff to nulstr-util.[ch] 2019-03-14 13:25:52 +01:00
Filipe Brandenburger 7b61ce3c44 time-util: Introduce parse_sec_def_infinity
This works like parse_sec() but defaults to USEC_INFINITY when passed an
empty string or only whitespace.

Also introduce config_parse_sec_def_infinity, which can be used to parse
config options using this function.

This is useful for time options that use "infinity" for default and that
can be reset by unsetting them.

Introduce a test case to ensure it works as expected.
2019-02-14 11:04:42 -08:00
Yu Watanabe b41dd0d2db conf-parser: accept whitespaces before comments
Closes #11343.
2019-01-08 14:05:15 +09:00
Yu Watanabe 71b21730d4 conf-parser: mention that unknown lvalue is ignored 2019-01-08 12:50:58 +09:00
Yu Watanabe ef118d00eb util: drop missing.h from socket-util.h 2018-12-06 13:31:16 +01:00
Lennart Poettering 4472fa6d2c conf-parse: use strjoina() where appropriate 2018-11-17 08:47:27 +01:00
Lennart Poettering 143fadf369 core: remove JoinControllers= configuration setting
This removes the ability to configure which cgroup controllers to mount
together. Instead, we'll now hardcode that "cpu" and "cpuacct" are
mounted together as well as "net_cls" and "net_prio".

The concept of mounting controllers together has no future as it does
not exist to cgroupsv2. Moreover, the current logic is systematically
broken, as revealed by the discussions in #10507. Also, we surveyed Red
Hat customers and couldn't find a single user of the concept (which
isn't particularly surprising, as it is broken...)

This reduced the (already way too complex) cgroup handling for us, since
we now know whenever we make a change to a cgroup for one controller to
which other controllers it applies.
2018-11-16 14:54:13 +01:00
Yu Watanabe 9adbfeb38a conf-parser: ignore trailing back-slash in comment
Fixes #10598.
2018-11-08 18:09:04 +09:00
Lennart Poettering bea1a01310 strv: wrap strv_new() in a macro so that NULL sentinel is implicit 2018-10-31 18:00:52 +01:00
Yu Watanabe 1e5f4e8ba2 conf-parser,login: logs description of error in parsing size 2018-07-03 15:18:04 +02:00
Lennart Poettering 0c69794138 tree-wide: remove Lennart's copyright lines
These lines are generally out-of-date, incomplete and unnecessary. With
SPDX and git repository much more accurate and fine grained information
about licensing and authorship is available, hence let's drop the
per-file copyright notice. Of course, removing copyright lines of others
is problematic, hence this commit only removes my own lines and leaves
all others untouched. It might be nicer if sooner or later those could
go away too, making git the only and accurate source of authorship
information.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek 5d904a6aaa tree-wide: drop !! casts to booleans
They are not needed, because anything that is non-zero is converted
to true.

C11:
> 6.3.1.2: When any scalar value is converted to _Bool, the result is 0 if the
> value compares equal to 0; otherwise, the result is 1.

https://stackoverflow.com/questions/31551888/casting-int-to-bool-in-c-c
2018-06-13 10:52:40 +02:00
Yu Watanabe 8e7b5bd047 conf-parser: simplify conf_parse_path()
Follow-up for 97651797e83d0548aef9f808657d3518d89e5aee.
2018-06-13 13:50:35 +09:00
Marc Kleine-Budde c07b23ca7e conf-parser: add config_parse_permille() 2018-06-09 15:12:31 +02:00
Lennart Poettering b8b846d7b4 tree-wide: fix a number of log calls that use %m but have no errno set
This is mostly fall-out from d1a1f0aaf0,
however some cases are older bugs.

There might be more issues lurking, this was a simple grep for "%m"
across the tree, with all lines removed that mention "errno" at all.
2018-06-07 15:29:17 +02:00
Yu Watanabe c0d72c4313 conf-parser: fix memleak (#9177)
Fixes CID#1391437.

Closes #9180.
2018-06-04 15:18:28 +03:00
Yu Watanabe f106314c89 conf-parser: remove redundant utf8-validity check 2018-06-04 01:38:54 +09:00
Yu Watanabe 97b9c506cf conf-parse: use free_and_replace()
Also removes unnecessary empty lines.
2018-06-04 00:30:42 +09:00
Yu Watanabe 78d17fa099 conf-parser: reject utf8-invalid lines 2018-06-04 00:30:18 +09:00
Yu Watanabe cd4f53c5b5 conf-parse: use path_simplify_and_warn() in config_parse_path() 2018-06-03 23:57:30 +09:00
Yu Watanabe 858d36c1ec path-util: introduce path_simplify()
The function is similar to path_kill_slashes() but also removes
initial './', trailing '/.', and '/./' in the path.
When the second argument of path_simplify() is false, then it
behaves as the same as path_kill_slashes(). Hence, this also
replaces path_kill_slashes() with path_simplify().
2018-06-03 23:39:26 +09:00
Yu Watanabe 2d1729ca3f conf-parser: introduce DEFINE_CONFIG_PARSE*() macros
This introduces several macros for defining config parsers.
Also this fixes errno in DEFINE_CONFIG_PARSE_ENUM() and _ENUMV()
and makes the log level lower when a duplicated item is
specified to the settings parsed by the function defined by
DEFINE_CONFIG_PARSE_ENUMV().
2018-05-31 11:09:41 +09:00
Lennart Poettering 7ef7e15bd7 conf-parser: add a bit more whitespace
We usually seperate case statements within a switch from each other by
empty lines. We also often add an empty line after multi-line function
prototypes, let's do so here too

Also, no trailing ; after }...
2018-05-29 15:25:22 +02:00
Lennart Poettering 5a4ff98840 conf-parser: shorten config_parse_string() by using free_and_strdup() and empty_to_null() 2018-05-17 20:45:57 +02:00
Lennart Poettering 4f424df760 core: move config_parse_limit() to the generic conf-parser.[ch]
That way we can use it in nspawn.

Also, while we are at it, let's rename the call config_parse_rlimit(),
i.e. insert the "r", to clarify what kind of limit this is about.
2018-05-17 20:36:52 +02:00
Filipe Brandenburger 4f29e0db12 conf-parser: accept trailing backslash at the end of the file (#8941)
This makes it behave the same whether there is a blank line or not at
the end of the file.  This is also consistent with the behavior of the
shell on a shell script that ends on a trailing backslash at the last
line.

Added tests to test_config_parse(), which only pass if the corresponding
change to config_parse() is included.
2018-05-09 18:10:07 -07:00
Yu Watanabe 29a3db75fd util: rename signal_from_string_try_harder() to signal_from_string()
Also this makes the new `signal_from_string()` function reject
e.g, `SIG3` or `SIG+5`.
2018-05-03 16:52:49 +09:00
Lennart Poettering 79138a384f conf-parse: add a generic config_parse_mtu() conf file parser function
It's mostly a wrapper around parse_mtu() but with some nicer logging.

The address family is initialized from the "ltype" parameter, so that
configuration file parser tables can be easily declare it.
2018-04-26 13:51:44 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Yu Watanabe 1cc6c93a95 tree-wide: use TAKE_PTR() and TAKE_FD() macros 2018-04-05 14:26:26 +09:00