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
640dfcdc
Unverified
Commit
640dfcdc
authored
Feb 22, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: cleanup macros write_id_mapping
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
d9705838
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
+10
-14
conf.c
src/lxc/conf.c
+10
-14
No files found.
src/lxc/conf.c
View file @
640dfcdc
...
...
@@ -2699,30 +2699,28 @@ struct lxc_conf *lxc_conf_init(void)
int
write_id_mapping
(
enum
idtype
idtype
,
pid_t
pid
,
const
char
*
buf
,
size_t
buf_size
)
{
int
fd
,
ret
;
__do_close_prot_errno
int
fd
;
int
ret
;
char
path
[
PATH_MAX
];
if
(
geteuid
()
!=
0
&&
idtype
==
ID_TYPE_GID
)
{
size_t
buflen
;
__do_close_prot_errno
int
setgroups_fd
=
-
EBADF
;
ret
=
snprintf
(
path
,
PATH_MAX
,
"/proc/%d/setgroups"
,
pid
);
if
(
ret
<
0
||
ret
>=
PATH_MAX
)
return
-
E2BIG
;
fd
=
open
(
path
,
O_WRONLY
);
if
(
fd
<
0
&&
errno
!=
ENOENT
)
{
setgroups_
fd
=
open
(
path
,
O_WRONLY
);
if
(
setgroups_
fd
<
0
&&
errno
!=
ENOENT
)
{
SYSERROR
(
"Failed to open
\"
%s
\"
"
,
path
);
return
-
1
;
}
if
(
fd
>=
0
)
{
buflen
=
STRLITERALLEN
(
"deny
\n
"
);
errno
=
0
;
ret
=
lxc_write_nointr
(
fd
,
"deny
\n
"
,
buflen
);
close
(
fd
);
if
(
ret
!=
buflen
)
{
SYSERROR
(
"Failed to write
\"
deny
\"
to "
"
\"
/proc/%d/setgroups
\"
"
,
pid
);
if
(
setgroups_fd
>=
0
)
{
ret
=
lxc_write_nointr
(
setgroups_fd
,
"deny
\n
"
,
STRLITERALLEN
(
"deny
\n
"
));
if
(
ret
!=
STRLITERALLEN
(
"deny
\n
"
))
{
SYSERROR
(
"Failed to write
\"
deny
\"
to
\"
/proc/%d/setgroups
\"
"
,
pid
);
return
-
1
;
}
TRACE
(
"Wrote
\"
deny
\"
to
\"
/proc/%d/setgroups
\"
"
,
pid
);
...
...
@@ -2740,9 +2738,7 @@ int write_id_mapping(enum idtype idtype, pid_t pid, const char *buf,
return
-
1
;
}
errno
=
0
;
ret
=
lxc_write_nointr
(
fd
,
buf
,
buf_size
);
close
(
fd
);
if
(
ret
!=
buf_size
)
{
SYSERROR
(
"Failed to write %cid mapping to
\"
%s
\"
"
,
idtype
==
ID_TYPE_UID
?
'u'
:
'g'
,
path
);
...
...
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