From patchwork Mon Nov 30 23:09:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Champetier X-Patchwork-Id: 550555 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B889514016A for ; Tue, 1 Dec 2015 10:15:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=os91fdAk; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 51AE928C763; Tue, 1 Dec 2015 00:11:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id D6BEC28AD25 for ; Tue, 1 Dec 2015 00:09:50 +0100 (CET) X-policyd-weight: using cached result; rate:hard: -8.5 Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Tue, 1 Dec 2015 00:09:41 +0100 (CET) Received: by wmww144 with SMTP id w144so158730249wmw.0 for ; Mon, 30 Nov 2015 15:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZQfX+OhDg63wRCxN3yisc8AzGcHT+cAjRemPp8rv/PQ=; b=os91fdAkr1p+iefvuEraFOzknH+mtl1eDjlatgzYgCCzEduBvO7YOWVA8euAD4P114 /A50VxAa4hjnNQ0CmgjFcn+0dWbbF4S7K6jZH9JgSbc83zUjLQREx3bGLjVZqoznHraH VHZIB1gnL2wZWHPCuMFC7Godmu06MVpUK4R9HfqJd+EiHlFvXDBoK0M9kTg9iz//TTHs hsvVS9fP41LE8aCU6K4bw63fKVadIHge+LS1TJVfoJSNWIEV1EzL30poZUft/ahoEE3N 8g6If8hgR0Eqf+w4kfS2e9IVk7LWIwNjMovyQcHa7pansWtaxJ2R7NAe7DUIjoyYohta e29A== X-Received: by 10.194.6.225 with SMTP id e1mr9373859wja.67.1448924984791; Mon, 30 Nov 2015 15:09:44 -0800 (PST) Received: from ubuntu1404.lxcnattst (ns623510.ovh.net. [5.135.134.9]) by smtp.gmail.com with ESMTPSA id pn6sm48769372wjb.15.2015.11.30.15.09.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Nov 2015 15:09:43 -0800 (PST) From: Etienne CHAMPETIER To: OpenWrt Development List Date: Mon, 30 Nov 2015 23:09:26 +0000 Message-Id: <1448924967-63976-9-git-send-email-champetier.etienne@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448924967-63976-1-git-send-email-champetier.etienne@gmail.com> References: <1448924967-63976-1-git-send-email-champetier.etienne@gmail.com> Subject: [OpenWrt-Devel] [PATCH procd 8/9] ujail: split name (-n) and hostname (-h) options X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Etienne CHAMPETIER --- jail/jail.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jail/jail.c b/jail/jail.c index 97ddaab..541363a 100644 --- a/jail/jail.c +++ b/jail/jail.c @@ -35,10 +35,11 @@ #include #define STACK_SIZE (1024 * 1024) -#define OPT_ARGS "S:C:n:r:w:d:psuloc" +#define OPT_ARGS "S:C:n:h:r:w:d:psuloc" static struct { char *name; + char *hostname; char **jail_argv; char *seccomp; char *capabilities; @@ -216,6 +217,7 @@ static void usage(void) fprintf(stderr, " -c\t\tset PR_SET_NO_NEW_PRIVS\n"); fprintf(stderr, " -n \tthe name of the jail\n"); fprintf(stderr, "namespace jail options:\n"); + fprintf(stderr, " -h \tchange the hostname of the jail\n"); fprintf(stderr, " -r \treadonly files that should be staged\n"); fprintf(stderr, " -w \twriteable files that should be staged\n"); fprintf(stderr, " -p\t\tjail has /proc\n"); @@ -255,8 +257,8 @@ static int exec_jail(void) static int spawn_jail(void *_notused) { - if (opts.name && sethostname(opts.name, strlen(opts.name))) { - ERROR("failed to sethostname: %s\n", strerror(errno)); + if (opts.hostname && sethostname(opts.hostname, strlen(opts.hostname))) { + ERROR("sethostname(%s) failed: %s\n", opts.hostname, strerror(errno)); } if (build_jail_fs()) { @@ -334,6 +336,9 @@ int main(int argc, char **argv) case 'n': opts.name = optarg; break; + case 'h': + opts.hostname = optarg; + break; case 'r': opts.namespace = 1; add_path_and_deps(optarg, 1, 0, 0);