From acc5ace6e58db2f3dceb1f7a27d0fc1fb29c4a27 Mon Sep 17 00:00:00 2001 From: Samuel Mendoza-Jonas Date: Wed, 6 May 2015 17:03:30 +1000 Subject: 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 --- lib/pb-config/pb-config.c | 2 ++ lib/pb-protocol/pb-protocol.c | 9 +++++++++ lib/types/types.h | 2 ++ 3 files changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c index 98a6078..8200883 100644 --- a/lib/pb-config/pb-config.c +++ b/lib/pb-config/pb-config.c @@ -77,6 +77,8 @@ struct config *config_copy(void *ctx, const struct config *src) dest->ipmi_bootdev = src->ipmi_bootdev; dest->ipmi_bootdev_persistent = src->ipmi_bootdev_persistent; + dest->allow_writes = src->allow_writes; + if (src->lang && strlen(src->lang)) dest->lang = talloc_strdup(dest, src->lang); else diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index 69ea35d..7d45f51 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -290,6 +290,8 @@ int pb_protocol_config_len(const struct config *config) len += 4 + 4; /* ipmi_bootdev, ipmi_bootdev_persistent */ + len += 4; /* allow_writes */ + len += 4 + optional_strlen(config->lang); return len; @@ -502,6 +504,9 @@ int pb_protocol_serialise_config(const struct config *config, *(uint32_t *)pos = config->ipmi_bootdev_persistent; pos += 4; + *(uint32_t *)pos = config->allow_writes; + pos += 4; + pos += pb_protocol_serialise_string(pos, config->lang); assert(pos <= buf + buf_len); @@ -958,6 +963,10 @@ int pb_protocol_deserialise_config(struct config *config, goto out; config->ipmi_bootdev_persistent = !!tmp; + if (read_u32(&pos, &len, &tmp)) + goto out; + config->allow_writes = !!tmp; + if (read_string(config, &pos, &len, &str)) goto out; diff --git a/lib/types/types.h b/lib/types/types.h index e5c7e3e..f7e4752 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -146,6 +146,8 @@ struct config { unsigned int ipmi_bootdev; bool ipmi_bootdev_persistent; + bool allow_writes; + char *lang; /* not user-settable */ -- cgit v1.2.1