applied, thanks
Frédéric Moulins wrote: > This patch allows to configure snmpd communities and access from uci. > > The standard '/etc/snmp/snmpd.conf' becomes a symbolic link to > '/var/run/snmpd.conf' where the configuration is generated at boot time. > > The config file included reflects the standard snmpd default > configuration. > > > Signed-off-by: Frédéric Moulins <[EMAIL PROTECTED]> > > Index: libs/net-snmp/files/snmpd.init > =================================================================== > --- libs/net-snmp/files/snmpd.init (révision 11569) > +++ libs/net-snmp/files/snmpd.init (copie de travail) > @@ -1,5 +1,5 @@ > #!/bin/sh /etc/rc.common > -# Copyright (C) 2006 OpenWrt.org > +# Copyright (C) 2008 OpenWrt.org > START=50 > > DEFAULT=/etc/default/snmpd > @@ -7,17 +7,93 @@ > LOG_D=/var/log > RUN_D=/var/run > PID_F=$RUN_D/snmpd.pid > +RUN_C=$RUN_D/snmpd.conf > > - > +snmpd_com2sec_add() { > + local cfg="$1" > + config_get secname "$cfg" secname > + [ -n "$secname" ] || return 0 > + config_get source "$cfg" source > + [ -n "$source" ] || return 0 > + config_get community "$cfg" community > + [ -n "$community" ] || return 0 > + echo "com2sec $secname $source $community" >> $RUN_C > +} > +snmpd_group_add() { > + local cfg="$1" > + config_get group "$cfg" group > + [ -n "$group" ] || return 0 > + config_get version "$cfg" version > + [ -n "$version" ] || return 0 > + config_get secname "$cfg" secname > + [ -n "$secname" ] || return 0 > + echo "group $group $version $secname" >> $RUN_C > +} > +snmpd_view_add() { > + local cfg="$1" > + config_get viewname "$cfg" viewname > + [ -n "$viewname" ] || return 0 > + config_get type "$cfg" type > + [ -n "$type" ] || return 0 > + config_get oid "$cfg" oid > + [ -n "$oid" ] || return 0 > + # optional mask > + config_get mask "$cfg" mask > + echo "view $viewname $type $oid $mask" >> $RUN_C > +} > +snmpd_access_add() { > + local cfg="$1" > + config_get group "$cfg" group > + [ -n "$group" ] || return 0 > + config_get context "$cfg" context > + [ -n $context ] || return 0 > + [ "$context" == "none" ] && context='""' > + config_get version "$cfg" version > + [ -n "$version" ] || return 0 > + config_get level "$cfg" level > + [ -n "$level" ] || return 0 > + config_get prefix "$cfg" prefix > + [ -n "$prefix" ] || return 0 > + config_get read "$cfg" read > + [ -n "$read" ] || return 0 > + config_get write "$cfg" write > + [ -n "$write" ] || return 0 > + config_get notify "$cfg" notify > + [ -n "$notify" ] || return 0 > + echo "access $group $context $version $level $prefix $read $write > $notify" >> $RUN_C > +} > +snmpd_pass_add() { > + local cfg="$1" > + local pass='pass' > + > + config_get miboid "$cfg" miboid > + [ -n "$miboid" ] || return 0 > + config_get prog "$cfg" prog > + [ -n "$prog" ] || return 0 > + config_get_bool persist "$cfg" persist 0 > + [ $persist -ne 0 ] && pass='pass_persist' > + config_get priority "$cfg" priority > + priority=${priority:+-p $priority} > + echo "$pass $priority $miboid $prog" >> $RUN_C > +} > start() { > - [ -f $DEFAULT ] && . $DEFAULT > [ -d $LIB_D ] || mkdir -p $LIB_D > [ -d $LOG_D ] || mkdir -p $LOG_D > [ -d $RUN_D ] || mkdir -p $RUN_D > - snmpd $OPTIONS > + [ -f $RUN_C ] && rm -f $RUN_C > + > + config_load snmpd > + > + config_foreach snmpd_com2sec_add com2sec > + config_foreach snmpd_group_add group > + config_foreach snmpd_view_add view > + config_foreach snmpd_access_add access > + config_foreach snmpd_pass_add pass > + > + [ -f $DEFAULT ] && . $DEFAULT > + $DEBUG /usr/sbin/snmpd $OPTIONS > } > - > stop() { > [ -f $PID_F ] && kill $(cat $PID_F) > + [ -f $RUN_C ] && rm -f $RUN_C > } > - > Index: libs/net-snmp/files/snmpd.conf > =================================================================== > --- libs/net-snmp/files/snmpd.conf (révision 11569) > +++ libs/net-snmp/files/snmpd.conf (copie de travail) > @@ -1,14 +1,64 @@ > -com2sec ro default public > -com2sec rw localhost private > +config com2sec public > + option secname ro > + option source default > + option community public > > -group public v1 ro > -group public v2c ro > -group public usm ro > -group private v1 rw > -group private v2c rw > -group private usm rw > +config com2sec private > + option secname rw > + option source localhost > + option community private > > -view all included .1 > +config group public_v1 > + option group public > + option version v1 > + option secname ro > > -access public "" any noauth exact all none none > -access private "" any noauth exact all all all > +config group public_v2c > + option group public > + option version v2c > + option secname ro > + > +config group public_usm > + option group public > + option version usm > + option secname ro > + > +config group private_v1 > + option group private > + option version v1 > + option secname rw > + > +config group private_v2c > + option group private > + option version v2c > + option secname rw > + > +config group private_usm > + option group private > + option version usm > + option secname rw > + > +config view all > + option viewname all > + option type included > + option oid .1 > + > +config access public_access > + option group public > + option context none > + option version any > + option level noauth > + option prefix exact > + option read all > + option write none > + option notify none > + > +config access private_access > + option group private > + option context none > + option version any > + option level noauth > + option prefix exact > + option read all > + option write all > + option notify all > Index: libs/net-snmp/Makefile > =================================================================== > --- libs/net-snmp/Makefile (révision 11569) > +++ libs/net-snmp/Makefile (copie de travail) > @@ -198,12 +198,14 @@ > > define Package/snmpd/conffiles > /etc/default/snmpd > -/etc/snmp/snmpd.conf > +/etc/config/snmpd > endef > > define Package/snmpd/install > + $(INSTALL_DIR) $(1)/etc/config > + $(INSTALL_DATA) ./files/snmpd.conf $(1)/etc/config/snmpd > $(INSTALL_DIR) $(1)/etc/snmp > - $(INSTALL_DATA) ./files/snmpd.conf $(1)/etc/snmp/snmpd.conf > + ln -sf /var/run/snmpd.conf $(1)/etc/snmp/ > $(INSTALL_DIR) $(1)/etc/default > $(INSTALL_DATA) ./files/snmpd.default $(1)/etc/default/snmpd > $(INSTALL_DIR) $(1)/etc/init.d > @@ -214,12 +216,14 @@ > > define Package/snmpd-static/conffiles > /etc/default/snmpd > -/etc/snmp/snmpd.conf > +/etc/config/snmpd > endef > > define Package/snmpd-static/install > + $(INSTALL_DIR) $(1)/etc/config > + $(INSTALL_DATA) ./files/snmpd.conf $(1)/etc/config/snmpd > $(INSTALL_DIR) $(1)/etc/snmp > - $(INSTALL_DATA) ./files/snmpd.conf $(1)/etc/snmp/snmpd.conf > + ln -sf /var/run/snmpd.conf $(1)/etc/snmp/ > $(INSTALL_DIR) $(1)/etc/default > $(INSTALL_DATA) ./files/snmpd.default $(1)/etc/default/snmpd > $(INSTALL_DIR) $(1)/etc/init.d > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel