Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
iproute2
Commits
5950ba91
Commit
5950ba91
authored
Aug 06, 2015
by
Phil Sutter
Committed by
Stephen Hemminger
Aug 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/namespace: don't leak fd in error case
Signed-off-by:
Phil Sutter
<
phil@nwl.cc
>
parent
b95d28c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
lib/namespace.c
lib/namespace.c
+8
-5
No files found.
lib/namespace.c
View file @
5950ba91
...
...
@@ -58,32 +58,35 @@ int netns_switch(char *name)
if
(
setns
(
netns
,
CLONE_NEWNET
)
<
0
)
{
fprintf
(
stderr
,
"setting the network namespace
\"
%s
\"
failed: %s
\n
"
,
name
,
strerror
(
errno
));
return
-
1
;
goto
fail_close
;
}
if
(
unshare
(
CLONE_NEWNS
)
<
0
)
{
fprintf
(
stderr
,
"unshare failed: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
goto
fail_close
;
}
/* Don't let any mounts propagate back to the parent */
if
(
mount
(
""
,
"/"
,
"none"
,
MS_SLAVE
|
MS_REC
,
NULL
))
{
fprintf
(
stderr
,
"
\"
mount --make-rslave /
\"
failed: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
goto
fail_close
;
}
/* Mount a version of /sys that describes the network namespace */
if
(
umount2
(
"/sys"
,
MNT_DETACH
)
<
0
)
{
fprintf
(
stderr
,
"umount of /sys failed: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
goto
fail_close
;
}
if
(
mount
(
name
,
"/sys"
,
"sysfs"
,
0
,
NULL
)
<
0
)
{
fprintf
(
stderr
,
"mount of /sys failed: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
goto
fail_close
;
}
/* Setup bind mounts for config files in /etc */
bind_etc
(
name
);
return
0
;
fail_close:
close
(
netns
);
return
-
1
;
}
int
netns_get_fd
(
const
char
*
name
)
...
...
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