From: Eric McDonald Date: Sat, 7 Mar 2026 21:48:14 +0000 (-0800) Subject: net-snmp: add early return when CommunityName is unset X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=dbd293d75186eba31e99f4a6feed5193b53107fc;p=openwrt-packages.git net-snmp: add early return when CommunityName is unset snmpd_access_default_add, snmpd_access_HostName_add, and snmpd_access_HostIP_add would write unintended output to the config file if the CommunityName option is not specified. Add an early return to each function to prevent writing in that case. This is a breaking change for configs where CommunityName is unset. Previously, an empty CommunityName option would result in a malformed directive with a double space and no guaranteed newline, the exact form of which depended on the values of other options. Now, no directive is written. Signed-off-by: Eric McDonald --- diff --git a/net/net-snmp/files/snmpd.init b/net/net-snmp/files/snmpd.init index bc675792d..96d36b162 100644 --- a/net/net-snmp/files/snmpd.init +++ b/net/net-snmp/files/snmpd.init @@ -132,6 +132,7 @@ snmpd_access_default_add() { config_get mode "$cfg" Mode [ -n "$mode" ] || return 0 config_get community "$cfg" CommunityName + [ -n "$community" ] || return 0 config_get oidrestrict "$cfg" RestrictOID config_get oid "$cfg" RestrictedOID echo -n "$mode $community default" >> $CONFIGFILE @@ -145,6 +146,7 @@ snmpd_access_HostName_add() { config_get mode "$cfg" Mode [ -n "$mode" ] || return 0 config_get community "$cfg" CommunityName + [ -n "$community" ] || return 0 config_get oidrestrict "$cfg" RestrictOID config_get oid "$cfg" RestrictedOID echo -n "$mode $community $hostname" >> $CONFIGFILE @@ -159,6 +161,7 @@ snmpd_access_HostIP_add() { config_get mode "$cfg" Mode [ -n "$mode" ] || return 0 config_get community "$cfg" CommunityName + [ -n "$community" ] || return 0 config_get oidrestrict "$cfg" RestrictOID config_get oid "$cfg" RestrictedOID echo -n "$mode $community $host_ip/$ip_mask" >> $CONFIGFILE