Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 75819 - rc-scripts fail with noclobber bash
Summary: rc-scripts fail with noclobber bash
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All All
: High normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-27 10:08 UTC by Jesús P Rey (Chuso)
Modified: 2005-12-25 22:14 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesús P Rey (Chuso) 2004-12-27 10:08:21 UTC
Since rc-scripts use > to send text to a file instead of >|, if you run a rc-script from a bash prompt with noclobber option, it may not work properly:

      # /etc/init.d/iptables save 
       * Saving iptables state...
      /sbin/runscript.sh: line 79: /var/lib/iptables/rules-save:
      cannot overwrite existing file                      [ !! ]                                                                         

Please use >| instead of >

Examples:

/etc/init.d/bootsplash
-               echo "silent" > /proc/splash
+               echo "silent" >| /proc/splash

/etc/init.d/iptables init.d_fix/iptables
-               echo "1" > /proc/sys/net/ipv4/conf/all/forwarding
+               echo "1" >| /proc/sys/net/ipv4/conf/all/forwarding
-                       echo "0" > /proc/sys/net/ipv4/conf/all/forwarding
+                       echo "0" >| /proc/sys/net/ipv4/conf/all/forwarding
-        /sbin/iptables-save ${SAVE_RESTORE_OPTIONS} > ${IPTABLES_SAVE}
+        /sbin/iptables-save ${SAVE_RESTORE_OPTIONS} >| ${IPTABLES_SAVE}
         eend $?

/etc/init.d/net.eth0
-               echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
+               echo -n 1 >| /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
Comment 1 SpanKY gentoo-dev 2004-12-27 13:01:40 UTC
perhaps the better fix is to disable noclobber in /sbin/runscript.sh
Comment 2 SpanKY gentoo-dev 2004-12-27 16:14:26 UTC
hrm, you never mentioned what baselayout you were using, and it seems to work fine for me:
root@phear 0 ~ # set -o noclobber
root@phear 0 ~ # echo > f
root@phear 0 ~ # echo > f
-bash: f: cannot overwrite existing file
root@phear 0 ~ # /etc/init.d/iptables save  
 * Saving iptables state ...                                         [ ok ]
root@phear 0 ~ # /etc/init.d/iptables pause
* Saving iptables state ...                                          [ ok ]
 * Stopping firewall ...                                             [ ok ]
root@phear 0 ~ # /etc/init.d/iptables start
 * Loading iptables state and starting firewall ...
 * Restoring iptables ruleset                                        [ ok ]
Comment 3 Jesús P Rey (Chuso) 2004-12-28 15:33:47 UTC
> perhaps the better fix is to disable noclobber in /sbin/runscript.sh

Yes, it looks a smarter sollution ;)

At least /usr/sbin/etc-update also needs this fix

> hrm, you never mentioned what baselayout you were using, and it seems to work fine for me

The iptables POC I posted was reproduced with sys-apps/baselayout-1.9.4-r6 and net-firewall/iptables-1.2.11-r3
Comment 4 SpanKY gentoo-dev 2004-12-28 16:09:45 UTC
ok, well try again with 1.11.x (that's what i tested with)

etc-update is a different issue, that has nothing to do with rc-scripts (it's part of portage)
Comment 5 Jesús P Rey (Chuso) 2005-04-14 09:42:27 UTC
Sorry, allexport must also be activated.

With noclobber on and allexport on is when this error happens.
Comment 6 SpanKY gentoo-dev 2005-12-25 22:13:37 UTC
ok, that explains it a bit more ...
Comment 7 SpanKY gentoo-dev 2005-12-25 22:14:31 UTC
but unless someone can propose a clean solution to prevent the allexport option from screwing things up, we arent going to waste energy on this

allexport can break via shell options or aliases or bash functions