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
8917c382
Unverified
Commit
8917c382
authored
Feb 05, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree-wide: use lxc_drop_groups() instead of lxc_setgroups(0, NULL)
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
8dd6f81e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
13 additions
and
13 deletions
+13
-13
attach.c
src/lxc/attach.c
+1
-1
cgfsng.c
src/lxc/cgroups/cgfsng.c
+2
-2
lxc_usernsexec.c
src/lxc/cmd/lxc_usernsexec.c
+1
-1
conf.c
src/lxc/conf.c
+2
-2
lxccontainer.c
src/lxc/lxccontainer.c
+1
-1
start.c
src/lxc/start.c
+2
-2
btrfs.c
src/lxc/storage/btrfs.c
+1
-1
rsync.c
src/lxc/storage/rsync.c
+2
-2
storage_utils.c
src/lxc/storage/storage_utils.c
+1
-1
No files found.
src/lxc/attach.c
View file @
8917c382
...
@@ -1214,7 +1214,7 @@ __noreturn static void do_attach(struct attach_payload *ap)
...
@@ -1214,7 +1214,7 @@ __noreturn static void do_attach(struct attach_payload *ap)
goto
on_error
;
goto
on_error
;
}
}
if
(
!
lxc_
setgroups
(
0
,
NULL
)
&&
errno
!=
EPERM
)
if
(
!
lxc_
drop_groups
(
)
&&
errno
!=
EPERM
)
goto
on_error
;
goto
on_error
;
if
(
options
->
namespaces
&
CLONE_NEWUSER
)
if
(
options
->
namespaces
&
CLONE_NEWUSER
)
...
...
src/lxc/cgroups/cgfsng.c
View file @
8917c382
...
@@ -965,7 +965,7 @@ static int cgroup_tree_remove_wrapper(void *data)
...
@@ -965,7 +965,7 @@ static int cgroup_tree_remove_wrapper(void *data)
gid_t
nsgid
=
(
arg
->
conf
->
root_nsgid_map
!=
NULL
)
?
0
:
arg
->
conf
->
init_gid
;
gid_t
nsgid
=
(
arg
->
conf
->
root_nsgid_map
!=
NULL
)
?
0
:
arg
->
conf
->
init_gid
;
int
ret
;
int
ret
;
if
(
!
lxc_
setgroups
(
0
,
NULL
)
&&
errno
!=
EPERM
)
if
(
!
lxc_
drop_groups
(
)
&&
errno
!=
EPERM
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to setgroups(0, NULL)"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to setgroups(0, NULL)"
);
ret
=
setresgid
(
nsgid
,
nsgid
,
nsgid
);
ret
=
setresgid
(
nsgid
,
nsgid
,
nsgid
);
...
@@ -1574,7 +1574,7 @@ static int chown_cgroup_wrapper(void *data)
...
@@ -1574,7 +1574,7 @@ static int chown_cgroup_wrapper(void *data)
uid_t
nsuid
=
(
arg
->
conf
->
root_nsuid_map
!=
NULL
)
?
0
:
arg
->
conf
->
init_uid
;
uid_t
nsuid
=
(
arg
->
conf
->
root_nsuid_map
!=
NULL
)
?
0
:
arg
->
conf
->
init_uid
;
gid_t
nsgid
=
(
arg
->
conf
->
root_nsgid_map
!=
NULL
)
?
0
:
arg
->
conf
->
init_gid
;
gid_t
nsgid
=
(
arg
->
conf
->
root_nsgid_map
!=
NULL
)
?
0
:
arg
->
conf
->
init_gid
;
if
(
!
lxc_
setgroups
(
0
,
NULL
)
&&
errno
!=
EPERM
)
if
(
!
lxc_
drop_groups
(
)
&&
errno
!=
EPERM
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to setgroups(0, NULL)"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to setgroups(0, NULL)"
);
ret
=
setresgid
(
nsgid
,
nsgid
,
nsgid
);
ret
=
setresgid
(
nsgid
,
nsgid
,
nsgid
);
...
...
src/lxc/cmd/lxc_usernsexec.c
View file @
8917c382
...
@@ -88,7 +88,7 @@ static int do_child(void *vargv)
...
@@ -88,7 +88,7 @@ static int do_child(void *vargv)
int
ret
;
int
ret
;
char
**
argv
=
(
char
**
)
vargv
;
char
**
argv
=
(
char
**
)
vargv
;
if
(
!
lxc_
setgroups
(
0
,
NULL
)
&&
errno
!=
EPERM
)
if
(
!
lxc_
drop_groups
(
)
&&
errno
!=
EPERM
)
return
-
1
;
return
-
1
;
/* Assume we want to become root */
/* Assume we want to become root */
...
...
src/lxc/conf.c
View file @
8917c382
...
@@ -4282,7 +4282,7 @@ int userns_exec_minimal(const struct lxc_conf *conf,
...
@@ -4282,7 +4282,7 @@ int userns_exec_minimal(const struct lxc_conf *conf,
close_prot_errno_disarm
(
sock_fds
[
0
]);
close_prot_errno_disarm
(
sock_fds
[
0
]);
if
(
!
lxc_
setgroups
(
0
,
NULL
)
&&
errno
!=
EPERM
)
if
(
!
lxc_
drop_groups
(
)
&&
errno
!=
EPERM
)
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
ret
=
setresgid
(
resgid
,
resgid
,
resgid
);
ret
=
setresgid
(
resgid
,
resgid
,
resgid
);
...
@@ -4700,7 +4700,7 @@ int userns_exec_mapped_root(const char *path, int path_fd,
...
@@ -4700,7 +4700,7 @@ int userns_exec_mapped_root(const char *path, int path_fd,
if
(
!
lxc_switch_uid_gid
(
0
,
0
))
if
(
!
lxc_switch_uid_gid
(
0
,
0
))
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
if
(
!
lxc_
setgroups
(
0
,
NULL
))
if
(
!
lxc_
drop_groups
(
))
_exit
(
EXIT_FAILURE
);
_exit
(
EXIT_FAILURE
);
ret
=
fchown
(
target_fd
,
0
,
st
.
st_gid
);
ret
=
fchown
(
target_fd
,
0
,
st
.
st_gid
);
...
...
src/lxc/lxccontainer.c
View file @
8917c382
...
@@ -3660,7 +3660,7 @@ static int clone_update_rootfs(struct clone_update_data *data)
...
@@ -3660,7 +3660,7 @@ static int clone_update_rootfs(struct clone_update_data *data)
/* update hostname in rootfs */
/* update hostname in rootfs */
/* we're going to mount, so run in a clean namespace to simplify cleanup */
/* we're going to mount, so run in a clean namespace to simplify cleanup */
(
void
)
lxc_
setgroups
(
0
,
NULL
);
(
void
)
lxc_
drop_groups
(
);
if
(
setgid
(
0
)
<
0
)
{
if
(
setgid
(
0
)
<
0
)
{
ERROR
(
"Failed to setgid to 0"
);
ERROR
(
"Failed to setgid to 0"
);
...
...
src/lxc/start.c
View file @
8917c382
...
@@ -1111,7 +1111,7 @@ static int do_start(void *data)
...
@@ -1111,7 +1111,7 @@ static int do_start(void *data)
/* Drop groups only after we switched to a valid gid in the new
/* Drop groups only after we switched to a valid gid in the new
* user namespace.
* user namespace.
*/
*/
if
(
!
lxc_
setgroups
(
0
,
NULL
)
&&
if
(
!
lxc_
drop_groups
(
)
&&
(
handler
->
am_root
||
errno
!=
EPERM
))
(
handler
->
am_root
||
errno
!=
EPERM
))
goto
out_warn_father
;
goto
out_warn_father
;
...
@@ -1410,7 +1410,7 @@ static int do_start(void *data)
...
@@ -1410,7 +1410,7 @@ static int do_start(void *data)
#if HAVE_LIBCAP
#if HAVE_LIBCAP
if
(
lxc_proc_cap_is_set
(
CAP_SETGID
,
CAP_EFFECTIVE
))
if
(
lxc_proc_cap_is_set
(
CAP_SETGID
,
CAP_EFFECTIVE
))
#endif
#endif
if
(
!
lxc_
setgroups
(
0
,
NULL
))
if
(
!
lxc_
drop_groups
(
))
goto
out_warn_father
;
goto
out_warn_father
;
if
(
!
lxc_switch_uid_gid
(
new_uid
,
new_gid
))
if
(
!
lxc_switch_uid_gid
(
new_uid
,
new_gid
))
...
...
src/lxc/storage/btrfs.c
View file @
8917c382
...
@@ -374,7 +374,7 @@ int btrfs_snapshot_wrapper(void *data)
...
@@ -374,7 +374,7 @@ int btrfs_snapshot_wrapper(void *data)
const
char
*
src
;
const
char
*
src
;
struct
rsync_data_char
*
arg
=
data
;
struct
rsync_data_char
*
arg
=
data
;
(
void
)
lxc_
setgroups
(
0
,
NULL
);
(
void
)
lxc_
drop_groups
(
);
if
(
setgid
(
0
)
<
0
)
{
if
(
setgid
(
0
)
<
0
)
{
ERROR
(
"Failed to setgid to 0"
);
ERROR
(
"Failed to setgid to 0"
);
...
...
src/lxc/storage/rsync.c
View file @
8917c382
...
@@ -35,7 +35,7 @@ int lxc_rsync_exec_wrapper(void *data)
...
@@ -35,7 +35,7 @@ int lxc_rsync_exec_wrapper(void *data)
if
(
!
lxc_switch_uid_gid
(
0
,
0
))
if
(
!
lxc_switch_uid_gid
(
0
,
0
))
return
-
1
;
return
-
1
;
if
(
!
lxc_
setgroups
(
0
,
NULL
))
if
(
!
lxc_
drop_groups
(
))
return
-
1
;
return
-
1
;
return
lxc_rsync_exec
(
args
->
src
,
args
->
dest
);
return
lxc_rsync_exec
(
args
->
src
,
args
->
dest
);
...
@@ -96,7 +96,7 @@ int lxc_rsync(struct rsync_data *data)
...
@@ -96,7 +96,7 @@ int lxc_rsync(struct rsync_data *data)
if
(
!
lxc_switch_uid_gid
(
0
,
0
))
if
(
!
lxc_switch_uid_gid
(
0
,
0
))
return
-
1
;
return
-
1
;
if
(
!
lxc_
setgroups
(
0
,
NULL
))
if
(
!
lxc_
drop_groups
(
))
return
-
1
;
return
-
1
;
src
=
lxc_storage_get_path
(
orig
->
dest
,
orig
->
type
);
src
=
lxc_storage_get_path
(
orig
->
dest
,
orig
->
type
);
...
...
src/lxc/storage/storage_utils.c
View file @
8917c382
...
@@ -461,7 +461,7 @@ int storage_destroy_wrapper(void *data)
...
@@ -461,7 +461,7 @@ int storage_destroy_wrapper(void *data)
{
{
struct
lxc_conf
*
conf
=
data
;
struct
lxc_conf
*
conf
=
data
;
(
void
)
lxc_
setgroups
(
0
,
NULL
);
(
void
)
lxc_
drop_groups
(
);
if
(
setgid
(
0
)
<
0
)
{
if
(
setgid
(
0
)
<
0
)
{
SYSERROR
(
"Failed to setgid to 0"
);
SYSERROR
(
"Failed to setgid to 0"
);
...
...
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