1 |
Hi Fabian, |
2 |
|
3 |
On Fri, Feb 29, 2008 at 08:51:49AM +0100, Fabian Groffen wrote: |
4 |
|
5 |
> > > I guess, the next step would be to wrap src_build() and src_install() |
6 |
> > > into a sandbox that can't leave $EPREFIX/var/tmp/portage. |
7 |
> > Attached is a first attempt at this. |
8 |
> For the moment, no, as I haven't ever looked at how it is done in |
9 |
> Portage. I suspect it is part of ebuild.sh or misc-functions.sh though. |
10 |
> You could grep for "sandbox" in usr/lib/portage/bin for a start. |
11 |
|
12 |
Actually it's done in pym/portage/dbapi/vartree.py by functions |
13 |
treewalk() and mergeme(). This is why it can't actually be sandboxed - |
14 |
it's running in the same python interpreter and no new executable is |
15 |
spawned. So the whole emerge would have to be sandboxed which can't seem |
16 |
to be done since mac os x sandboxes can't be nested. :-( |
17 |
|
18 |
But you've already changed treewalk() to call mergme() with |
19 |
EPREFIX.lstrip(os.path.sep) instead of "". So it will ignore anything in |
20 |
the temporary install image that would be installed outside of prefix. |
21 |
This should be just fine. |
22 |
|
23 |
Attached is a new version of my sandboxing patch. It now doesn't need a |
24 |
temporary profile file. Instead it passes the profile as a command line |
25 |
parameter to sandbox-exec. Also, I've changed the profile to be |
26 |
black-listing instead of white-listing: Everything is allowed by default, |
27 |
except writing to anything outside of EPREFIX. This should minimise |
28 |
breakage caused by the sandboxing. |
29 |
|
30 |
There's a new feature "macosprefixsandbox". If set, any action that |
31 |
would normally run unconfined, will be confined to a sandbox limiting |
32 |
write access to EPREFIX. This way even setup and postrm and the like |
33 |
can't leave the prefix. |
34 |
|
35 |
I did an emerge -ateND world with and without sandboxing. The log |
36 |
revealed some differences caused by the sandboxing which I'm in the |
37 |
process of tracking down. Most notably, the getcwd() function seems to |
38 |
behave differently in a sandbox. See |
39 |
http://lists.apple.com/archives/darwin-kernel/2008/Mar/msg00004.html for |
40 |
this. |
41 |
|
42 |
Differences I can't explain right now: |
43 |
|
44 |
- bash_logout was missing from the sandboxed build |
45 |
- some DynaLoader writemain call was added in sandboxed build |
46 |
- readline's configure suddenly checks for xterm and write in sandboxed build |
47 |
- a pnmtops configure check cleanly fails in sandboxed build instead of throwing |
48 |
an error message |
49 |
- a sort configure check fails |
50 |
|
51 |
A diff of my logs is attached, in case you can spot some obvious cause |
52 |
for the differences. I'll give the build another go to rule out the |
53 |
possibility that those differences are caused by something else. |
54 |
|
55 |
I have two goals now: |
56 |
- see, how I can integrate sandboxing into bootstrapping |
57 |
- start using prefix as root and see how it behaves |
58 |
|
59 |
My guess is, that the first will boil down to automatically adding |
60 |
FEATURES="macossandbox macosprefixsandbox" to make.conf at an early |
61 |
point. Since portage itself is bootstrapped into EPREFIX/tmp everything |
62 |
after that should be properly sandboxed. Do you think, it'd make sense |
63 |
to work on sandboxing steps before that? |
64 |
|
65 |
As for the latter, I run into the following problem: |
66 |
|
67 |
root@esgaroth:~ $ cd ~michael/bin/gentoo/ |
68 |
root@esgaroth:/Users/michael/bin/gentoo $ ./startprefix |
69 |
Entering Gentoo Prefix /Users/michael/bin/gentoo |
70 |
root@esgaroth:/Users/michael/bin/gentoo $ emerge prefixtest |
71 |
emerge: superuser access is required. |
72 |
|
73 |
Can you give me a quick hint on that one? |
74 |
-- |
75 |
thanks, Micha |