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
cfeeed19
Unverified
Commit
cfeeed19
authored
Dec 05, 2017
by
Stéphane Graber
Committed by
GitHub
Dec 05, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1994 from brauner/2017-12-04/bugfixes
attach: do not fail on non-existing namespaces
parents
1048874c
134284c3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
25 deletions
+34
-25
attach.c
src/lxc/attach.c
+8
-1
conf.c
src/lxc/conf.c
+11
-9
confile.c
src/lxc/confile.c
+0
-8
confile_legacy.c
src/lxc/confile_legacy.c
+3
-2
criu.c
src/lxc/criu.c
+9
-3
utils.c
src/lxc/utils.c
+3
-2
No files found.
src/lxc/attach.c
View file @
cfeeed19
...
@@ -281,8 +281,15 @@ static int in_same_namespace(pid_t pid1, pid_t pid2, const char *ns)
...
@@ -281,8 +281,15 @@ static int in_same_namespace(pid_t pid1, pid_t pid2, const char *ns)
struct
stat
ns_st1
,
ns_st2
;
struct
stat
ns_st1
,
ns_st2
;
ns_fd1
=
lxc_preserve_ns
(
pid1
,
ns
);
ns_fd1
=
lxc_preserve_ns
(
pid1
,
ns
);
if
(
ns_fd1
<
0
)
if
(
ns_fd1
<
0
)
{
/* The kernel does not support this namespace. This is not an
* error.
*/
if
(
errno
==
ENOENT
)
return
-
EINVAL
;
goto
out
;
goto
out
;
}
ns_fd2
=
lxc_preserve_ns
(
pid2
,
ns
);
ns_fd2
=
lxc_preserve_ns
(
pid2
,
ns
);
if
(
ns_fd2
<
0
)
if
(
ns_fd2
<
0
)
...
...
src/lxc/conf.c
View file @
cfeeed19
...
@@ -1741,11 +1741,12 @@ static int mount_entry(const char *fsname, const char *target,
...
@@ -1741,11 +1741,12 @@ static int mount_entry(const char *fsname, const char *target,
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
optional
)
{
if
(
optional
)
{
INFO
(
"Failed to mount
\"
%s
\"
on
\"
%s
\"
(optional): %s"
,
INFO
(
"Failed to mount
\"
%s
\"
on
\"
%s
\"
(optional): %s"
,
fsname
,
target
,
strerror
(
errno
));
fsname
?
fsname
:
"(null)"
,
target
,
strerror
(
errno
));
return
0
;
return
0
;
}
}
SYSERROR
(
"Failed to mount
\"
%s
\"
on
\"
%s
\"
"
,
fsname
,
target
);
SYSERROR
(
"Failed to mount
\"
%s
\"
on
\"
%s
\"
"
,
fsname
?
fsname
:
"(null)"
,
target
);
return
-
1
;
return
-
1
;
}
}
...
@@ -1753,13 +1754,12 @@ static int mount_entry(const char *fsname, const char *target,
...
@@ -1753,13 +1754,12 @@ static int mount_entry(const char *fsname, const char *target,
unsigned
long
rqd_flags
=
0
;
unsigned
long
rqd_flags
=
0
;
DEBUG
(
"Remounting
\"
%s
\"
on
\"
%s
\"
to respect bind or remount "
DEBUG
(
"Remounting
\"
%s
\"
on
\"
%s
\"
to respect bind or remount "
"options"
,
"options"
,
fsname
?
fsname
:
"(none)"
,
target
?
target
:
"(none)"
);
fsname
?
fsname
:
"(none)"
,
target
?
target
:
"(none)"
);
if
(
mountflags
&
MS_RDONLY
)
if
(
mountflags
&
MS_RDONLY
)
rqd_flags
|=
MS_RDONLY
;
rqd_flags
|=
MS_RDONLY
;
#ifdef HAVE_STATVFS
#ifdef HAVE_STATVFS
if
(
statvfs
(
fsname
,
&
sb
)
==
0
)
{
if
(
fsname
&&
statvfs
(
fsname
,
&
sb
)
==
0
)
{
unsigned
long
required_flags
=
rqd_flags
;
unsigned
long
required_flags
=
rqd_flags
;
if
(
sb
.
f_flag
&
MS_NOSUID
)
if
(
sb
.
f_flag
&
MS_NOSUID
)
...
@@ -1798,12 +1798,14 @@ static int mount_entry(const char *fsname, const char *target,
...
@@ -1798,12 +1798,14 @@ static int mount_entry(const char *fsname, const char *target,
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
optional
)
{
if
(
optional
)
{
INFO
(
"Failed to mount
\"
%s
\"
on
\"
%s
\"
"
INFO
(
"Failed to mount
\"
%s
\"
on
\"
%s
\"
"
"(optional): %s"
,
fsname
,
target
,
"(optional): %s"
,
fsname
?
fsname
:
"(null)"
,
target
,
strerror
(
errno
));
strerror
(
errno
));
return
0
;
return
0
;
}
}
SYSERROR
(
"Failed to mount
\"
%s
\"
on
\"
%s
\"
"
,
fsname
,
target
);
SYSERROR
(
"Failed to mount
\"
%s
\"
on
\"
%s
\"
"
,
fsname
?
fsname
:
"(null)"
,
target
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -1811,8 +1813,8 @@ static int mount_entry(const char *fsname, const char *target,
...
@@ -1811,8 +1813,8 @@ static int mount_entry(const char *fsname, const char *target,
#ifdef HAVE_STATVFS
#ifdef HAVE_STATVFS
skipremount:
skipremount:
#endif
#endif
DEBUG
(
"Mounted
\"
%s
\"
on
\"
%s
\"
with filesystem type
\"
%s
\"
"
,
fsname
,
DEBUG
(
"Mounted
\"
%s
\"
on
\"
%s
\"
with filesystem type
\"
%s
\"
"
,
target
,
fstype
);
fsname
?
fsname
:
"(null)"
,
target
,
fstype
);
return
0
;
return
0
;
}
}
...
...
src/lxc/confile.c
View file @
cfeeed19
...
@@ -2942,35 +2942,27 @@ static int get_config_mount_auto(const char *key, char *retv, int inlen,
...
@@ -2942,35 +2942,27 @@ static int get_config_mount_auto(const char *key, char *retv, int inlen,
switch
(
c
->
auto_mounts
&
LXC_AUTO_CGROUP_MASK
)
{
switch
(
c
->
auto_mounts
&
LXC_AUTO_CGROUP_MASK
)
{
case
LXC_AUTO_CGROUP_NOSPEC
:
case
LXC_AUTO_CGROUP_NOSPEC
:
strprint
(
retv
,
inlen
,
"%scgroup"
,
sep
);
strprint
(
retv
,
inlen
,
"%scgroup"
,
sep
);
sep
=
" "
;
break
;
break
;
case
LXC_AUTO_CGROUP_MIXED
:
case
LXC_AUTO_CGROUP_MIXED
:
strprint
(
retv
,
inlen
,
"%scgroup:mixed"
,
sep
);
strprint
(
retv
,
inlen
,
"%scgroup:mixed"
,
sep
);
sep
=
" "
;
break
;
break
;
case
LXC_AUTO_CGROUP_RO
:
case
LXC_AUTO_CGROUP_RO
:
strprint
(
retv
,
inlen
,
"%scgroup:ro"
,
sep
);
strprint
(
retv
,
inlen
,
"%scgroup:ro"
,
sep
);
sep
=
" "
;
break
;
break
;
case
LXC_AUTO_CGROUP_RW
:
case
LXC_AUTO_CGROUP_RW
:
strprint
(
retv
,
inlen
,
"%scgroup:rw"
,
sep
);
strprint
(
retv
,
inlen
,
"%scgroup:rw"
,
sep
);
sep
=
" "
;
break
;
break
;
case
LXC_AUTO_CGROUP_FULL_NOSPEC
:
case
LXC_AUTO_CGROUP_FULL_NOSPEC
:
strprint
(
retv
,
inlen
,
"%scgroup-full"
,
sep
);
strprint
(
retv
,
inlen
,
"%scgroup-full"
,
sep
);
sep
=
" "
;
break
;
break
;
case
LXC_AUTO_CGROUP_FULL_MIXED
:
case
LXC_AUTO_CGROUP_FULL_MIXED
:
strprint
(
retv
,
inlen
,
"%scgroup-full:mixed"
,
sep
);
strprint
(
retv
,
inlen
,
"%scgroup-full:mixed"
,
sep
);
sep
=
" "
;
break
;
break
;
case
LXC_AUTO_CGROUP_FULL_RO
:
case
LXC_AUTO_CGROUP_FULL_RO
:
strprint
(
retv
,
inlen
,
"%scgroup-full:ro"
,
sep
);
strprint
(
retv
,
inlen
,
"%scgroup-full:ro"
,
sep
);
sep
=
" "
;
break
;
break
;
case
LXC_AUTO_CGROUP_FULL_RW
:
case
LXC_AUTO_CGROUP_FULL_RW
:
strprint
(
retv
,
inlen
,
"%scgroup-full:rw"
,
sep
);
strprint
(
retv
,
inlen
,
"%scgroup-full:rw"
,
sep
);
sep
=
" "
;
break
;
break
;
default:
default:
break
;
break
;
...
...
src/lxc/confile_legacy.c
View file @
cfeeed19
...
@@ -969,7 +969,7 @@ static int lxc_clear_nic(struct lxc_conf *c, const char *key)
...
@@ -969,7 +969,7 @@ static int lxc_clear_nic(struct lxc_conf *c, const char *key)
p1
=
strchr
(
key
,
'.'
);
p1
=
strchr
(
key
,
'.'
);
if
(
!
p1
||
*
(
p1
+
1
)
==
'\0'
)
if
(
!
p1
||
*
(
p1
+
1
)
==
'\0'
)
p1
=
NULL
;
return
-
1
;
if
(
!
p1
&&
it
)
{
if
(
!
p1
&&
it
)
{
lxc_remove_nic
(
it
);
lxc_remove_nic
(
it
);
...
@@ -987,8 +987,9 @@ static int lxc_clear_nic(struct lxc_conf *c, const char *key)
...
@@ -987,8 +987,9 @@ static int lxc_clear_nic(struct lxc_conf *c, const char *key)
free
(
it2
->
elem
);
free
(
it2
->
elem
);
free
(
it2
);
free
(
it2
);
}
}
}
else
{
return
-
1
;
}
}
else
return
-
1
;
return
0
;
return
0
;
}
}
...
...
src/lxc/criu.c
View file @
cfeeed19
...
@@ -827,9 +827,10 @@ out_unlock:
...
@@ -827,9 +827,10 @@ out_unlock:
*/
*/
static
void
do_restore
(
struct
lxc_container
*
c
,
int
status_pipe
,
struct
migrate_opts
*
opts
,
char
*
criu_version
)
static
void
do_restore
(
struct
lxc_container
*
c
,
int
status_pipe
,
struct
migrate_opts
*
opts
,
char
*
criu_version
)
{
{
int
fd
;
pid_t
pid
;
pid_t
pid
;
struct
lxc_handler
*
handler
;
struct
lxc_handler
*
handler
;
int
status
,
fd
;
int
status
=
0
;
int
pipes
[
2
]
=
{
-
1
,
-
1
};
int
pipes
[
2
]
=
{
-
1
,
-
1
};
/* Try to detach from the current controlling tty if it exists.
/* Try to detach from the current controlling tty if it exists.
...
@@ -1024,7 +1025,12 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
...
@@ -1024,7 +1025,12 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
* assign the return here to silence potential.
* assign the return here to silence potential.
*/
*/
ret
=
snprintf
(
title
,
sizeof
(
title
),
"[lxc monitor] %s %s"
,
c
->
config_path
,
c
->
name
);
ret
=
snprintf
(
title
,
sizeof
(
title
),
"[lxc monitor] %s %s"
,
c
->
config_path
,
c
->
name
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
title
))
INFO
(
"Setting truncated process name"
);
ret
=
setproctitle
(
title
);
ret
=
setproctitle
(
title
);
if
(
ret
<
0
)
INFO
(
"Failed to set process name"
);
ret
=
lxc_poll
(
c
->
name
,
handler
);
ret
=
lxc_poll
(
c
->
name
,
handler
);
if
(
ret
)
if
(
ret
)
...
@@ -1049,9 +1055,9 @@ out:
...
@@ -1049,9 +1055,9 @@ out:
*/
*/
if
(
!
status
)
if
(
!
status
)
status
=
1
;
status
=
1
;
if
(
write
(
status_pipe
,
&
status
,
sizeof
(
status
))
!=
sizeof
(
status
))
{
if
(
write
(
status_pipe
,
&
status
,
sizeof
(
status
))
!=
sizeof
(
status
))
SYSERROR
(
"writing status failed"
);
SYSERROR
(
"writing status failed"
);
}
close
(
status_pipe
);
close
(
status_pipe
);
}
}
...
...
src/lxc/utils.c
View file @
cfeeed19
...
@@ -1644,7 +1644,7 @@ int safe_mount(const char *src, const char *dest, const char *fstype,
...
@@ -1644,7 +1644,7 @@ int safe_mount(const char *src, const char *dest, const char *fstype,
close
(
destfd
);
close
(
destfd
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
errno
=
saved_errno
;
errno
=
saved_errno
;
SYSERROR
(
"Failed to mount %s onto %s"
,
src
,
dest
);
SYSERROR
(
"Failed to mount %s onto %s"
,
src
?
src
:
"(null)"
,
dest
);
return
ret
;
return
ret
;
}
}
...
@@ -1906,8 +1906,9 @@ int lxc_preserve_ns(const int pid, const char *ns)
...
@@ -1906,8 +1906,9 @@ int lxc_preserve_ns(const int pid, const char *ns)
ret
=
snprintf
(
path
,
__NS_PATH_LEN
,
"/proc/%d/ns%s%s"
,
pid
,
ret
=
snprintf
(
path
,
__NS_PATH_LEN
,
"/proc/%d/ns%s%s"
,
pid
,
!
ns
||
strcmp
(
ns
,
""
)
==
0
?
""
:
"/"
,
!
ns
||
strcmp
(
ns
,
""
)
==
0
?
""
:
"/"
,
!
ns
||
strcmp
(
ns
,
""
)
==
0
?
""
:
ns
);
!
ns
||
strcmp
(
ns
,
""
)
==
0
?
""
:
ns
);
errno
=
EFBIG
;
if
(
ret
<
0
||
(
size_t
)
ret
>=
__NS_PATH_LEN
)
if
(
ret
<
0
||
(
size_t
)
ret
>=
__NS_PATH_LEN
)
return
-
1
;
return
-
EFBIG
;
return
open
(
path
,
O_RDONLY
|
O_CLOEXEC
);
return
open
(
path
,
O_RDONLY
|
O_CLOEXEC
);
}
}
...
...
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