mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
Merge pull request #6746 from yuwata/parse-empty-string
allow to input empty string to config_parse_xxx()
This commit is contained in:
commit
60c776fd75
@ -803,8 +803,8 @@
|
||||
is used, only one AF_UNIX socket in the file system or one
|
||||
FIFO may be configured for the socket unit. Use this option to
|
||||
manage one or more symlinked alias names for a socket, binding
|
||||
their lifecycle together. Defaults to the empty
|
||||
list.</para></listitem>
|
||||
their lifecycle together. If the empty string is assigned, the
|
||||
list of paths is reset. Defaults to the empty list.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
@ -283,6 +283,23 @@ int config_parse_unit_path_strv_printf(
|
||||
assert(rvalue);
|
||||
assert(u);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
char **empty;
|
||||
|
||||
/* Empty assignment resets the list. As a special rule
|
||||
* we actually fill in a real empty array here rather
|
||||
* than NULL, since some code wants to know if
|
||||
* something was set at all... */
|
||||
empty = new0(char*, 1);
|
||||
if (!empty)
|
||||
return log_oom();
|
||||
|
||||
strv_free(*x);
|
||||
*x = empty;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (p = rvalue;;) {
|
||||
_cleanup_free_ char *word = NULL, *k = NULL;
|
||||
|
||||
|
@ -725,6 +725,11 @@ int config_parse_path(
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
n = NULL;
|
||||
goto finalize;
|
||||
}
|
||||
|
||||
if (!utf8_is_valid(rvalue)) {
|
||||
log_syntax_invalid_utf8(unit, LOG_ERR, filename, line, rvalue);
|
||||
return fatal ? -ENOEXEC : 0;
|
||||
@ -743,6 +748,7 @@ int config_parse_path(
|
||||
|
||||
path_kill_slashes(n);
|
||||
|
||||
finalize:
|
||||
free(*s);
|
||||
*s = n;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user