From 81e1ace59ec86842bb6f30dc0e44afc00cd7f79f Mon Sep 17 00:00:00 2001 From: Etienne CHAMPETIER Date: Mon, 30 Nov 2015 23:09:23 +0000 Subject: [PATCH] instance, ujail: wire remount / read only option (-o) Signed-off-by: Etienne CHAMPETIER --- service/instance.c | 10 ++++++++++ service/instance.h | 1 + 2 files changed, 11 insertions(+) diff --git a/service/instance.c b/service/instance.c index c478d4b..26faa9a 100644 --- a/service/instance.c +++ b/service/instance.c @@ -81,6 +81,7 @@ enum { JAIL_ATTR_SYSFS, JAIL_ATTR_UBUS, JAIL_ATTR_LOG, + JAIL_ATTR_RONLY, JAIL_ATTR_MOUNT, __JAIL_ATTR_MAX, }; @@ -91,6 +92,7 @@ static const struct blobmsg_policy jail_attr[__JAIL_ATTR_MAX] = { [JAIL_ATTR_SYSFS] = { "sysfs", BLOBMSG_TYPE_BOOL }, [JAIL_ATTR_UBUS] = { "ubus", BLOBMSG_TYPE_BOOL }, [JAIL_ATTR_LOG] = { "log", BLOBMSG_TYPE_BOOL }, + [JAIL_ATTR_RONLY] = { "ronly", BLOBMSG_TYPE_BOOL }, [JAIL_ATTR_MOUNT] = { "mount", BLOBMSG_TYPE_TABLE }, }; @@ -198,6 +200,9 @@ jail_run(struct service_instance *in, char **argv) if (jail->log) argv[argc++] = "-l"; + if (jail->ronly) + argv[argc++] = "-o"; + blobmsg_list_for_each(&jail->mount, var) { const char *type = blobmsg_data(var->data); @@ -655,6 +660,10 @@ instance_jail_parse(struct service_instance *in, struct blob_attr *attr) jail->log = blobmsg_get_bool(tb[JAIL_ATTR_LOG]); jail->argc++; } + if (tb[JAIL_ATTR_RONLY]) { + jail->ronly = blobmsg_get_bool(tb[JAIL_ATTR_RONLY]); + jail->argc++; + } if (tb[JAIL_ATTR_MOUNT]) { struct blob_attr *cur; int rem; @@ -943,6 +952,7 @@ void instance_dump(struct blob_buf *b, struct service_instance *in, int verbose) blobmsg_add_u8(b, "sysfs", in->jail.sysfs); blobmsg_add_u8(b, "ubus", in->jail.ubus); blobmsg_add_u8(b, "log", in->jail.log); + blobmsg_add_u8(b, "ronly", in->jail.ronly); blobmsg_close_table(b, r); if (!avl_is_empty(&in->jail.mount.avl)) { struct blobmsg_list_node *var; diff --git a/service/instance.h b/service/instance.h index 5a76841..43844dc 100644 --- a/service/instance.h +++ b/service/instance.h @@ -27,6 +27,7 @@ struct jail { bool sysfs; bool ubus; bool log; + bool ronly; char *name; struct blobmsg_list mount; int argc; -- 2.11.0