[OpenWrt-Devel] [PATCH procd 9/9] instance, ujail: wire hostname (-h) option

Etienne CHAMPETIER champetier.etienne at gmail.com
Mon Nov 30 18:09:27 EST 2015


Signed-off-by: Etienne CHAMPETIER <champetier.etienne at gmail.com>
---
 service/instance.c | 13 +++++++++++++
 service/instance.h |  1 +
 2 files changed, 14 insertions(+)

diff --git a/service/instance.c b/service/instance.c
index ad0d284..bca36e1 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -81,6 +81,7 @@ static const struct blobmsg_policy instance_attr[__INSTANCE_ATTR_MAX] = {
 
 enum {
 	JAIL_ATTR_NAME,
+	JAIL_ATTR_HOSTNAME,
 	JAIL_ATTR_PROCFS,
 	JAIL_ATTR_SYSFS,
 	JAIL_ATTR_UBUS,
@@ -92,6 +93,7 @@ enum {
 
 static const struct blobmsg_policy jail_attr[__JAIL_ATTR_MAX] = {
 	[JAIL_ATTR_NAME] = { "name", BLOBMSG_TYPE_STRING },
+	[JAIL_ATTR_HOSTNAME] = { "hostname", BLOBMSG_TYPE_STRING },
 	[JAIL_ATTR_PROCFS] = { "procfs", BLOBMSG_TYPE_BOOL },
 	[JAIL_ATTR_SYSFS] = { "sysfs", BLOBMSG_TYPE_BOOL },
 	[JAIL_ATTR_UBUS] = { "ubus", BLOBMSG_TYPE_BOOL },
@@ -187,6 +189,11 @@ jail_run(struct service_instance *in, char **argv)
 		argv[argc++] = jail->name;
 	}
 
+	if (jail->hostname) {
+		argv[argc++] = "-h";
+		argv[argc++] = jail->hostname;
+	}
+
 	if (in->seccomp) {
 		argv[argc++] = "-S";
 		argv[argc++] = in->seccomp;
@@ -656,6 +663,10 @@ instance_jail_parse(struct service_instance *in, struct blob_attr *attr)
 		jail->name = blobmsg_get_string(tb[JAIL_ATTR_NAME]);
 		jail->argc += 2;
 	}
+	if (tb[JAIL_ATTR_HOSTNAME]) {
+		jail->hostname = blobmsg_get_string(tb[JAIL_ATTR_HOSTNAME]);
+		jail->argc += 2;
+	}
 	if (tb[JAIL_ATTR_PROCFS]) {
 		jail->procfs = blobmsg_get_bool(tb[JAIL_ATTR_PROCFS]);
 		jail->argc++;
@@ -981,6 +992,8 @@ void instance_dump(struct blob_buf *b, struct service_instance *in, int verbose)
 		void *r = blobmsg_open_table(b, "jail");
 		if (in->jail.name)
 			blobmsg_add_string(b, "name", in->jail.name);
+		if (in->jail.hostname)
+			blobmsg_add_string(b, "hostname", in->jail.hostname);
 		blobmsg_add_u8(b, "procfs", in->jail.procfs);
 		blobmsg_add_u8(b, "sysfs", in->jail.sysfs);
 		blobmsg_add_u8(b, "ubus", in->jail.ubus);
diff --git a/service/instance.h b/service/instance.h
index 0af9680..df4a5d3 100644
--- a/service/instance.h
+++ b/service/instance.h
@@ -29,6 +29,7 @@ struct jail {
 	bool log;
 	bool ronly;
 	char *name;
+	char *hostname;
 	struct blobmsg_list mount;
 	int argc;
 };
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list