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
896a3d4f
Unverified
Commit
896a3d4f
authored
Nov 29, 2017
by
Christian Brauner
Committed by
GitHub
Nov 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1957 from AustinReichert/tools-refactor-lxc-unshare
tools/lxc_unshare: removed internal logging
parents
0db85c58
076d1ba7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
lxc_unshare.c
src/lxc/tools/lxc_unshare.c
+11
-13
No files found.
src/lxc/tools/lxc_unshare.c
View file @
896a3d4f
...
@@ -44,8 +44,6 @@
...
@@ -44,8 +44,6 @@
#include "network.h"
#include "network.h"
#include "utils.h"
#include "utils.h"
lxc_log_define
(
lxc_unshare_ui
,
lxc
);
struct
my_iflist
struct
my_iflist
{
{
char
*
mi_ifname
;
char
*
mi_ifname
;
...
@@ -81,14 +79,14 @@ static bool lookup_user(const char *optarg, uid_t *uid)
...
@@ -81,14 +79,14 @@ static bool lookup_user(const char *optarg, uid_t *uid)
pwent
=
getpwnam
(
name
);
pwent
=
getpwnam
(
name
);
if
(
!
pwent
)
{
if
(
!
pwent
)
{
ERROR
(
"invalid username %s
"
,
name
);
fprintf
(
stderr
,
"invalid username %s
\n
"
,
name
);
return
false
;
return
false
;
}
}
*
uid
=
pwent
->
pw_uid
;
*
uid
=
pwent
->
pw_uid
;
}
else
{
}
else
{
pwent
=
getpwuid
(
*
uid
);
pwent
=
getpwuid
(
*
uid
);
if
(
!
pwent
)
{
if
(
!
pwent
)
{
ERROR
(
"invalid uid %u
"
,
*
uid
);
fprintf
(
stderr
,
"invalid uid %u
\n
"
,
*
uid
);
return
false
;
return
false
;
}
}
}
}
...
@@ -119,19 +117,19 @@ static int do_start(void *arg)
...
@@ -119,19 +117,19 @@ static int do_start(void *arg)
if
((
flags
&
CLONE_NEWUTS
)
&&
want_hostname
)
if
((
flags
&
CLONE_NEWUTS
)
&&
want_hostname
)
if
(
sethostname
(
want_hostname
,
strlen
(
want_hostname
))
<
0
)
{
if
(
sethostname
(
want_hostname
,
strlen
(
want_hostname
))
<
0
)
{
ERROR
(
"failed to set hostname %s: %s
"
,
want_hostname
,
strerror
(
errno
));
fprintf
(
stderr
,
"failed to set hostname %s: %s
\n
"
,
want_hostname
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
/* Setuid is useful even without a new user id space. */
/* Setuid is useful even without a new user id space. */
if
(
start_arg
->
setuid
&&
setuid
(
uid
))
{
if
(
start_arg
->
setuid
&&
setuid
(
uid
))
{
ERROR
(
"failed to set uid %d: %s
"
,
uid
,
strerror
(
errno
));
fprintf
(
stderr
,
"failed to set uid %d: %s
\n
"
,
uid
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
execvp
(
args
[
0
],
args
);
execvp
(
args
[
0
],
args
);
ERROR
(
"failed to exec: '%s': %s
"
,
args
[
0
],
strerror
(
errno
));
fprintf
(
stderr
,
"failed to exec: '%s': %s
\n
"
,
args
[
0
],
strerror
(
errno
));
return
1
;
return
1
;
}
}
...
@@ -189,7 +187,7 @@ int main(int argc, char *argv[])
...
@@ -189,7 +187,7 @@ int main(int argc, char *argv[])
}
}
if
(
argv
[
optind
]
==
NULL
)
{
if
(
argv
[
optind
]
==
NULL
)
{
ERROR
(
"a command to execute in the new namespace is required
"
);
fprintf
(
stderr
,
"a command to execute in the new namespace is required
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -229,23 +227,23 @@ int main(int argc, char *argv[])
...
@@ -229,23 +227,23 @@ int main(int argc, char *argv[])
usage
(
argv
[
0
]);
usage
(
argv
[
0
]);
if
(
!
(
flags
&
CLONE_NEWNET
)
&&
my_iflist
)
{
if
(
!
(
flags
&
CLONE_NEWNET
)
&&
my_iflist
)
{
ERROR
(
"-i <interfacename> needs -s NETWORK optio
n"
);
fprintf
(
stderr
,
"-i <interfacename> needs -s NETWORK option
\
n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
!
(
flags
&
CLONE_NEWUTS
)
&&
start_arg
.
want_hostname
)
{
if
(
!
(
flags
&
CLONE_NEWUTS
)
&&
start_arg
.
want_hostname
)
{
ERROR
(
"-H <hostname> needs -s UTSNAME optio
n"
);
fprintf
(
stderr
,
"-H <hostname> needs -s UTSNAME option
\
n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
!
(
flags
&
CLONE_NEWNS
)
&&
start_arg
.
want_default_mounts
)
{
if
(
!
(
flags
&
CLONE_NEWNS
)
&&
start_arg
.
want_default_mounts
)
{
ERROR
(
"-M needs -s MOUNT optio
n"
);
fprintf
(
stderr
,
"-M needs -s MOUNT option
\
n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
pid
=
lxc_clone
(
do_start
,
&
start_arg
,
flags
);
pid
=
lxc_clone
(
do_start
,
&
start_arg
,
flags
);
if
(
pid
<
0
)
{
if
(
pid
<
0
)
{
ERROR
(
"failed to clone
"
);
fprintf
(
stderr
,
"failed to clone
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -260,7 +258,7 @@ int main(int argc, char *argv[])
...
@@ -260,7 +258,7 @@ int main(int argc, char *argv[])
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
if
(
waitpid
(
pid
,
&
status
,
0
)
<
0
)
{
if
(
waitpid
(
pid
,
&
status
,
0
)
<
0
)
{
ERROR
(
"failed to wait for '%d'
"
,
pid
);
fprintf
(
stderr
,
"failed to wait for '%d'
\n
"
,
pid
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
...
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