Skip to content

Make base mount points shared#98

Closed
Zyqsempai wants to merge 2 commits intorootless-containers:masterfrom
Zyqsempai:97-make-mount-points-shared
Closed

Make base mount points shared#98
Zyqsempai wants to merge 2 commits intorootless-containers:masterfrom
Zyqsempai:97-make-mount-points-shared

Conversation

@Zyqsempai
Copy link
Copy Markdown
Contributor

Fixes #97

Made base mount point shared.
Signed-off-by: Boris Popovschi [email protected]

@Zyqsempai
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda Did you mean something like this?

@AkihiroSuda
Copy link
Copy Markdown
Member

Sorry, I was talking about the rootfs.

e.g.

  • Run rootlesskit bash
  • Mount /media/cdrom as the real root
  • The files under /media/cdrom is invisible in the rootlesskit shell.
    The files should be visible when rootlesskit was launched with some flag like --propagation=rslave.

@Zyqsempai
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda Ok, let's summarize a little bit:

  1. We need new flag for rootlesskit --propagation
  2. Possible values for flag: slave, rslave, shared. rshared, private
  3. Based on flag value we should define mount propagation type, the only question I have, which point we should mount?

@Zyqsempai Zyqsempai force-pushed the 97-make-mount-points-shared branch from 993eea1 to 9967590 Compare January 8, 2020 09:08
@Zyqsempai
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda PTAL

Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, doesn't seem working

@Zyqsempai
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda Yep, looks like, but I don't see where can be the problem.

findmnt -o TARGET,PROPAGATION
TARGET                                PROPAGATION
/                                     shared
├─/dev                                shared
│ ├─/dev/pts                          shared
│ ├─/dev/shm                          shared
│ ├─/dev/hugepages                    shared
│ └─/dev/mqueue                       shared
├─/run                                shared
│ ├─/run/lock                         shared
│ └─/run/user/1000                    shared
│   ├─/run/user/1000/gvfs             shared
│   └─/run/user/1000/doc              shared
├─/sys                                shared
│ ├─/sys/kernel/security              shared
│ ├─/sys/fs/cgroup                    shared
│ │ ├─/sys/fs/cgroup/unified          shared
│ │ ├─/sys/fs/cgroup/systemd          shared
│ │ ├─/sys/fs/cgroup/cpu,cpuacct      shared
│ │ ├─/sys/fs/cgroup/hugetlb          shared
│ │ ├─/sys/fs/cgroup/pids             shared
│ │ ├─/sys/fs/cgroup/net_cls,net_prio shared
│ │ ├─/sys/fs/cgroup/blkio            shared
│ │ ├─/sys/fs/cgroup/freezer          shared
│ │ ├─/sys/fs/cgroup/memory           shared
│ │ ├─/sys/fs/cgroup/devices          shared
│ │ ├─/sys/fs/cgroup/rdma             shared
│ │ ├─/sys/fs/cgroup/perf_event       shared
│ │ └─/sys/fs/cgroup/cpuset           shared
│ ├─/sys/fs/pstore                    shared
│ ├─/sys/firmware/efi/efivars         shared
│ ├─/sys/fs/bpf                       shared
│ ├─/sys/kernel/debug                 shared
│ ├─/sys/kernel/config                shared
│ └─/sys/fs/fuse/connections          shared
├─/proc                               shared
│ └─/proc/sys/fs/binfmt_misc          shared
├─/snap/core/8213                     shared
├─/snap/gnome-logs/81                 shared
├─/snap/gtk-common-themes/1353        shared
├─/snap/core18/1288                   shared
├─/snap/gnome-calculator/544          shared
├─/snap/gnome-3-28-1804/110           shared
├─/snap/gnome-characters/367          shared
├─/snap/core/8268                     shared
├─/snap/gnome-calculator/501          shared
├─/snap/core18/1279                   shared
├─/snap/gnome-3-28-1804/71            shared
├─/snap/gnome-characters/375          shared
└─/boot/efi                           shared

this what I see inside the rootlesskit shell, everything is shared.
And outside

sudo cat /proc/28338/mountinfo 
1198 994 8:20 / / rw,relatime shared:651 - ext4 /dev/sdb4 rw,errors=remount-ro

again root is shared, do you have any ideas?

@AkihiroSuda
Copy link
Copy Markdown
Member

@Zyqsempai

This seems to work for your PR:

diff --git a/pkg/parent/parent.go b/pkg/parent/parent.go
index 6e7e61b..287032f 100644
--- a/pkg/parent/parent.go
+++ b/pkg/parent/parent.go
@@ -84,9 +84,8 @@ func Parent(opt Opt) error {
        }
        cmd := exec.Command("/proc/self/exe", os.Args[1:]...)
        cmd.SysProcAttr = &syscall.SysProcAttr{
-               Pdeathsig:    syscall.SIGKILL,
-               Cloneflags:   syscall.CLONE_NEWUSER,
-               Unshareflags: syscall.CLONE_NEWNS,
+               Pdeathsig:  syscall.SIGKILL,
+               Cloneflags: syscall.CLONE_NEWUSER | syscall.CLONE_NEWNS,
        }
        if opt.NetworkDriver != nil {
                cmd.SysProcAttr.Unshareflags |= syscall.CLONE_NEWNET

@AkihiroSuda AkihiroSuda added this to the v0.9.0 milestone Feb 20, 2020
Signed-off-by: Boris Popovschi <[email protected]>
@AkihiroSuda
Copy link
Copy Markdown
Member

@Zyqsempai Do you want to update this, or shall I carry?

Signed-off-by: Boris Popovschi <[email protected]>
@Zyqsempai Zyqsempai force-pushed the 97-make-mount-points-shared branch from 9967590 to 831eade Compare February 25, 2020 11:34
@Zyqsempai
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda I tried your suggestion, but it looks like it's still not working, but from the opposite side, now it's always shared, and it's impossible to make it private.
I pushed it, so you can try it by your self.

@AkihiroSuda
Copy link
Copy Markdown
Member

I will carry

AkihiroSuda added a commit to AkihiroSuda/rootlesskit that referenced this pull request Feb 25, 2020
copy-up still doesn't work:
```
$ rootlesskit --propagation=rshared --copy-up=/run echo test
[rootlesskit:child ] error: failed to move mount point from /tmp/rootlesskit-b668352932 to /run/.ro159097011: invalid argument
[rootlesskit:parent] error: child exited: exit status 1
```

Signed-off-by: Akihiro Suda <[email protected]>
@AkihiroSuda
Copy link
Copy Markdown
Member

carried in #109

AkihiroSuda added a commit to AkihiroSuda/rootlesskit that referenced this pull request Feb 25, 2020
AkihiroSuda added a commit to AkihiroSuda/rootlesskit that referenced this pull request Feb 25, 2020
AkihiroSuda added a commit to AkihiroSuda/rootlesskit that referenced this pull request Feb 25, 2020
AkihiroSuda added a commit to AkihiroSuda/rootlesskit that referenced this pull request Feb 25, 2020
AkihiroSuda added a commit to AkihiroSuda/rootlesskit that referenced this pull request Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support specifying mount propagation

2 participants