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
6e50e704
Unverified
Commit
6e50e704
authored
Jun 05, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: improve lxc_map_ids()
Closes
https://github.com/lxc/lxd/issues/3384
. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
54117de5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
conf.c
src/lxc/conf.c
+21
-1
No files found.
src/lxc/conf.c
View file @
6e50e704
...
...
@@ -3333,7 +3333,14 @@ static int write_id_mapping(enum idtype idtype, pid_t pid, const char *buf,
return
0
;
}
/* Check whether a binary exist and has either CAP_SETUID, CAP_SETGID or both. */
/* Check whether a binary exist and has either CAP_SETUID, CAP_SETGID or both.
*
* @return 1 if functional binary was found
* @return 0 if binary exists but is lacking privilege
* @return -ENOENT if binary does not exist
* @return -EINVAL if cap to check is neither CAP_SETUID nor CAP_SETGID
*
*/
static
int
idmaptool_on_path_and_privileged
(
const
char
*
binary
,
cap_value_t
cap
)
{
char
*
path
;
...
...
@@ -3341,6 +3348,9 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
struct
stat
st
;
int
fret
=
0
;
if
(
cap
!=
CAP_SETUID
&&
cap
!=
CAP_SETGID
)
return
-
EINVAL
;
path
=
on_path
(
binary
,
NULL
);
if
(
!
path
)
return
-
ENOENT
;
...
...
@@ -3429,7 +3439,17 @@ int lxc_map_ids(struct lxc_list *idmap, pid_t pid)
* range by shadow.
*/
uidmap
=
idmaptool_on_path_and_privileged
(
"newuidmap"
,
CAP_SETUID
);
if
(
uidmap
==
-
ENOENT
)
WARN
(
"newuidmap binary is missing"
);
else
if
(
!
uidmap
)
WARN
(
"newuidmap is lacking necessary privileges"
);
gidmap
=
idmaptool_on_path_and_privileged
(
"newgidmap"
,
CAP_SETGID
);
if
(
gidmap
==
-
ENOENT
)
WARN
(
"newgidmap binary is missing"
);
else
if
(
!
gidmap
)
WARN
(
"newgidmap is lacking necessary privileges"
);
if
(
uidmap
>
0
&&
gidmap
>
0
)
{
DEBUG
(
"Functional newuidmap and newgidmap binary found."
);
use_shadow
=
true
;
...
...
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