@@ -161,38 +161,17 @@ static ssize_t process_vm_writev(pid_t pid,
161161bool nscg2 (pid_t pid) {
162162 int pidfd = pidfd_open (pid, 0 );
163163 if (pidfd != -1 ) {
164- int res = -1 ;
165- int mntfd = openat (pidfd, " ns/mnt" , O_RDONLY);
166- if (mntfd == -1 ) {
167- LOGE (" openat(pidfd_open(%d, 0) -> %d, \" ns/mnt\" , O_RDONLY): %s" , pid, pidfd, strerror (errno));
168- goto fallback_mnt;
169- }
170- res = setns (mntfd, CLONE_NEWNS);
171- if (res) {
172- LOGE (" setns(openat(pidfd_open(%d, 0), \" ns/mnt\" ) -> %d, CLONE_NEWNS): %s" , pid, mntfd, strerror (errno));
173- close (mntfd);
174- goto fallback_mnt;
175- }
176- close (mntfd);
177-
178- int cgfd = openat (pidfd, " ns/cgroup" , O_RDONLY);
179- if (cgfd == -1 ) {
180- LOGE (" openat(pidfd_open(%d, 0) -> %d, \" ns/cgroup\" , O_RDONLY): %s" , pid, pidfd, strerror (errno));
181- goto fallback_cg;
182- }
183- res = setns (cgfd, CLONE_NEWCGROUP);
164+ int res = setns (pidfd, 0 );
165+ close (pidfd);
184166 if (res) {
185- LOGE (" setns(openat(pidfd_open(%d, 0), \" ns/cgroup\" ) -> %d, CLONE_NEWCGROUP): %s" , pid, cgfd, strerror (errno));
186- close (cgfd);
187- goto fallback_cg;
167+ LOGE (" setns(pidfd_open(%d, 0) -> %d (closed), 0): %s" , pid, mntfd, strerror (errno));
168+ goto fallback;
188169 }
189- close (cgfd);
190- close (pidfd);
191170 return true ;
192171 } else {
193172 LOGE (" pidfd_open(%d): %s" , pid, strerror (errno));
194173 }
195- fallback_mnt :
174+ fallback :
196175 {
197176 std::string mntPath = " /proc/" + std::to_string (pid) + " /ns/mnt" ;
198177 int mntfd_fallback = open (mntPath.c_str (), O_RDONLY);
@@ -209,7 +188,6 @@ bool nscg2(pid_t pid) {
209188 return false ;
210189 }
211190 }
212- fallback_cg:
213191 {
214192 std::string cgPath = " /proc/" + std::to_string (pid) + " /ns/cgroup" ;
215193 int cgfd_fallback = open (cgPath.c_str (), O_RDONLY);
0 commit comments