diff options
author | Ashutosh Mehra <asmehra@redhat.com> | 2022-05-30 22:57:07 +0300 |
---|---|---|
committer | Andrei Vagin <avagin@gmail.com> | 2022-06-13 08:32:22 +0300 |
commit | 0db600d91cabebd28215ae2da1f7878bcaa5a9c8 (patch) | |
tree | c1dc5aa77706ddc97798000db76ce4987dc297f2 /scripts | |
parent | 98eda32ae28b3ffcc849380c59ec9535586a1622 (diff) |
Fix the check for mnt namespace in criu-ns
criu-ns script incorrectly compares the pidns fd with mntns fd.
Also reversed the condition in is_my_namespace function to align it
with the function name.
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/criu-ns | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/criu-ns b/scripts/criu-ns index 9fc58b640..1217c3dcd 100755 --- a/scripts/criu-ns +++ b/scripts/criu-ns @@ -153,9 +153,9 @@ def _set_namespace(fd): raise OSError(_errno, errno.errorcode[_errno]) -def is_my_namespace(fd): +def is_my_namespace(fd, ns): """Returns True if fd refers to current namespace""" - return os.stat('/proc/self/ns/pid').st_ino != os.fstat(fd).st_ino + return os.stat('/proc/self/ns/%s' % ns).st_ino == os.fstat(fd).st_ino def set_pidns(tpid, pid_idx): @@ -165,7 +165,7 @@ def set_pidns(tpid, pid_idx): pid namespace. """ ns_fd = os.open('/proc/%s/ns/pid' % tpid, os.O_RDONLY) - if is_my_namespace(ns_fd): + if not is_my_namespace(ns_fd, "pid"): for line in open('/proc/%s/status' % tpid): if not line.startswith('NSpid:'): continue @@ -190,7 +190,7 @@ def set_mntns(tpid): will be the same in target mntns. """ ns_fd = os.open('/proc/%s/ns/mnt' % tpid, os.O_RDONLY) - if is_my_namespace(ns_fd): + if not is_my_namespace(ns_fd, "mnt"): root_st = os.stat('/') cwd_st = os.stat('.') cwd_path = os.path.realpath('.') |