bool is_image) {
_cleanup_close_pair_ int errno_pipe_fd[2] = { -1, -1 };
- _cleanup_close_ int self_mntns_fd = -1, mntns_fd = -1, root_fd = -1, pidns_fd = -1, chased_src_fd = -1;
+ _cleanup_close_ int mntns_fd = -1, root_fd = -1, pidns_fd = -1, chased_src_fd = -1;
char mount_slave[] = "/tmp/propagate.XXXXXX", *mount_tmp, *mount_outside, *p;
bool mount_slave_created = false, mount_slave_mounted = false,
mount_tmp_created = false, mount_tmp_mounted = false,
mount_outside_created = false, mount_outside_mounted = false;
_cleanup_free_ char *chased_src_path = NULL;
- struct stat st, self_mntns_st;
+ struct stat st;
pid_t child;
int r;
if (r < 0)
return log_debug_errno(r, "Failed to retrieve FDs of the target process' namespace: %m");
- if (fstat(mntns_fd, &st) < 0)
- return log_debug_errno(errno, "Failed to fstat mount namespace FD of target process: %m");
-
- r = namespace_open(0, NULL, &self_mntns_fd, NULL, NULL, NULL);
+ r = in_same_namespace(target, 0, NAMESPACE_MOUNT);
if (r < 0)
- return log_debug_errno(r, "Failed to retrieve FDs of systemd's namespace: %m");
-
- if (fstat(self_mntns_fd, &self_mntns_st) < 0)
- return log_debug_errno(errno, "Failed to fstat mount namespace FD of systemd: %m");
-
+ return log_debug_errno(r, "Failed to determine if mount namespaces are equal: %m");
/* We can't add new mounts at runtime if the process wasn't started in a namespace */
- if (stat_inode_same(&st, &self_mntns_st))
+ if (r > 0)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to activate bind mount in target, not running in a mount namespace");
/* One day, when bind mounting /proc/self/fd/n works across namespace boundaries we should rework