diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-12-15 15:21:18 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-12-16 02:52:22 +0100 |
commit | a5053a158b43c5ddee90f4915b9fc603e0191d6d (patch) | |
tree | 81ff8346a9de44d09db6c129886a2753b1c681f2 /src/shared/conf-parser.c | |
parent | util: introduce ifname_valid_full() (diff) | |
download | systemd-a5053a158b43c5ddee90f4915b9fc603e0191d6d.tar.xz systemd-a5053a158b43c5ddee90f4915b9fc603e0191d6d.zip |
udev: support AlternativeName= setting in .link file
Diffstat (limited to 'src/shared/conf-parser.c')
-rw-r--r-- | src/shared/conf-parser.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 90b31148f3..cb20279dda 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -985,6 +985,66 @@ int config_parse_ifname( return 0; } +int config_parse_ifnames( + const char *unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + + _cleanup_strv_free_ char **names = NULL; + char ***s = data; + const char *p; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + if (isempty(rvalue)) { + *s = strv_free(*s); + return 0; + } + + p = rvalue; + for (;;) { + _cleanup_free_ char *word = NULL; + + r = extract_first_word(&p, &word, NULL, 0); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, + "Failed to extract interface name, ignoring assignment: %s", + rvalue); + return 0; + } + if (r == 0) + break; + + if (!ifname_valid_full(word, ltype)) { + log_syntax(unit, LOG_ERR, filename, line, 0, + "Interface name is not valid or too long, ignoring assignment: %s", + word); + continue; + } + + r = strv_consume(&names, TAKE_PTR(word)); + if (r < 0) + return log_oom(); + } + + r = strv_extend_strv(s, names, true); + if (r < 0) + return log_oom(); + + return 0; +} + int config_parse_ip_port( const char *unit, const char *filename, |