Accepting request 72294 from security:netfilter

- cleanup up initscript
  * don't use /var/lock/subsys
  * read /etc/sysconfig/ebtables for setting and restore state from
    /etc/ebtables where the script actually saved the state to.

OBS-URL: https://build.opensuse.org/request/show/72294
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/ebtables?expand=0&rev=15
This commit is contained in:
Sascha Peilicke 2011-06-01 07:32:35 +00:00 committed by Git OBS Bridge
commit b06740c209
3 changed files with 63 additions and 27 deletions

View File

@ -13,7 +13,7 @@ Index: ebtables.sysv
-# Check that networking is up. -# Check that networking is up.
-[ ${NETWORKING} = "no" ] && exit 0 -[ ${NETWORKING} = "no" ] && exit 0
+### BEGIN INIT INFO +### BEGIN INIT INFO
+# Provides: eptables +# Provides: ebtables
+# Required-Start: $remote_fs $network +# Required-Start: $remote_fs $network
+# Required-Stop: $remote_fs $network +# Required-Stop: $remote_fs $network
+# Short-Description: Ethernet Bridge filter tables +# Short-Description: Ethernet Bridge filter tables
@ -24,56 +24,82 @@ Index: ebtables.sysv
[ -x __EXEC_PATH__/ebtables ] || exit 1 [ -x __EXEC_PATH__/ebtables ] || exit 1
[ -x __EXEC_PATH__/ebtables-save ] || exit 1 [ -x __EXEC_PATH__/ebtables-save ] || exit 1
@@ -35,8 +38,8 @@ EBTABLES_SAVE_ON_STOP="no" @@ -30,12 +33,15 @@ umask 0077
#default configuration
EBTABLES_TEXT_FORMAT="yes"
EBTABLES_BINARY_FORMAT="yes"
-EBTABLES_MODULES_UNLOAD="yes"
+EBTABLES_MODULES_UNLOAD="no"
EBTABLES_SAVE_ON_STOP="no"
EBTABLES_SAVE_ON_RESTART="no" EBTABLES_SAVE_ON_RESTART="no"
EBTABLES_SAVE_COUNTER="no" EBTABLES_SAVE_COUNTER="no"
-config=__SYSCONFIG__/$prog-config -config=__SYSCONFIG__/$prog-config
-[ -f "$config" ] && . "$config"
+. /etc/rc.status +. /etc/rc.status
+rc_reset +rc_reset
+
+config=/etc/sysconfig/ebtables
[ -f "$config" ] && . "$config"
start() { start() {
echo -n $"Starting $desc ($prog): " @@ -45,16 +51,15 @@ start() {
@@ -49,10 +52,10 @@ start() { __EXEC_PATH__/ebtables -t $table --atomic-file __SYSCONFIG__/ebtables.$table --atomic-commit || RETVAL=1
done
else
- __EXEC_PATH__/ebtables-restore < /etc/sysconfig/ebtables || RETVAL=1
+ __EXEC_PATH__/ebtables-restore < __SYSCONFIG__/ebtables || RETVAL=1
fi fi
if [ $RETVAL -eq 0 ]; then if [ $RETVAL -eq 0 ]; then
- success "$prog startup" - success "$prog startup"
+ rc_status -v - rm -f /var/lock/subsys/$prog
rm -f /var/lock/subsys/$prog + touch /var/run/rcebtables
+ rc_failed 0
else else
- failure "$prog startup" - failure "$prog startup"
+ rc_failed 3 + rc_failed 3
fi fi
echo - echo
} }
@@ -70,10 +73,10 @@ stop() {
stop() {
@@ -70,17 +75,18 @@ stop() {
fi fi
if [ $RETVAL -eq 0 ]; then if [ $RETVAL -eq 0 ]; then
- success "$prog shutdown" - success "$prog shutdown"
+ rc_status -v - rm -f /var/lock/subsys/$prog
rm -f /var/lock/subsys/$prog + rm -f /var/run/rcebtables
+ rc_failed 0
else else
- failure "$prog shutdown" - failure "$prog shutdown"
+ rc_failed 3 + rc_failed 3
fi fi
echo - echo
} }
@@ -107,9 +110,9 @@ save() {
restart() {
stop
+ rc_status -v
start
+ rc_status -v
}
save() {
@@ -106,40 +112,42 @@ save() {
done
fi fi
if [ $RETVAL -eq 0 ]; then - if [ $RETVAL -eq 0 ]; then
- success "$prog saved" - success "$prog saved"
+ rc_status -v - else
else
- failure "$prog saved" - failure "$prog saved"
+ if [ $RETVAL -ne 0 ]; then
+ rc_failed 3 + rc_failed 3
fi fi
echo - echo
} }
@@ -117,29 +120,34 @@ save() {
case "$1" in case "$1" in
start) start)
start start
@ -87,16 +113,18 @@ Index: ebtables.sysv
restart|reload) restart|reload)
[ "$EBTABLES_SAVE_ON_RESTART" = "yes" ] && save [ "$EBTABLES_SAVE_ON_RESTART" = "yes" ] && save
restart restart
+ rc_status -v
;; ;;
condrestart) - condrestart)
[ -e /var/lock/subsys/$prog ] && restart - [ -e /var/lock/subsys/$prog ] && restart
- RETVAL=$? - RETVAL=$?
+ rc_status + try-restart|condrestart)
+ if [ -e /var/run/rcebtables ]; then
+ restart
+ fi
;; ;;
save) save)
save save
+ rc_status + rc_status -v
;; ;;
status) status)
__EXEC_PATH__/ebtables-save __EXEC_PATH__/ebtables-save
@ -104,8 +132,9 @@ Index: ebtables.sysv
+ rc_status -v + rc_status -v
;; ;;
*) *)
echo $"Usage $0 {start|stop|restart|condrestart|save|status}" - echo $"Usage $0 {start|stop|restart|condrestart|save|status}"
- RETVAL=1 - RETVAL=1
+ echo $"Usage $0 {start|stop|restart|try-restart|save|status}"
+ exit 1 + exit 1
+ ;; + ;;
esac esac

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue May 31 12:34:34 UTC 2011 - lnussel@suse.de
- cleanup up initscript
* don't use /var/lock/subsys
* read /etc/sysconfig/ebtables for setting and restore state from
/etc/ebtables where the script actually saved the state to.
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Mar 18 07:09:55 UTC 2010 - coolo@novell.com Thu Mar 18 07:09:55 UTC 2010 - coolo@novell.com

View File

@ -85,9 +85,10 @@ make \
SYSCONFIGDIR=%{_sysconfdir} \ SYSCONFIGDIR=%{_sysconfdir} \
install install
ln -sf %{_sysconfdir}/init.d/ebtables $RPM_BUILD_ROOT%{_sbindir}/rcebtables ln -sf %{_sysconfdir}/init.d/ebtables $RPM_BUILD_ROOT%{_sbindir}/rcebtables
# not used
rm -f $RPM_BUILD_ROOT/etc/ebtables-config
%post %post
/sbin/ldconfig
%fillup_and_insserv ebtables %fillup_and_insserv ebtables
%preun %preun
@ -96,7 +97,6 @@ ln -sf %{_sysconfdir}/init.d/ebtables $RPM_BUILD_ROOT%{_sbindir}/rcebtables
%postun %postun
%restart_on_update ebtables %restart_on_update ebtables
%insserv_cleanup %insserv_cleanup
/sbin/ldconfig
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
@ -104,7 +104,6 @@ rm -rf $RPM_BUILD_ROOT
%files %files
%defattr(-,root,root) %defattr(-,root,root)
%doc %{_mandir}/man8/ebtables.8* %doc %{_mandir}/man8/ebtables.8*
%config(noreplace) %{_sysconfdir}/ebtables-config
%config(noreplace) %{_sysconfdir}/ethertypes %config(noreplace) %{_sysconfdir}/ethertypes
%{_sysconfdir}/init.d/ebtables %{_sysconfdir}/init.d/ebtables
%dir %{_libdir}/%{name} %dir %{_libdir}/%{name}