1 |
On Fri, Sep 22, 2017 at 6:29 PM, James McMechan |
2 |
<james_mcmechan@×××××××.com> wrote: |
3 |
> On Fri, Sep 22, 2017 at 5:18 PM, Rich Freeman <rich0@g.o> wrote: |
4 |
>>On Fri, Sep 22, 2017 at 4:43 PM, James McMechan |
5 |
>><james_mcmechan@×××××××.com> wrote: |
6 |
>>> |
7 |
>>> # now create a separate mount namespace non-persistent |
8 |
>>> unshare -m bash |
9 |
>>> |
10 |
>> |
11 |
>>If you're going to go to the trouble to set up a container, you might |
12 |
>>as well add some more isolation: |
13 |
>> |
14 |
>>unshare --mount --net --pid --uts --cgroup --fork --ipc --mount-proc bash |
15 |
>> |
16 |
> |
17 |
> I would not want to change the networking, it should already be working |
18 |
> and I would be better served by not messing with it. |
19 |
> |
20 |
|
21 |
Well, that's the point. You don't want networking to work during the |
22 |
build phases. Maybe you'd want it for the test phase. In any case, |
23 |
you would definitely want control over that in the ebuild. Random |
24 |
build systems shouldn't be talking to the internet, if for no other |
25 |
reason than to avoid it fetching stuff to install that bypasses the |
26 |
integrity checks. |
27 |
|
28 |
If you create a new net namespace by default it won't have any |
29 |
interfaces other than lo. |
30 |
|
31 |
> |
32 |
> The --mount-proc is not really helpful as I immediately remount the entire |
33 |
> "/" filesystem at /mnt/gentoo and chroot into it after custom setup of proc sys and dev |
34 |
> |
35 |
|
36 |
As long as it doesn't see the host /proc then you're fine. You just |
37 |
wouldn't want to have it mounted into the container. |
38 |
|
39 |
> Now I could see a use for --map-root-user --user, then portage could run as |
40 |
> root in the container with the least danger by being user portage:portage outside. |
41 |
> |
42 |
|
43 |
Certainly, but that takes a bit more work, and to be honest I've never |
44 |
actually bothered to get it working using unshare. It probably isn't |
45 |
too difficult. |
46 |
|
47 |
The options I listed basically "just work" without any real additional effort. |
48 |
|
49 |
So, we're drifting in topic, but as long as we're coming up with |
50 |
nice-to-have utilities it would be lovely if our install CDs had |
51 |
something similar to systemd-nspawn to set up a container instead of a |
52 |
chroot for performing the install. If nothing else it would make |
53 |
mount cleanup easier when you're done. I imagine it would just be a |
54 |
bit of shell scripting with util-linux on the CD - while nspawn is |
55 |
bundled with systemd you don't need any of its fancier features for |
56 |
doing an install. |
57 |
|
58 |
Back on topic - none of this stuff will work on FreeBSD, which might |
59 |
be an issue for those running Gentoo on that kernel. Ditto for Prefix |
60 |
I suppose. I suspect that jails/etc would also do the job but you'd |
61 |
need some arch-dependent code to set up the container. Just about all |
62 |
of these tricks are involving non-POSIX functionality. Actually, I'm |
63 |
not sure if even the current LD_PRELOAD approach is completely |
64 |
portable, though it has the advantage of being entirely in userspace. |
65 |
|
66 |
-- |
67 |
Rich |