diff options
author | jim-p <jimp@pfsense.org> | 2012-11-12 15:41:36 -0500 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2012-11-12 15:41:36 -0500 |
commit | 7b2290139d7a52e2a77b76dcae6a524c1d959ecd (patch) | |
tree | 5c965a1636468e724c365043526fdebba7e4969e | |
parent | 1bceebd0ea4feb40cd9a9f0179cd093734b26e7e (diff) | |
download | pfsense-7b2290139d7a52e2a77b76dcae6a524c1d959ecd.zip pfsense-7b2290139d7a52e2a77b76dcae6a524c1d959ecd.tar.gz |
Add button to switch between read/write and read-only on Diag > NanoBSD; Add setting to keep the media read/write at all times; Add indication of ro/rw status on Dashboard.
-rw-r--r-- | etc/inc/config.lib.inc | 11 | ||||
-rwxr-xr-x | usr/local/www/diag_nanobsd.php | 51 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/system_information.widget.php | 3 |
3 files changed, 60 insertions, 5 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc index bcc26f5..dc57b41 100644 --- a/etc/inc/config.lib.inc +++ b/etc/inc/config.lib.inc @@ -302,13 +302,16 @@ EOD; ******/ /* mount flash card read/write */ function conf_mount_rw() { - global $g; + global $g, $config; /* do not mount on cdrom platform */ if($g['platform'] == "cdrom" or $g['platform'] == "pfSense") return; - if (refcount_reference(1000) > 1) + if (!isset($config['system']['nanobsd_force_rw']) && (refcount_reference(1000) > 1)) + return; + + if (isset($config['system']['nanobsd_force_rw']) && is_writable("/")) return; $status = mwexec("/sbin/mount -u -w -o sync,noatime {$g['cf_path']}"); @@ -340,12 +343,12 @@ function conf_mount_rw() { * null ******/ function conf_mount_ro() { - global $g; + global $g, $config; /* Do not trust $g['platform'] since this can be clobbered during factory reset. */ $platform = trim(file_get_contents("/etc/platform")); /* do not umount on cdrom or pfSense platforms */ - if($platform == "cdrom" or $platform == "pfSense") + if($platform == "cdrom" or $platform == "pfSense" or isset($config['system']['nanobsd_force_rw'])) return; if (refcount_unreference(1000) > 0) diff --git a/usr/local/www/diag_nanobsd.php b/usr/local/www/diag_nanobsd.php index 4289eda..353f9ba 100755 --- a/usr/local/www/diag_nanobsd.php +++ b/usr/local/www/diag_nanobsd.php @@ -108,6 +108,25 @@ if (isset($_POST['dhcpbackup'])) { install_cron_job("/etc/rc.backup_dhcpleases.sh", ($config['system']['dhcpbackup'] > 0), $minute="0", "*/{$config['system']['dhcpbackup']}"); } +if ($_POST['changero']) { + if (is_writable("/")) { + conf_mount_ro(); + } else { + conf_mount_rw(); + } +} + +if ($_POST['setrw']) { + if (isset($_POST['nanobsd_force_rw'])) { + conf_mount_rw(); + $config['system']['nanobsd_force_rw'] = true; + } else { + unset($config['system']['nanobsd_force_rw']); + } + + write_config("Changed Permanent Read/Write Setting"); + conf_mount_ro(); +} if ($savemsg) print_info_box($savemsg) @@ -155,6 +174,38 @@ if ($savemsg) <td colspan="2" valign="top" class=""> </td> </tr> <tr> + <td colspan="2" valign="top" class="listtopic"><?=gettext("Media Read/Write Status");?></td> + </tr> + <tr> + <td valign="top" class="vncell">Current Read/Write Status:</td> + <td valign="top" class="vncell"> + <form action="diag_nanobsd.php" method="post" name="iform"> + <?php if (is_writable("/")) { + echo gettext("Read/Write"); + if (!isset($config['system']['nanobsd_force_rw'])) + echo "<br/><input type='submit' name='changero' value='" . gettext("Switch to Read-Only") . "'>"; + } else { + echo gettext("Read-Only"); + if (!isset($config['system']['nanobsd_force_rw'])) + echo "<br/><input type='submit' name='changero' value='" . gettext("Switch to Read/Write") . "'>"; + } ?> + </form> + <br/><?php echo gettext("NOTE: This setting is only temporary, and can be switched dynamically in the background."); ?> + </td> + </tr> + <tr> + <td valign="top" class="vncell">Permanent Read/Write:</td> + <td valign="top" class="vncell"> + <form action="diag_nanobsd.php" method="post" name="iform"> + <input type="checkbox" name="nanobsd_force_rw" <?php if (isset($config['system']['nanobsd_force_rw'])) echo "checked"; ?>> <?php echo gettext("Keep media mounted read/write at all times.") ?> + <br/><input type='submit' name='setrw' value='<?php echo gettext("Save") ?>'> + </form> + </td> + </tr> + <tr> + <td colspan="2" valign="top" class=""> </td> + </tr> + <tr> <td colspan="2" valign="top" class="listtopic"><?=gettext("Duplicate bootup slice to alternate");?></td> </tr> <tr> diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index 2a7055d..82f3415 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -120,11 +120,12 @@ $curcfg = $config['system']['firmware']; global $GLABEL_SLICE, $UFS_ID, $OLD_UFS_ID, $BOOTFLASH; global $BOOT_DEVICE, $REAL_BOOT_DEVICE, $BOOT_DRIVE, $ACTIVE_SLICE; nanobsd_detect_slice_info(); + $rw = is_writable("/") ? "(rw)" : "(ro)"; ?> <tr> <td width="25%" class="vncellt">NanoBSD Boot Slice</td> <td width="75%" class="listr"> - <?=htmlspecialchars(nanobsd_friendly_slice_name($BOOT_DEVICE));?> / <?=htmlspecialchars($BOOTFLASH);?> + <?=htmlspecialchars(nanobsd_friendly_slice_name($BOOT_DEVICE));?> / <?=htmlspecialchars($BOOTFLASH);?> <?php echo $rw; ?> <?php if ($BOOTFLASH != $ACTIVE_SLICE): ?> <br/><br/>Next Boot:<br/> <?=htmlspecialchars(nanobsd_friendly_slice_name($GLABEL_SLICE));?> / <?=htmlspecialchars($ACTIVE_SLICE);?> |