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
6def4323
Unverified
Commit
6def4323
authored
May 27, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Aug 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: improve write_id_mapping()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
8aeafb41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
+23
-17
conf.c
src/lxc/conf.c
+23
-17
No files found.
src/lxc/conf.c
View file @
6def4323
...
@@ -3581,27 +3581,33 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid)
...
@@ -3581,27 +3581,33 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid)
static
int
write_id_mapping
(
enum
idtype
idtype
,
pid_t
pid
,
const
char
*
buf
,
static
int
write_id_mapping
(
enum
idtype
idtype
,
pid_t
pid
,
const
char
*
buf
,
size_t
buf_size
)
size_t
buf_size
)
{
{
char
path
[
PATH_MAX
];
char
path
[
MAXPATHLEN
];
int
ret
,
closeret
;
int
fd
,
ret
;
FILE
*
f
;
ret
=
snprintf
(
path
,
PATH_MAX
,
"/proc/%d/%cid_map"
,
pid
,
idtype
==
ID_TYPE_UID
?
'u'
:
'g'
);
ret
=
snprintf
(
path
,
MAXPATHLEN
,
"/proc/%d/%cid_map"
,
pid
,
if
(
ret
<
0
||
ret
>=
PATH_MAX
)
{
idtype
==
ID_TYPE_UID
?
'u'
:
'g'
);
fprintf
(
stderr
,
"%s: path name too long
\n
"
,
__func__
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
{
ERROR
(
"failed to create path
\"
%s
\"
"
,
path
);
return
-
E2BIG
;
return
-
E2BIG
;
}
}
f
=
fopen
(
path
,
"w"
);
if
(
!
f
)
{
fd
=
open
(
path
,
O_WRONLY
);
perror
(
"open"
);
if
(
fd
<
0
)
{
return
-
EINVAL
;
SYSERROR
(
"failed to open
\"
%s
\"
"
,
path
);
return
-
1
;
}
}
ret
=
fwrite
(
buf
,
buf_size
,
1
,
f
);
if
(
ret
<
0
)
errno
=
0
;
SYSERROR
(
"writing id mapping"
);
ret
=
lxc_write_nointr
(
fd
,
buf
,
buf_size
);
closeret
=
fclose
(
f
);
if
(
ret
!=
buf_size
)
{
if
(
closeret
)
SYSERROR
(
"failed to write %cid mapping to
\"
%s
\"
"
,
SYSERROR
(
"writing id mapping"
);
idtype
==
ID_TYPE_UID
?
'u'
:
'g'
,
path
);
return
ret
<
0
?
ret
:
closeret
;
close
(
fd
);
return
-
1
;
}
close
(
fd
);
return
0
;
}
}
int
lxc_map_ids
(
struct
lxc_list
*
idmap
,
pid_t
pid
)
int
lxc_map_ids
(
struct
lxc_list
*
idmap
,
pid_t
pid
)
...
...
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