Hi, RD Thrush wrote on Sun, May 08, 2011 at 11:03:32AM -0400:
> I noticed that ROOTBACKUP stopped working when I converted the /altroot > fstab entry to a disklabel UID. The attached patch seems to work for me > but I'm sure there's a better way. Indeed. The existing code is already scary, and this makes it worse. Clearly, at least part of daily(8) has to be rewritten in Perl, and clearly, the ROOTBACKUP handling is part of the part. However, how exactly that should be done depends on how much exactly we want to rewrite. I think ROOTBACKUP is the only part that really requires rewriting, the rest seems reasonably simple such that i don't see a real problem with using sh(1) for the rest. If we decide to just rewrite the ROOTBACKUP handling, i'd suggest simply moving it from daily(8) to security(8). It is functionally similar to what security(8) already does (consider changelist(5)). Besides, one might consider backing up critical data as related to security. Of course, one could also move the whole thing to perl(1), but right now, i see little benefit. Regarding the question of what to move where, feedback from other developers is welcome. Yours, Ingo > Index: src/etc/daily > =================================================================== > RCS file: /a8v/pub/cvsroot/OpenBSD/src/etc/daily,v > retrieving revision 1.71 > diff -u -p -u -p -r1.71 daily > --- src/etc/daily 23 Apr 2011 19:35:53 -0000 1.71 > +++ src/etc/daily 8 May 2011 14:39:23 -0000 > @@ -94,16 +94,33 @@ fi > # use it as a backup root filesystem to be updated daily. > next_part "Backing up root filesystem:" > while [ "X$ROOTBACKUP" = X1 ]; do > - 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 > + altroot=`awk '$2 == "/altroot" && $3 == "ffs" && $4 ~ /xx/ \ > + { print }' < /etc/fstab` > + HAS_DUID=$(echo $altroot | grep -v '^/dev/') > + if [ "X$HAS_DUID" = "X" ]; then > + rootbak=`echo $altroot | awk '$2 == "/altroot" && \ > + $1 ~ /^\/dev\// && $3 == "ffs" && \ > + $4 ~ /xx/ \ > + { print substr($1, 6) }'` > + if [ -z "$rootbak" ]; then > + echo "No xx ffs /altroot device found in the fstab(5)." > + break > + fi > + bakdisk=${rootbak%[a-p]} > + sysctl -n hw.disknames | grep -Fqw $bakdisk || break > + bakpart=${rootbak#$bakdisk} > + else > + duidbak=$(echo ${altroot} | cut -d\. -f1) > + bakpart=$(echo ${altroot} | awk '{print $1}' | cut -d\. -f2) > + bakdisk=$(sysctl -n hw.disknames | tr "," "\n" \ > + | grep -Fw $duidbak | cut -d: -f1) > + if [ -z "$bakdisk" ]; then > + echo "No xx ffs /altroot duid found in the fstab(5)." > + break > + fi > + rootbak="$bakdisk$bakpart" > + sysctl -n hw.disknames | grep -Fqw $bakdisk || break > fi > - bakdisk=${rootbak%[a-p]} > - sysctl -n hw.disknames | grep -Fqw $bakdisk || break > - bakpart=${rootbak#$bakdisk} > baksize=`disklabel $bakdisk 2>/dev/null | \ > awk -v "part=$bakpart:" '$1 == part { print $2 }'` > rootdev=`mount | awk '$3 == "/" && $1 ~ /^\/dev\// && $5 == "ffs" \