diff options
author | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-05-06 17:03:30 +1000 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-08-06 14:08:33 +1000 |
commit | acc5ace6e58db2f3dceb1f7a27d0fc1fb29c4a27 (patch) | |
tree | d5577259029ad08d93de57e0a3560b6271627e8a /discover | |
parent | 79bfd11f662fcf46bd4ae58a0aab993cbe158dbe (diff) | |
download | petitboot-acc5ace6e58db2f3dceb1f7a27d0fc1fb29c4a27.zip petitboot-acc5ace6e58db2f3dceb1f7a27d0fc1fb29c4a27.tar.gz |
Make read-only guarantee user-settable
Create a new Petitboot option 'petitboot,write?' that specifies whether
the system is allowed to mount devices read-write. The option can be
toggled by the user in the nc-config screen.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Diffstat (limited to 'discover')
-rw-r--r-- | discover/device-handler.c | 5 | ||||
-rw-r--r-- | discover/platform-powerpc.c | 11 | ||||
-rw-r--r-- | discover/platform.c | 1 |
3 files changed, 17 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c index 31cbcc2..4f7a7b7 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -1391,10 +1391,15 @@ static int umount_device(struct discover_device *dev) int device_request_write(struct discover_device *dev, bool *release) { const char *fstype, *device_path; + const struct config *config; int rc; *release = false; + config = config_get(); + if (!config->allow_writes) + return -1; + if (!dev->mounted) return -1; diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 2b3b043..fc96305 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -53,6 +53,7 @@ static const char *known_params[] = { "petitboot,bootdevs", "petitboot,language", "petitboot,debug?", + "petitboot,write?", NULL, }; @@ -548,6 +549,10 @@ static void populate_config(struct platform_powerpc *platform, val = get_param(platform, "petitboot,debug?"); config->debug = val && !strcmp(val, "true"); } + + val = get_param(platform, "petitboot,write?"); + if (val) + config->allow_writes = !strcmp(val, "true"); } static char *iface_config_str(void *ctx, struct interface_config *config) @@ -707,6 +712,12 @@ static int update_config(struct platform_powerpc *platform, val = config->lang ?: ""; update_string_config(platform, "petitboot,language", val); + if (config->allow_writes == defaults->allow_writes) + val = ""; + else + val = config->allow_writes ? "true" : "false"; + update_string_config(platform, "petitboot,write?", val); + update_network_config(platform, config); update_bootdev_config(platform, config); diff --git a/discover/platform.c b/discover/platform.c index 74e2a82..b1d0f19 100644 --- a/discover/platform.c +++ b/discover/platform.c @@ -108,6 +108,7 @@ void config_set_defaults(struct config *config) config->network.n_dns_servers = 0; config->safe_mode = false; config->lang = NULL; + config->allow_writes = true; config->n_autoboot_opts = 2; config->autoboot_opts = talloc_array(config, struct autoboot_option, |