From 98304a9268ecfea6efde439575a06acb9f1dbe48 Mon Sep 17 00:00:00 2001 From: Evan Susarret Date: Wed, 24 Apr 2013 06:18:21 -0300 Subject: ZFSROOT not hardcoded to zpool or dataset 'tank' For ZFS root readonly case, the WHEREISROOT variable was grep-ing for 'tank', expecting a zpool with that name. A workaround of naming a dataset 'tank', for example, 'sys/ROOT/tank' or 'sys/tank/pfSense' is compatible, however this shouldn't be hardcoded in. My proposed change replaces WHEREISROOT with ZFSROOT using awk. I noticed awk is used elsewhere in this script. However it is still simple code that is not resilient against unexpected circumstances, let alone failure. --- etc/rc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/rc b/etc/rc index 70996d8..9546b73 100755 --- a/etc/rc +++ b/etc/rc @@ -68,9 +68,9 @@ echo "Mounting filesystems..." # Handle ZFS read-only case if [ "$PLATFORM" = "pfSense" ]; then if [ -f /usr/bin/grep ]; then - WHEREISROOT=`/sbin/mount | /usr/bin/grep " / " | /usr/bin/grep "tank" | /usr/bin/cut -d' ' -f1` - if [ "$WHEREISROOT" != "" ]; then - /sbin/zfs set readonly=off $WHEREISROOT + ZFSROOT=`/sbin/mount | /usr/bin/grep " / " | /usr/bin/awk -F ' on ' '{print $1}'` + if [ "$ZFSROOT" != "" ]; then + echo /sbin/zfs set readonly=off $ZFSROOT fi fi fi -- cgit v1.1 From c56caf594bc223d48af3afdc365d227588f29f4f Mon Sep 17 00:00:00 2001 From: Evan Susarret Date: Sun, 28 Apr 2013 06:43:17 -0400 Subject: Use 'zfs mount' to get ZFSROOT dataset using just zfs, grep, and cut, with a simple regexp --- etc/rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc b/etc/rc index 9546b73..e2c3847 100755 --- a/etc/rc +++ b/etc/rc @@ -68,7 +68,7 @@ echo "Mounting filesystems..." # Handle ZFS read-only case if [ "$PLATFORM" = "pfSense" ]; then if [ -f /usr/bin/grep ]; then - ZFSROOT=`/sbin/mount | /usr/bin/grep " / " | /usr/bin/awk -F ' on ' '{print $1}'` + ZFSROOT=`/sbin/zfs mount | /usr/bin/grep ' /$' | /usr/bin/cut -d ' ' -f 1` if [ "$ZFSROOT" != "" ]; then echo /sbin/zfs set readonly=off $ZFSROOT fi -- cgit v1.1