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
3275932b
Unverified
Commit
3275932b
authored
Feb 22, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: simplify idmaptool_on_path_and_privileged
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
c4fb13e9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
15 deletions
+10
-15
conf.c
src/lxc/conf.c
+10
-15
No files found.
src/lxc/conf.c
View file @
3275932b
...
@@ -2844,24 +2844,23 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
...
@@ -2844,24 +2844,23 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
struct
stat
st
;
struct
stat
st
;
int
fret
=
0
;
int
fret
=
0
;
errno
=
EINVAL
;
if
(
cap
!=
CAP_SETUID
&&
cap
!=
CAP_SETGID
)
if
(
cap
!=
CAP_SETUID
&&
cap
!=
CAP_SETGID
)
return
-
EINVAL
;
return
-
1
;
errno
=
ENOENT
;
path
=
on_path
(
binary
,
NULL
);
path
=
on_path
(
binary
,
NULL
);
if
(
!
path
)
if
(
!
path
)
return
-
ENOENT
;
return
-
1
;
ret
=
stat
(
path
,
&
st
);
ret
=
stat
(
path
,
&
st
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
fret
=
-
errno
;
return
-
1
;
goto
cleanup
;
}
/* Check if the binary is setuid. */
/* Check if the binary is setuid. */
if
(
st
.
st_mode
&
S_ISUID
)
{
if
(
st
.
st_mode
&
S_ISUID
)
{
DEBUG
(
"The binary
\"
%s
\"
does have the setuid bit set"
,
path
);
DEBUG
(
"The binary
\"
%s
\"
does have the setuid bit set"
,
path
);
fret
=
1
;
return
1
;
goto
cleanup
;
}
}
#if HAVE_LIBCAP && LIBCAP_SUPPORTS_FILE_CAPABILITIES
#if HAVE_LIBCAP && LIBCAP_SUPPORTS_FILE_CAPABILITIES
...
@@ -2871,8 +2870,7 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
...
@@ -2871,8 +2870,7 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
lxc_file_cap_is_set
(
path
,
CAP_SETUID
,
CAP_PERMITTED
))
{
lxc_file_cap_is_set
(
path
,
CAP_SETUID
,
CAP_PERMITTED
))
{
DEBUG
(
"The binary
\"
%s
\"
has CAP_SETUID in its CAP_EFFECTIVE "
DEBUG
(
"The binary
\"
%s
\"
has CAP_SETUID in its CAP_EFFECTIVE "
"and CAP_PERMITTED sets"
,
path
);
"and CAP_PERMITTED sets"
,
path
);
fret
=
1
;
return
1
;
goto
cleanup
;
}
}
/* Check if it has the CAP_SETGID capability. */
/* Check if it has the CAP_SETGID capability. */
...
@@ -2881,8 +2879,7 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
...
@@ -2881,8 +2879,7 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
lxc_file_cap_is_set
(
path
,
CAP_SETGID
,
CAP_PERMITTED
))
{
lxc_file_cap_is_set
(
path
,
CAP_SETGID
,
CAP_PERMITTED
))
{
DEBUG
(
"The binary
\"
%s
\"
has CAP_SETGID in its CAP_EFFECTIVE "
DEBUG
(
"The binary
\"
%s
\"
has CAP_SETGID in its CAP_EFFECTIVE "
"and CAP_PERMITTED sets"
,
path
);
"and CAP_PERMITTED sets"
,
path
);
fret
=
1
;
return
1
;
goto
cleanup
;
}
}
#else
#else
/* If we cannot check for file capabilities we need to give the benefit
/* If we cannot check for file capabilities we need to give the benefit
...
@@ -2891,11 +2888,9 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
...
@@ -2891,11 +2888,9 @@ static int idmaptool_on_path_and_privileged(const char *binary, cap_value_t cap)
*/
*/
DEBUG
(
"Cannot check for file capabilities as full capability support is "
DEBUG
(
"Cannot check for file capabilities as full capability support is "
"missing. Manual intervention needed"
);
"missing. Manual intervention needed"
);
fret
=
1
;
#endif
#endif
cleanup:
return
1
;
return
fret
;
}
}
int
lxc_map_ids_exec_wrapper
(
void
*
args
)
int
lxc_map_ids_exec_wrapper
(
void
*
args
)
...
...
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