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
c5cd20ce
Commit
c5cd20ce
authored
Aug 18, 2015
by
Patrick Toomey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass UID/GID explicitly through flags
Signed-off-by:
Patrick Toomey
<
ptoomey3@biasedcoin.com
>
parent
56f8ff00
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
10 deletions
+29
-10
arguments.h
src/lxc/arguments.h
+4
-0
conf.c
src/lxc/conf.c
+0
-3
conf.h
src/lxc/conf.h
+3
-3
lxc_execute.c
src/lxc/lxc_execute.c
+14
-2
start.c
src/lxc/start.c
+8
-2
No files found.
src/lxc/arguments.h
View file @
c5cd20ce
...
@@ -88,6 +88,10 @@ struct lxc_arguments {
...
@@ -88,6 +88,10 @@ struct lxc_arguments {
char
*
lvname
,
*
vgname
,
*
thinpool
;
char
*
lvname
,
*
vgname
,
*
thinpool
;
char
*
zfsroot
,
*
lowerdir
,
*
dir
;
char
*
zfsroot
,
*
lowerdir
,
*
dir
;
/* lxc-execute */
uid_t
uid
;
gid_t
gid
;
/* auto-start */
/* auto-start */
int
all
;
int
all
;
int
ignore_auto
;
int
ignore_auto
;
...
...
src/lxc/conf.c
View file @
c5cd20ce
...
@@ -2604,9 +2604,6 @@ struct lxc_conf *lxc_conf_init(void)
...
@@ -2604,9 +2604,6 @@ 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
;
new
->
parent_uid
=
getuid
();
new
->
parent_gid
=
getgid
();
return
new
;
return
new
;
}
}
...
...
src/lxc/conf.h
View file @
c5cd20ce
...
@@ -366,9 +366,9 @@ struct lxc_conf {
...
@@ -366,9 +366,9 @@ struct lxc_conf {
/* init command */
/* init command */
char
*
init_cmd
;
char
*
init_cmd
;
/*
The UID/GID of the process creating the contain
er */
/*
the UID/GID that COMMAND for lxc-execute should run und
er */
uid_t
paren
t_uid
;
uid_t
ini
t_uid
;
gid_t
paren
t_gid
;
gid_t
ini
t_gid
;
};
};
#ifdef HAVE_TLS
#ifdef HAVE_TLS
...
...
src/lxc/lxc_execute.c
View file @
c5cd20ce
...
@@ -59,7 +59,9 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
...
@@ -59,7 +59,9 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
{
{
switch
(
c
)
{
switch
(
c
)
{
case
'f'
:
args
->
rcfile
=
arg
;
break
;
case
'f'
:
args
->
rcfile
=
arg
;
break
;
case
's'
:
return
lxc_config_define_add
(
&
defines
,
arg
);
case
's'
:
return
lxc_config_define_add
(
&
defines
,
arg
);
break
;
case
'u'
:
args
->
uid
=
atoi
(
arg
);
break
;
case
'g'
:
args
->
gid
=
atoi
(
arg
);
}
}
return
0
;
return
0
;
}
}
...
@@ -67,6 +69,8 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
...
@@ -67,6 +69,8 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
static
const
struct
option
my_longopts
[]
=
{
static
const
struct
option
my_longopts
[]
=
{
{
"rcfile"
,
required_argument
,
0
,
'f'
},
{
"rcfile"
,
required_argument
,
0
,
'f'
},
{
"define"
,
required_argument
,
0
,
's'
},
{
"define"
,
required_argument
,
0
,
's'
},
{
"uid"
,
required_argument
,
0
,
'u'
},
{
"gid"
,
required_argument
,
0
,
'g'
},
LXC_COMMON_OPTIONS
LXC_COMMON_OPTIONS
};
};
...
@@ -81,7 +85,9 @@ and execs COMMAND into this container.\n\
...
@@ -81,7 +85,9 @@ and execs COMMAND into this container.\n\
Options :
\n
\
Options :
\n
\
-n, --name=NAME NAME for name of the container
\n
\
-n, --name=NAME NAME for name of the container
\n
\
-f, --rcfile=FILE Load configuration file FILE
\n
\
-f, --rcfile=FILE Load configuration file FILE
\n
\
-s, --define KEY=VAL Assign VAL to configuration variable KEY
\n
"
,
-s, --define KEY=VAL Assign VAL to configuration variable KEY
\n
\
-u, --uid=UID Execute COMMAND with UID inside the container
\n
\
-g, --gid=GID Execute COMMAND with GID inside the container
\n
"
,
.
options
=
my_longopts
,
.
options
=
my_longopts
,
.
parser
=
my_parser
,
.
parser
=
my_parser
,
.
checker
=
my_checker
,
.
checker
=
my_checker
,
...
@@ -139,6 +145,12 @@ int main(int argc, char *argv[])
...
@@ -139,6 +145,12 @@ int main(int argc, char *argv[])
if
(
lxc_config_define_load
(
&
defines
,
conf
))
if
(
lxc_config_define_load
(
&
defines
,
conf
))
return
1
;
return
1
;
if
(
my_args
.
uid
)
conf
->
init_uid
=
my_args
.
uid
;
if
(
my_args
.
gid
)
conf
->
init_gid
=
my_args
.
gid
;
ret
=
lxc_execute
(
my_args
.
name
,
my_args
.
argv
,
my_args
.
quiet
,
conf
,
my_args
.
lxcpath
[
0
],
false
);
ret
=
lxc_execute
(
my_args
.
name
,
my_args
.
argv
,
my_args
.
quiet
,
conf
,
my_args
.
lxcpath
[
0
],
false
);
lxc_conf_free
(
conf
);
lxc_conf_free
(
conf
);
...
...
src/lxc/start.c
View file @
c5cd20ce
...
@@ -668,8 +668,14 @@ static int do_start(void *data)
...
@@ -668,8 +668,14 @@ static int do_start(void *data)
* the intent is to execute a command as the original user.
* the intent is to execute a command as the original user.
*/
*/
if
(
!
lxc_list_empty
(
&
handler
->
conf
->
id_map
))
{
if
(
!
lxc_list_empty
(
&
handler
->
conf
->
id_map
))
{
gid_t
new_gid
=
handler
->
conf
->
is_execute
?
handler
->
conf
->
parent_gid
:
0
;
gid_t
new_gid
=
0
;
gid_t
new_uid
=
handler
->
conf
->
is_execute
?
handler
->
conf
->
parent_uid
:
0
;
if
(
handler
->
conf
->
is_execute
&&
handler
->
conf
->
init_gid
)
new_gid
=
handler
->
conf
->
init_gid
;
uid_t
new_uid
=
0
;
if
(
handler
->
conf
->
is_execute
&&
handler
->
conf
->
init_uid
)
new_uid
=
handler
->
conf
->
init_uid
;
NOTICE
(
"switching to gid/uid %d/%d in new user namespace"
,
new_gid
,
new_uid
);
NOTICE
(
"switching to gid/uid %d/%d in new user namespace"
,
new_gid
,
new_uid
);
if
(
setgid
(
new_gid
))
{
if
(
setgid
(
new_gid
))
{
SYSERROR
(
"setgid"
);
SYSERROR
(
"setgid"
);
...
...
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