Hi Mattieu, Mattieu Baptiste wrote on Fri, Mar 18, 2011 at 04:28:40PM +0100:
> This diff enables daily(8) to use DUID instead of pathname in > /etc/fstab for backing up root filesystem. I see the point, but i am not thrilled. > I'm not a shell expert... comments are welcome. Already now, the /altroot handling is the worst part of daily(8). I guess i may say that without insulting anybody, see http://www.openbsd.org/cgi-bin/cvsweb/src/etc/daily?annotate=HEAD http://www.openbsd.org/cgi-bin/cvsweb/src/etc/daily.diff?r1=1.63;r2=1.64 The problem with your patch is not that it needs to be done better, but that the tools available in daily(8) are hardly suited to the job. So i'm reluctant to add more shell code in order to add more functionality (the last additions only aimed at improving safety, as far as that goes with this style of code). After completing http://www.openbsd.org/cgi-bin/cvsweb/src/libexec/security/ the /altroot stuff in daily(8) is a good next candidate for code to be moved to Perl. To speed up the process, contributions to security(8) are welcome. Yours, Ingo > Index: daily > =================================================================== > RCS file: /cvs/src/etc/daily,v > retrieving revision 1.68 > diff -u -r1.68 daily > --- daily 22 Sep 2010 13:01:10 -0000 1.68 > +++ daily 18 Mar 2011 15:15:57 -0000 > @@ -97,11 +97,22 @@ > rootbak=`awk '$2 == "/altroot" && $1 ~ /^\/dev\// && $3 == "ffs" && \ > $4 ~ /xx/ \ > { print substr($1, 6) }' < /etc/fstab` > - if [ -z "$rootbak" ]; then > - echo "No xx ffs /altroot device found in the fstab(5)." > - break > + if [ ! -z $rootbak ]; then > + bakdisk=${rootbak%[a-p]} > + else > + duid=`awk '$2 == "/altroot" && $1 ~ /^.*\..*/ && \ > + $3 == "ffs" && $4 ~ /xx/ \ > + { print substr($1, 1, 18) }' < /etc/fstab` > + if [ -z "$duid" ]; then > + echo "No xx ffs /altroot device found in the fstab(5)." > + break > + fi > + duiddisk=`echo $duid | awk '{ print substr($1, 1, 16) }'` > + bakdisk=`sysctl -n hw.disknames | \ > + sed -e 's/.*[,=]\(.*\):'$duiddisk'.*/\1/'` > + rootbak=`echo $duid | \ > + awk '{ print "'$bakdisk'"substr($1, 18, 1) }'` > fi > - bakdisk=${rootbak%[a-p]} > sysctl -n hw.disknames | grep -Fqw $bakdisk || break > bakpart=${rootbak#$bakdisk} > baksize=`disklabel $bakdisk 2>/dev/null | \
