Comment 3 for bug 2017840

Revision history for this message
CH (pdragon99) wrote :

Whoops, found another bug:

```
# ifup enp2s0

/etc/network/if-up.d/resolved: 1: /run/network/ifupdown-inet-enp2s0: DNS=1.1.1.1: not found
/etc/network/if-up.d/resolved: 2: /run/network/ifupdown-inet-enp2s0: DOMAINS=example.org: not found
Failed to parse DNS server address: DNS
Failed to set DNS configuration: Invalid argument

# cat /run/network/ifupdown-inet-enp2s0

"DNS"="1.1.1.1"
"DOMAINS"="example.org"
```

And that comes from lines 47-51 of /etc/network/if-up.d/resolved:
```
    if [ -n "$NEW_DNS" ]; then
        cat <<EOF >"$mystatedir/ifupdown-${ADDRFAM}-$interface"
"$DNS"="$NEW_DNS"
EOF
        if [ -n "$NEW_DOMAINS" ]; then
            cat <<EOF >>"$mystatedir/ifupdown-${ADDRFAM}-$interface"
"$DOMAINS"="$NEW_DOMAINS"
EOF
```
Basically, the double-quotes around "$DNS" and "$DOMAINS" shouldn't be there, because it's a here-doc.

But this reveals another bug: the variable $DOMAINS is used to hold either "DOMAINS" or "DOMAINS6" in lines 41 or 44, but the actual search domains in line 95.

Has this code ever worked?