net-snmp: fix newline when RestrictOID is neither yes nor no
authorEric McDonald <redacted>
Sat, 7 Mar 2026 22:29:16 +0000 (14:29 -0800)
committerFlorian Eckert <redacted>
Wed, 11 Mar 2026 08:07:04 +0000 (09:07 +0100)
commit136bff9a8e85755bdb132d741a8e2f5937d3ba57
treec7a11240e34d09f3ae7418824cd9308f6e8178ec
parentb6ff8c79b17baf31c3ef5253b762f2d4c42b853a
net-snmp: fix newline when RestrictOID is neither yes nor no

snmpd_access_default_add, snmpd_access_HostName_add, and
snmpd_access_HostIP_add check if RestrictOID is `yes` or `no`
but fail to write a newline for other values of RestrictOID
(e.g., `true`, `false`) or if unset, corrupting the generated config.

Fix by using config_get_bool and restructuring to write either
a complete line or nothing. Also require RestrictedOID to be
non-empty when RestrictOID is enabled.

This is a breaking change for configs where RestrictOID is set
to a value that the old code did not match as `yes` (e.g., `true`,
`1`, `on`, `enabled`) but config_get_bool evaluates as true. In
practice, this is unlikely to affect existing installs unless a
user is unknowingly relying on unintended behavior or is deliberately
relying on the old code's non-standard boolean evaluation; this
latter case is considered unlikely by this commit's author. Configs
where RestrictOID is enabled but RestrictedOID is empty are also
affected; previously a directive with a trailing space was written,
now no directive is written.

Signed-off-by: Eric McDonald <redacted>
net/net-snmp/files/snmpd.init
git clone https://git.99rst.org/PROJECT