Re: edgerouter lite ethernet
On 09/16/13 19:29, Jonathan Matthew wrote: Here's the rest of the changes required to get ethernet working on the edgerouter lite, which makes it possible to boot off nfsroot and do exciting stuff like build kernels. - add atphy(4) to configs - allow separate rx and tx clock settings - add phy mapping for erl - add tx/rx clock settings for erl ok? No. This breaks the RAMDISK (tested on CAM-0100). Log at the bottom of this email from the CAM-0100 (and attached as a tarball too because I don't trust Thunderbird). Note that everything else works except for the RAMDISK. The GENERIC kernel works great on the CAM-0100 and ERL and everything works as expected on both machines with GENERIC. Also, the panic still occurs if you remove the atphy* line from RAMDISK. Can someone else who has a CAM-0100 double check to make sure it's not just me, since I'd love to have this go in. ~Brian Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2013 OpenBSD. All rights reserved. http://www.OpenBSD.org OpenBSD 5.4-current (GENERIC) #29: Tue Sep 17 08:07:14 EST 2013 r...@cantrip.eait.uq.edu.au:/usr/src/sys/arch/octeon/compile/GENERIC real mem = 247922688 (236MB) avail mem = 245612544 (234MB) mainbus0 at root cpu0 at mainbus0: Cavium OCTEON CPU rev 0.1 500 MHz, Software FP emulation cpu0: cache L1-I 32KB D 16KB 4 way, L2 128KB direct clock0 at mainbus0: int 5 iobus0 at mainbus0 octcf at iobus0 base 0x1d000800 irq 0 not configured pcibus at iobus0 irq 0 not configured cn30xxgmx0 at iobus0 base 0x118000800 irq 48 cnmac0 at cn30xxgmx0 address=0x000118000800: RGMII, address dc:9f:db:29:40:2f atphy0 at cnmac0 phy 7: F1 10/100/1000 PHY, rev. 2 cnmac1 at cn30xxgmx0 address=0x000118000800: RGMII, address dc:9f:db:29:40:30 atphy1 at cnmac1 phy 6: F1 10/100/1000 PHY, rev. 2 cnmac2 at cn30xxgmx0 address=0x000118000800: RGMII, address dc:9f:db:29:40:31 atphy2 at cnmac2 phy 5: F1 10/100/1000 PHY, rev. 2 uar: ns16550, no working fifo com0: console com1 at uartbus0 base 0x118000c00 irq 35: ns16550, no working fifo /dev/ksyms: Symbol table not valid. vscsi0 at root scsibus0 at vscsi0: 256 targets softraid0 at root scsibus1 at softraid0: 256 targets root device: cnmac0 nfs_boot: using interface cnmac0, with revarp & bootparams cnmac0: link up (1000baseT-FDX) cnmac0: link down cnmac0: link up (1000baseT-FDX) nfs_boot: client_addr=192.168.1.2 nfs_boot: server_addr=192.168.1.22 hostname=erl root on 192.168.1.22:/srv/octeon-nfsroot WARNING: No TOD clock, believing file system. WARNING: CHECK AND RESET THE DATE! swap on 192.168.1.22:/srv/octeon-nfsswap Index: arch/octeon/conf/GENERIC === RCS file: /cvs/src/sys/arch/octeon/conf/GENERIC,v retrieving revision 1.9 diff -u -p -r1.9 GENERIC --- arch/octeon/conf/GENERIC24 Jun 2011 02:18:17 - 1.9 +++ arch/octeon/conf/GENERIC16 Sep 2013 22:50:31 - @@ -44,6 +44,7 @@ cnmac*at cn30xxgmx? rgephy* at mii? ukphy*at mii? +atphy* at mii? # IDE Controller pciide* at pci? flags 0x Index: arch/octeon/conf/RAMDISK === RCS file: /cvs/src/sys/arch/octeon/conf/RAMDISK,v retrieving revision 1.11 diff -u -p -r1.11 RAMDISK --- arch/octeon/conf/RAMDISK26 Mar 2013 14:23:19 - 1.11 +++ arch/octeon/conf/RAMDISK16 Sep 2013 22:50:31 - @@ -64,6 +64,7 @@ cnmac*at cn30xxgmx? rgephy* at mii? ukphy*at mii? +atphy* at mii? pseudo-device loop 1 # network loopback pseudo-device bpfilter1 # packet filter Index: arch/octeon/dev/cn30xxasx.c === RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxasx.c,v retrieving revision 1.3 diff -u -p -r1.3 cn30xxasx.c --- arch/octeon/dev/cn30xxasx.c 5 Dec 2012 23:20:14 - 1.3 +++ arch/octeon/dev/cn30xxasx.c 16 Sep 2013 22:50:31 - @@ -175,10 +175,10 @@ cn30xxasx_enable_intr(struct cn30xxasx_s #endif int -cn30xxasx_clk_set(struct cn30xxasx_softc *sc, int setting) +cn30xxasx_clk_set(struct cn30xxasx_softc *sc, int tx_setting, int rx_setting) { - _ASX_WR8(sc, ASX0_TX_CLK_SET0_OFFSET + 8 * sc->sc_port, setting); - _ASX_WR8(sc, ASX0_RX_CLK_SET0_OFFSET + 8 * sc->sc_port, setting); + _ASX_WR8(sc, ASX0_TX_CLK_SET0_OFFSET + 8 * sc->sc_port, tx_setting); + _ASX_WR8(sc, ASX0_RX_CLK_SET0_OFFSET + 8 * sc->sc_port, rx_setting); return 0; } Index: arch/octeon/dev/cn30xxasxvar.h === RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxasxvar.h,v retrieving revision 1.1 diff -u -p -r1.1 cn30xxasxvar.h --- arch/octeon/dev/cn30xxasxvar.h 16 Jun 2011 11:22:30 - 1.1 +++ arch/octeon/dev/cn30xxasxvar
Re: edgerouter lite ethernet
On 09/17/13 02:29, Jonathan Matthew wrote: Here's the rest of the changes required to get ethernet working on the edgerouter lite, which makes it possible to boot off nfsroot and do exciting stuff like build kernels. - add atphy(4) to configs - allow separate rx and tx clock settings - add phy mapping for erl - add tx/rx clock settings for erl ok? [...] Works for me, thanks. -Artturi
edgerouter lite ethernet
Here's the rest of the changes required to get ethernet working on the edgerouter lite, which makes it possible to boot off nfsroot and do exciting stuff like build kernels. - add atphy(4) to configs - allow separate rx and tx clock settings - add phy mapping for erl - add tx/rx clock settings for erl ok? Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2013 OpenBSD. All rights reserved. http://www.OpenBSD.org OpenBSD 5.4-current (GENERIC) #29: Tue Sep 17 08:07:14 EST 2013 r...@cantrip.eait.uq.edu.au:/usr/src/sys/arch/octeon/compile/GENERIC real mem = 247922688 (236MB) avail mem = 245612544 (234MB) mainbus0 at root cpu0 at mainbus0: Cavium OCTEON CPU rev 0.1 500 MHz, Software FP emulation cpu0: cache L1-I 32KB D 16KB 4 way, L2 128KB direct clock0 at mainbus0: int 5 iobus0 at mainbus0 octcf at iobus0 base 0x1d000800 irq 0 not configured pcibus at iobus0 irq 0 not configured cn30xxgmx0 at iobus0 base 0x118000800 irq 48 cnmac0 at cn30xxgmx0 address=0x000118000800: RGMII, address dc:9f:db:29:40:2f atphy0 at cnmac0 phy 7: F1 10/100/1000 PHY, rev. 2 cnmac1 at cn30xxgmx0 address=0x000118000800: RGMII, address dc:9f:db:29:40:30 atphy1 at cnmac1 phy 6: F1 10/100/1000 PHY, rev. 2 cnmac2 at cn30xxgmx0 address=0x000118000800: RGMII, address dc:9f:db:29:40:31 atphy2 at cnmac2 phy 5: F1 10/100/1000 PHY, rev. 2 uar: ns16550, no working fifo com0: console com1 at uartbus0 base 0x118000c00 irq 35: ns16550, no working fifo /dev/ksyms: Symbol table not valid. vscsi0 at root scsibus0 at vscsi0: 256 targets softraid0 at root scsibus1 at softraid0: 256 targets root device: cnmac0 nfs_boot: using interface cnmac0, with revarp & bootparams cnmac0: link up (1000baseT-FDX) cnmac0: link down cnmac0: link up (1000baseT-FDX) nfs_boot: client_addr=192.168.1.2 nfs_boot: server_addr=192.168.1.22 hostname=erl root on 192.168.1.22:/srv/octeon-nfsroot WARNING: No TOD clock, believing file system. WARNING: CHECK AND RESET THE DATE! swap on 192.168.1.22:/srv/octeon-nfsswap Index: arch/octeon/conf/GENERIC === RCS file: /cvs/src/sys/arch/octeon/conf/GENERIC,v retrieving revision 1.9 diff -u -p -r1.9 GENERIC --- arch/octeon/conf/GENERIC24 Jun 2011 02:18:17 - 1.9 +++ arch/octeon/conf/GENERIC16 Sep 2013 22:50:31 - @@ -44,6 +44,7 @@ cnmac*at cn30xxgmx? rgephy*at mii? ukphy* at mii? +atphy* at mii? # IDE Controller pciide*at pci? flags 0x Index: arch/octeon/conf/RAMDISK === RCS file: /cvs/src/sys/arch/octeon/conf/RAMDISK,v retrieving revision 1.11 diff -u -p -r1.11 RAMDISK --- arch/octeon/conf/RAMDISK26 Mar 2013 14:23:19 - 1.11 +++ arch/octeon/conf/RAMDISK16 Sep 2013 22:50:31 - @@ -64,6 +64,7 @@ cnmac*at cn30xxgmx? rgephy*at mii? ukphy* at mii? +atphy* at mii? pseudo-device loop1 # network loopback pseudo-device bpfilter1 # packet filter Index: arch/octeon/dev/cn30xxasx.c === RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxasx.c,v retrieving revision 1.3 diff -u -p -r1.3 cn30xxasx.c --- arch/octeon/dev/cn30xxasx.c 5 Dec 2012 23:20:14 - 1.3 +++ arch/octeon/dev/cn30xxasx.c 16 Sep 2013 22:50:31 - @@ -175,10 +175,10 @@ cn30xxasx_enable_intr(struct cn30xxasx_s #endif int -cn30xxasx_clk_set(struct cn30xxasx_softc *sc, int setting) +cn30xxasx_clk_set(struct cn30xxasx_softc *sc, int tx_setting, int rx_setting) { - _ASX_WR8(sc, ASX0_TX_CLK_SET0_OFFSET + 8 * sc->sc_port, setting); - _ASX_WR8(sc, ASX0_RX_CLK_SET0_OFFSET + 8 * sc->sc_port, setting); + _ASX_WR8(sc, ASX0_TX_CLK_SET0_OFFSET + 8 * sc->sc_port, tx_setting); + _ASX_WR8(sc, ASX0_RX_CLK_SET0_OFFSET + 8 * sc->sc_port, rx_setting); return 0; } Index: arch/octeon/dev/cn30xxasxvar.h === RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxasxvar.h,v retrieving revision 1.1 diff -u -p -r1.1 cn30xxasxvar.h --- arch/octeon/dev/cn30xxasxvar.h 16 Jun 2011 11:22:30 - 1.1 +++ arch/octeon/dev/cn30xxasxvar.h 16 Sep 2013 22:50:31 - @@ -50,7 +50,7 @@ struct cn30xxasx_attach_args { void cn30xxasx_init(struct cn30xxasx_attach_args *, struct cn30xxasx_softc **); intcn30xxasx_enable(struct cn30xxasx_softc *, int); -intcn30xxasx_clk_set(struct cn30xxasx_softc *, int); +intcn30xxasx_clk_set(struct cn30xxasx_softc *, int, int); uint64_t cn30xxasx_int_summary(struct cn30xxasx_softc *sc); #endif Index: arch/octeon/dev/cn30xxgmx.c ===
Re: /etc/rc.d/rc.subr; prefix ${pexp} with script interpretor path
On Mon, Sep 16, 2013 at 11:28:06PM +0200, Alexander Hall wrote: > sed can do it all. Really. Notes: > > - I separate re_quote() cause I think it can be useful in other places. > - I think re_quote() is (basic) regex complete. > - I don't care if the interpreter is (or seems) nonexistant, as that > shouldn't be a runtime error. > - I'm sure sed may die horribly if you try to feed it a 9GB oneline > file. However, if so, it should not produce any output anyway. ;) > If this would ever be considered a real problem, dd(1) would help > (as espie already mentioned). > > re_quote() { sed 's/\([]^$*.\\[]\)/\\\1/g'; } > > interpreter=$( > sed -n 's/^#![[:space:]]*\(.*\)/\1 /p;q' "${daemon}" | > re_quote) > pexp="$interpreter$pexp" Ah, but what happens when you run that thru a pure binary file that spans a single line ?...
Re: /etc/rc.d/rc.subr; prefix ${pexp} with script interpretor path
On 09/16/13 23:32, Marc Espie wrote: On Mon, Sep 16, 2013 at 11:28:06PM +0200, Alexander Hall wrote: sed can do it all. Really. Notes: - I separate re_quote() cause I think it can be useful in other places. - I think re_quote() is (basic) regex complete. - I don't care if the interpreter is (or seems) nonexistant, as that shouldn't be a runtime error. - I'm sure sed may die horribly if you try to feed it a 9GB oneline file. However, if so, it should not produce any output anyway. ;) If this would ever be considered a real problem, dd(1) would help (as espie already mentioned). ^ here (see below) re_quote() { sed 's/\([]^$*.\\[]\)/\\\1/g'; } interpreter=$( sed -n 's/^#![[:space:]]*\(.*\)/\1 /p;q' "${daemon}" | re_quote) pexp="$interpreter$pexp" Ah, but what happens when you run that thru a pure binary file that spans a single line ?... That is mentioned just above re_quote... :-) /Alexander
Re: Iso image integrity verification
Yes, the MITM was DPD. Great currier. I recommand it to everyone. NOT! ^courier ^ recommend :-p
Re: /etc/rc.d/rc.subr; prefix ${pexp} with script interpretor path
On 09/16/13 20:48, Craig R. Skinner wrote: On 2013-09-16 Mon 15:12 PM |, Paul de Weerd wrote: Hi Craig, --- cat bad_script.sh # This is a VERY BAD example of a script! This will break your # shebang thingambob echo Now what... -- I think you'd be better of making sure the first two characters in the file are actually "#!": head -n1 ${FILE} | grep '^#!' | sed 's/^#![[:blank:]]*//' Good idea Paul. Implemented below, along with rudimentary testing for a valid interpreter: Index: rc.subr === RCS file: /cvs/src/etc/rc.d/rc.subr,v retrieving revision 1.70 diff -u -r1.70 rc.subr --- rc.subr 11 Jul 2013 09:34:33 - 1.70 +++ rc.subr 16 Sep 2013 18:19:14 - @@ -221,4 +221,15 @@ unset _rcflags _rcuser pexp="${daemon}${daemon_flags:+ ${daemon_flags}}" +file ${daemon} | fgrep -q script && +{ + shebang=$(head -n 1 ${daemon} | grep '^#!' | sed 's/^#![[:blank:]]*//') + interpreter=$(echo ${shebang} | cut -d' ' -f1) sed can do it all. Really. Notes: - I separate re_quote() cause I think it can be useful in other places. - I think re_quote() is (basic) regex complete. - I don't care if the interpreter is (or seems) nonexistant, as that shouldn't be a runtime error. - I'm sure sed may die horribly if you try to feed it a 9GB oneline file. However, if so, it should not produce any output anyway. ;) If this would ever be considered a real problem, dd(1) would help (as espie already mentioned). re_quote() { sed 's/\([]^$*.\\[]\)/\\\1/g'; } interpreter=$( sed -n 's/^#![[:space:]]*\(.*\)/\1 /p;q' "${daemon}" | re_quote) pexp="$interpreter$pexp" Moreover, - you probably want to unset $interpreter when done. - we might want to re_quote the entire $pexp later instead. /Alexander + if [[ -f ${interpreter} && -x ${interpreter} ]] + then + pexp="${shebang} ${pexp}" + else + rc_err "$0: invalid interpreter: ${interpreter}" + fi +} rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c" Test scripts: #-=-= /etc/rc.d/rcshebangtester -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #!/bin/sh #daemon="/home/me/bin/rcshebangtester.dud" #daemon="/home/me/bin/rcshebangtester.ksh" daemon="/home/me/bin/rcshebangtester.pl" . /etc/rc.d/rc.subr rc_bg=YES #pexp="/bin/ksh ${daemon}" #pexp="/usr/bin/perl -T ${daemon}" #pexp="/usr/bin/perl ${daemon}" rc_cmd $1 #-=-= /home/me/bin/rcshebangtester.dud -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #!/var/empty #! /dev/null #! /usr/lib/libc.a # swap about above echo 'Busted!' #-=-= /home/me/bin/rcshebangtester.ksh =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #! /bin/ksh -x #! /bin/ksh # swap about above while true do uptime sleep 1 done #-=-= /home/me/bin/rcshebangtester.pl =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #! /usr/bin/perl -T #!/usr/bin/perl # swap about above use strict; use warnings; for(;;) { print time(), "\n"; sleep 1; } #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- $ sudo /etc/rc.d/rcshebangtester -d -f start; \ cat /var/run/rc.d/rcshebangtester; echo; sleep 5; \ sudo /etc/rc.d/rcshebangtester -d -f stop doing rc_read_runfile doing rc_check rcshebangtester doing rc_start 1379357218 1379357219 doing rc_wait start doing rc_check doing rc_write_runfile (ok) /usr/bin/perl -T /home/me/bin/rcshebangtester.pl 1379357220 1379357221 1379357222 1379357223 1379357224 doing rc_read_runfile doing rc_check rcshebangtester doing rc_stop doing rc_wait stop doing rc_check doing rc_rm_runfile (ok) #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Any other thoughts?
Re: /etc/rc.d/rc.subr; prefix ${pexp} with script interpretor path
On 2013-09-16 Mon 15:12 PM |, Paul de Weerd wrote: > Hi Craig, > > --- cat bad_script.sh > # This is a VERY BAD example of a script! This will break your > # shebang thingambob > > echo Now what... > -- > > I think you'd be better of making sure the first two characters in the > file are actually "#!": > > head -n1 ${FILE} | grep '^#!' | sed 's/^#![[:blank:]]*//' > Good idea Paul. Implemented below, along with rudimentary testing for a valid interpreter: Index: rc.subr === RCS file: /cvs/src/etc/rc.d/rc.subr,v retrieving revision 1.70 diff -u -r1.70 rc.subr --- rc.subr 11 Jul 2013 09:34:33 - 1.70 +++ rc.subr 16 Sep 2013 18:19:14 - @@ -221,4 +221,15 @@ unset _rcflags _rcuser pexp="${daemon}${daemon_flags:+ ${daemon_flags}}" +file ${daemon} | fgrep -q script && +{ + shebang=$(head -n 1 ${daemon} | grep '^#!' | sed 's/^#![[:blank:]]*//') + interpreter=$(echo ${shebang} | cut -d' ' -f1) + if [[ -f ${interpreter} && -x ${interpreter} ]] + then + pexp="${shebang} ${pexp}" + else + rc_err "$0: invalid interpreter: ${interpreter}" + fi +} rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c" Test scripts: #-=-= /etc/rc.d/rcshebangtester -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #!/bin/sh #daemon="/home/me/bin/rcshebangtester.dud" #daemon="/home/me/bin/rcshebangtester.ksh" daemon="/home/me/bin/rcshebangtester.pl" . /etc/rc.d/rc.subr rc_bg=YES #pexp="/bin/ksh ${daemon}" #pexp="/usr/bin/perl -T ${daemon}" #pexp="/usr/bin/perl ${daemon}" rc_cmd $1 #-=-= /home/me/bin/rcshebangtester.dud -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #!/var/empty #! /dev/null #! /usr/lib/libc.a # swap about above echo 'Busted!' #-=-= /home/me/bin/rcshebangtester.ksh =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #! /bin/ksh -x #! /bin/ksh # swap about above while true do uptime sleep 1 done #-=-= /home/me/bin/rcshebangtester.pl =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #! /usr/bin/perl -T #!/usr/bin/perl # swap about above use strict; use warnings; for(;;) { print time(), "\n"; sleep 1; } #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- $ sudo /etc/rc.d/rcshebangtester -d -f start; \ cat /var/run/rc.d/rcshebangtester; echo; sleep 5; \ sudo /etc/rc.d/rcshebangtester -d -f stop doing rc_read_runfile doing rc_check rcshebangtester doing rc_start 1379357218 1379357219 doing rc_wait start doing rc_check doing rc_write_runfile (ok) /usr/bin/perl -T /home/me/bin/rcshebangtester.pl 1379357220 1379357221 1379357222 1379357223 1379357224 doing rc_read_runfile doing rc_check rcshebangtester doing rc_stop doing rc_wait stop doing rc_check doing rc_rm_runfile (ok) #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Any other thoughts? -- Craig Skinner | http://twitter.com/Craig_Skinner | http://linkd.in/yGqkv7
Re: /etc/rc.d/rc.subr; prefix ${pexp} with script interpretor path
> Any other thoughts? Is there any way we could use something else than file(1) ? -- Antoine
Re: SQLite 3.8.0.2 diff
On Sun, Sep 15, 2013 at 11:12:44AM +0200, Landry Breuil wrote: > On Thu, Sep 12, 2013 at 02:35:02PM -0400, James Turner wrote: > > Attached is a diff to update our in tree version of SQLite to the > > recently released 3.8.0.2. SQLite 3.8.0 is needed for a fossil update > > I'm working on. > > > > I've tested this diff against my fossil update and everything appears to > > be good, the recent arc4random addition should have been maintained > > across the diff. > > > > This should probably go through a round of bulk builds. I'll express my > > thanks now for anyone who can assist by running a bulk build on a couple > > platforms. > > Doesnt seem to cause any direct fallout in an amd64 bulk build. > Thanks for running this against a bulk build. Glad to hear it doesn't seem to have any ill effects. > At some poing mozilla will also require 3.8.x, see > https://bugzilla.mozilla.org/show_bug.cgi?id=909382. Apparently there > are still bugfixes piling on this 3.8.0.x branch.. > > And note that for mozilla, we might need to turn on the new > SQLITE_ALLOW_URI_AUTHORITY define flag at some point for > https://bugzilla.mozilla.org/show_bug.cgi?id=879133 . I dont grok all the > details here, it seems a windows only issue (profiles on a cifs network > drive) but mozilla might require that flag to be set to allow building > with systemwide sqlite. > > Landry > -- James Turner
Re: /etc/rc.d/rc.subr; prefix ${pexp} with script interpretor path
On Mon, Sep 16, 2013 at 08:57:11PM +0200, Antoine Jacoutot wrote: > > Any other thoughts? > > Is there any way we could use something else than file(1) ? Well, you can look for a script using dd and matching it against the two possible signatures. e.g., dd 2>/dev/null if=file bs=4 count=1|grep -qe '#!/./ -e '#! /' I'm not sure that's too much of a progress. There might be another way to grab the first 4 bytes of a file. Off-hand I don't see any.
Re: /etc/rc.d/rc.subr; prefix ${pexp} with script interpretor path
On 2013-09-16 Mon 13:00 PM |, Antoine Jacoutot wrote: > > Heh, very interesting trick ;-) > But I don't think that is 100% full proof as is. > > e.g. > $ head -n 1 /usr/local/bin/xml2-config | cut -d! -f2 > /bin/sh > You have a white space before the interpreter. > > If you can improve that and make sure it works with all similar rc scripts > then I think it is definitely something that should be looked into. > Thanks. > Well spotted Antoine. I wrote a test script with various shebang lines of: #![space]/bin/ksh #![space][space]/bin/ksh #![space][tab]/bin/ksh -x #![tab]/bin/ksh -x #![space]/usr/bin/perl #![space][space]/usr/bin/perl #![space][tab]/usr/bin/perl -T #![tab][tab][tab]/usr/bin/perl -T This seems to work with these test scenarios (as seen in /var/run/rc.d/rcshebangtester): Index: rc.subr === RCS file: /cvs/src/etc/rc.d/rc.subr,v retrieving revision 1.70 diff -u -r1.70 rc.subr --- rc.subr 11 Jul 2013 09:34:33 - 1.70 +++ rc.subr 16 Sep 2013 12:09:42 - @@ -221,4 +221,9 @@ unset _rcflags _rcuser pexp="${daemon}${daemon_flags:+ ${daemon_flags}}" +file ${daemon} | fgrep -q script && +{ + shebang=$(head -n 1 ${daemon} | cut -d! -f2 | sed 's/^[[:blank:]]*//') + pexp="${shebang} ${pexp}" +} rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c" Would it also be worthwhile verifying the 1st element of $shebang is executable before prefixing $pexp? Cheers, -- Craig Skinner | http://twitter.com/Craig_Skinner | http://linkd.in/yGqkv7
Re: /etc/rc.d/rc.subr; prefix ${pexp} with script interpretor path
On Mon, Sep 16, 2013 at 11:50:50AM +0100, Craig R. Skinner wrote: > For scripts (perl, shell, whatever...), prefix ${pexp} with the script's > interpretor path as defined by the script. > > No need to override ${pexp} in the daemon's rc file. Heh, very interesting trick ;-) But I don't think that is 100% full proof as is. e.g. $ head -n 1 /usr/local/bin/xml2-config | cut -d! -f2 /bin/sh You have a white space before the interpreter. If you can improve that and make sure it works with all similar rc scripts then I think it is definitely something that should be looked into. Thanks. -- Antoine
/etc/rc.d/rc.subr; prefix ${pexp} with script interpretor path
For scripts (perl, shell, whatever...), prefix ${pexp} with the script's interpretor path as defined by the script. No need to override ${pexp} in the daemon's rc file. Index: rc.subr === RCS file: /cvs/src/etc/rc.d/rc.subr,v retrieving revision 1.70 diff -u -r1.70 rc.subr --- rc.subr 11 Jul 2013 09:34:33 - 1.70 +++ rc.subr 16 Sep 2013 10:26:09 - @@ -221,4 +221,9 @@ unset _rcflags _rcuser pexp="${daemon}${daemon_flags:+ ${daemon_flags}}" +file ${daemon} | fgrep -q script && +{ + shebang=$(head -n 1 ${daemon} | cut -d! -f2) + pexp="${shebang} ${pexp}" +} rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c" e.g. Remove pexp= from /etc/rc.d/greyscanner: --- greyscanner.pkg Mon Aug 19 14:46:01 2013 +++ greyscanner Mon Sep 16 11:30:33 2013 @@ -6,7 +6,6 @@ . /etc/rc.d/rc.subr -pexp="/usr/bin/perl ${daemon}" rc_reload=NO rc_cmd $1 $ sudo /etc/rc.d/greyscanner restart greyscanner(ok) greyscanner(ok) $ cat /var/run/rc.d/greyscanner /usr/bin/perl /usr/local/sbin/greyscanner $ ps auxwww | fgrep greyscanner root 25280 0.0 0.6 4896 2920 ?? Is11:35AM0:00.04 /usr/bin/perl /usr/local/sbin/greyscanner Cheers, -- Craig Skinner | http://twitter.com/Craig_Skinner | http://linkd.in/yGqkv7