Accumulate resolv.conf options

If there are multiple "options" lines, keep the options from all of
them.

Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
Rob Murray 2024-03-01 16:59:28 +00:00
parent 7f69142aa0
commit f04f69e366
2 changed files with 3 additions and 5 deletions

View file

@ -480,10 +480,8 @@ func (rc *ResolvConf) processLine(line string) {
if len(fields) < 2 {
return
}
// Replace options from earlier directives.
// TODO(robmry) - preserving incorrect behaviour, options should accumulate.
// rc.options = append(rc.options, fields[1:]...)
rc.options = fields[1:]
// Accumulate options.
rc.options = append(rc.options, fields[1:]...)
default:
// Copy anything that's not a recognised directive.
rc.other = append(rc.other, line)

View file

@ -263,7 +263,7 @@ options opt1 opt2 opt3`,
input: `nameserver 1.2.3.4
options opt1 opt2
options opt3 opt4`,
result: []string{"opt3", "opt4"},
result: []string{"opt1", "opt2", "opt3", "opt4"},
},
} {
test := GetOptions([]byte(tc.input))