Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
72bb04e4
Commit
72bb04e4
authored
Aug 19, 2015
by
Patrick Toomey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for setting lxc-execute init UID/GID via configuration file
Signed-off-by:
Patrick Toomey
<
ptoomey3@biasedcoin.com
>
parent
fd9f399b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
3 deletions
+26
-3
conf.c
src/lxc/conf.c
+5
-0
conf.h
src/lxc/conf.h
+2
-2
confile.c
src/lxc/confile.c
+19
-1
No files found.
src/lxc/conf.c
View file @
72bb04e4
...
@@ -2604,6 +2604,11 @@ struct lxc_conf *lxc_conf_init(void)
...
@@ -2604,6 +2604,11 @@ struct lxc_conf *lxc_conf_init(void)
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
new
->
inherit_ns_fd
[
i
]
=
-
1
;
new
->
inherit_ns_fd
[
i
]
=
-
1
;
/* if running in a new user namespace, init and COMMAND
* default to running as UID/GID 0 when using lxc-execute */
new
->
init_uid
=
0
;
new
->
init_gid
=
0
;
return
new
;
return
new
;
}
}
...
...
src/lxc/conf.h
View file @
72bb04e4
...
@@ -366,8 +366,8 @@ struct lxc_conf {
...
@@ -366,8 +366,8 @@ struct lxc_conf {
/* init command */
/* init command */
char
*
init_cmd
;
char
*
init_cmd
;
/* if running in a new user namespace, the UID/GID that
COMMAND for
/* if running in a new user namespace, the UID/GID that
init and COMMAND
*
lxc-execute should run under
*/
*
should run under when using lxc-execute
*/
uid_t
init_uid
;
uid_t
init_uid
;
gid_t
init_gid
;
gid_t
init_gid
;
};
};
...
...
src/lxc/confile.c
View file @
72bb04e4
...
@@ -104,6 +104,8 @@ static int config_start(const char *, const char *, struct lxc_conf *);
...
@@ -104,6 +104,8 @@ static int config_start(const char *, const char *, struct lxc_conf *);
static
int
config_group
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
config_group
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
config_environment
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
config_environment
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
config_init_cmd
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
config_init_cmd
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
config_init_uid
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
config_init_gid
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
struct
lxc_config_t
config
[]
=
{
static
struct
lxc_config_t
config
[]
=
{
...
@@ -168,6 +170,8 @@ static struct lxc_config_t config[] = {
...
@@ -168,6 +170,8 @@ static struct lxc_config_t config[] = {
{
"lxc.group"
,
config_group
},
{
"lxc.group"
,
config_group
},
{
"lxc.environment"
,
config_environment
},
{
"lxc.environment"
,
config_environment
},
{
"lxc.init_cmd"
,
config_init_cmd
},
{
"lxc.init_cmd"
,
config_init_cmd
},
{
"lxc.init_uid"
,
config_init_uid
},
{
"lxc.init_gid"
,
config_init_gid
},
};
};
struct
signame
{
struct
signame
{
...
@@ -1034,11 +1038,25 @@ static int config_init_cmd(const char *key, const char *value,
...
@@ -1034,11 +1038,25 @@ static int config_init_cmd(const char *key, const char *value,
return
config_path_item
(
&
lxc_conf
->
init_cmd
,
value
);
return
config_path_item
(
&
lxc_conf
->
init_cmd
,
value
);
}
}
static
int
config_init_uid
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
)
{
lxc_conf
->
init_uid
=
atoi
(
value
);
return
0
;
}
static
int
config_init_gid
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
)
{
lxc_conf
->
init_gid
=
atoi
(
value
);
return
0
;
}
static
int
config_hook
(
const
char
*
key
,
const
char
*
value
,
static
int
config_hook
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
)
struct
lxc_conf
*
lxc_conf
)
{
{
char
*
copy
;
char
*
copy
;
if
(
!
value
||
strlen
(
value
)
==
0
)
if
(
!
value
||
strlen
(
value
)
==
0
)
return
lxc_clear_hooks
(
lxc_conf
,
key
);
return
lxc_clear_hooks
(
lxc_conf
,
key
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment