Merge pull request #5146 from ssahani/ifname-alias
networkd: Allow ':' in label
This reverts a341dfe563 and takes a slightly different approach: anything is
allowed in network interface labels, but network interface names are verified
as before (i.e. amongst other things, no colons are allowed there).
This commit is contained in:
@@ -887,7 +887,7 @@ bool ifname_valid(const char *p) {
|
||||
if ((unsigned char) *p <= 32U)
|
||||
return false;
|
||||
|
||||
if (*p == '/')
|
||||
if (*p == ':' || *p == '/')
|
||||
return false;
|
||||
|
||||
numeric = numeric && (*p >= '0' && *p <= '9');
|
||||
|
||||
@@ -809,8 +809,8 @@ int config_parse_label(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!ifname_valid(rvalue)) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Interface label is not valid or too long, ignoring assignment: %s", rvalue);
|
||||
if (strlen(rvalue) >= IFNAMSIZ) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Interface label is too long, ignoring assignment: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
static void test_ifname_valid(void) {
|
||||
assert(ifname_valid("foo"));
|
||||
assert(ifname_valid("eth0"));
|
||||
assert(ifname_valid("eth0:0"));
|
||||
|
||||
assert(!ifname_valid("0"));
|
||||
assert(!ifname_valid("99"));
|
||||
@@ -45,7 +44,7 @@ static void test_ifname_valid(void) {
|
||||
assert(!ifname_valid("."));
|
||||
assert(!ifname_valid(".."));
|
||||
assert(ifname_valid("foo.bar"));
|
||||
assert(ifname_valid("x:y"));
|
||||
assert(!ifname_valid("x:y"));
|
||||
|
||||
assert(ifname_valid("xxxxxxxxxxxxxxx"));
|
||||
assert(!ifname_valid("xxxxxxxxxxxxxxxx"));
|
||||
|
||||
Reference in New Issue
Block a user