From 426929aea907421301aa58719674e339aa356b53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?=
Date: Tue, 6 Jun 2017 10:54:16 +0200
Subject: [PATCH] lxc: add possibility to define init uid/gid
Users may want to run the init command of a container as a special
user / group. This is achieved by adding and
elements. Note that the user can either provide a name or an ID to
specify the user / group to be used.
This commit also fixes a side effect of being able to run the command
as a non-root user: the user needs rights on the tty to allow shell
job control.
Reviewed-by: Daniel P. Berrange
---
docs/formatdomain.html.in | 9 +++++
docs/schemas/domaincommon.rng | 14 ++++++++
src/conf/domain_conf.c | 9 +++++
src/conf/domain_conf.h | 2 ++
src/lxc/lxc_container.c | 52 +++++++++++++++++++++++++++
tests/lxcxml2xmldata/lxc-inituser.xml | 31 ++++++++++++++++
tests/lxcxml2xmltest.c | 1 +
7 files changed, 118 insertions(+)
create mode 100644 tests/lxcxml2xmldata/lxc-inituser.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c155e2ae06..7f4bc1d212 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -334,6 +334,13 @@
To set a custom work directory for the init, use the initdir
element.
+
+ To run the init command as a given user or group, use the inituser
+ or initgroup elements respectively. Both elements can be provided
+ either a user (resp. group) id or a name. Prefixing the user or group id with
+ a + will force it to be considered like a numeric value. Without
+ this, it will be first tried as a user or group name.
+