Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 288863 - sys-apps/sandbox-2.1 throws violations when /dev/std* are pipes
Summary: sys-apps/sandbox-2.1 throws violations when /dev/std* are pipes
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Sandbox (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Sandbox Maintainers
URL:
Whiteboard:
Keywords:
: 282514 286660 289876 290059 (view as bug list)
Depends on: 258684
Blocks:
  Show dependency tree
 
Reported: 2009-10-13 11:39 UTC by Marcin Mirosław
Modified: 2024-01-26 12:14 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build log (build.log,27.83 KB, text/plain)
2009-10-13 11:40 UTC, Marcin Mirosław
Details
emerge --info (emerge.info,4.37 KB, text/plain)
2009-10-13 11:41 UTC, Marcin Mirosław
Details
build log , portage-2.1.6.13 (build.log,203.90 KB, text/plain)
2009-10-13 13:03 UTC, Marcin Mirosław
Details
sandbox+strace log (log,78.43 KB, text/plain)
2009-10-14 14:04 UTC, Marcin Mirosław
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Mirosław 2009-10-13 11:39:19 UTC
After uprading portage from 2.1.6.13 to 2.1.7.1 emerging gajim fails on:

>>> Source compiled.
--------------------------- ACCESS VIOLATION SUMMARY ---------------------------
LOG FILE "/var/log/sandbox/sandbox-18486.log"

VERSION 1.0
FORMAT: F - Function called
FORMAT: S - Access Status
FORMAT: P - Path as passed to function
FORMAT: A - Absolute Path (not canonical)
FORMAT: R - Canonical Path
FORMAT: C - Command Line

F: open_wr
S: deny
P: /dev/stderr
A: /dev/stderr
R: /dev/stderr
C: /bin/sh /usr/bin/pygtk-codegen-2.0 --prefix trayicon --register /usr/share/pygtk/2.0/defs/gdk-types.defs --register /usr/share/pygtk/2.0/defs/gtk-types.defs --override ./trayicon.override ./trayicon.defs

F: open_wr
S: deny
P: /dev/stderr
A: /dev/stderr
R: /dev/stderr
C: /bin/sh /usr/bin/pygtk-codegen-2.0 --prefix trayicon --register /usr/share/pygtk/2.0/defs/gdk-types.defs --register /usr/share/pygtk/2.0/defs/gtk-types.defs --override ./trayicon.override ./trayicon.defs
--------------------------------------------------------------------------------

>>> Failed to emerge net-im/gajim-0.12.1, Log file

Reproducible: Always
Comment 1 Marcin Mirosław 2009-10-13 11:40:12 UTC
Created attachment 206953 [details]
build log
Comment 2 Marcin Mirosław 2009-10-13 11:41:13 UTC
Created attachment 206954 [details]
emerge --info
Comment 3 Sebastian Luther (few) 2009-10-13 12:39:09 UTC
It doesn't fail with the old portage version?
Comment 4 Marcin Mirosław 2009-10-13 12:43:26 UTC
Yes, with portage-2.1.6.13 it compiles cleanly.
Comment 5 Sebastian Luther (few) 2009-10-13 12:48:39 UTC
Please attach the build log with portage-2.1.6.13. Use FEATURES="keeptemp" to prevent the build.log from being removed.
Comment 6 Marcin Mirosław 2009-10-13 13:03:58 UTC
Created attachment 206959 [details]
build log , portage-2.1.6.13
Comment 7 Zac Medico gentoo-dev 2009-10-14 00:30:33 UTC
It's probably related to bug 258684.
Comment 8 SpanKY gentoo-dev 2009-10-14 00:38:30 UTC
please post the output of:
  ls -l /dev/std* /dev/fd
Comment 9 Marcin Mirosław 2009-10-14 07:33:36 UTC
Here you are:
#   ls -l /dev/std* /dev/fd
lrwxrwxrwx 1 root root 13 2009-10-14  /dev/fd -> /proc/self/fd
lrwxrwxrwx 1 root root  4 2009-10-14  /dev/stderr -> fd/2
lrwxrwxrwx 1 root root  4 2009-10-14  /dev/stdin -> fd/0
lrwxrwxrwx 1 root root  4 2009-10-14  /dev/stdout -> fd/1
Comment 10 SpanKY gentoo-dev 2009-10-14 10:57:31 UTC
those all look right.  dare i ask if /proc/self/fd/ is sane ?

what happens if you run on the command line:
sandbox
echo moo > /dev/stderr
Comment 11 Marcin Mirosław 2009-10-14 11:18:19 UTC
(In reply to comment #10)
> those all look right.  dare i ask if /proc/self/fd/ is sane ?

But for which process? For example:
# ls -lah /proc/self/fd/
razem 0
dr-x------ 2 root root  0 10-14 13:05 .
dr-xr-xr-x 6 root root  0 10-14 13:05 ..
lrwx------ 1 root root 64 10-14 13:05 0 -> /dev/pts/2
lrwx------ 1 root root 64 10-14 13:05 1 -> /dev/pts/2
lrwx------ 1 root root 64 10-14 13:05 2 -> /dev/pts/2
lr-x------ 1 root root 64 10-14 13:05 3 -> /proc/30640/fd
marcinm proc #

> what happens if you run on the command line:
> sandbox
> echo moo > /dev/stderr

Looks ok..
# sandbox
============================= Gentoo path sandbox ==============================
Detection of the support files.
Verification of the required files.
Setting up the required environment variables.
The protected environment has been started.
--------------------------------------------------------------------------------
Process being started in forked instance.

* Loading sandboxed shell
*  Log File:           /var/log/sandbox/sandbox-24280.log
*  Debug Log File:     /var/log/sandbox/sandbox-debug-24280.log
*  sandboxon:          turn sandbox on
*  sandboxoff:         turn sandbox off
*  addread <path>:     allow <path> to be read
*  addwrite <path>:    allow <path> to be written
*  adddeny <path>:     deny access to <path>
*  addpredict <path>:  allow fake access to <path>

[s] marcinm proc # echo moo > /dev/stderr
moo
[s] marcinm proc #
 
Comment 12 Marcin Mirosław 2009-10-14 11:22:34 UTC
User sandbox can't write to /dev/stderr ..
 su -c sandbox -s /bin/bash  portage
============================= Gentoo path sandbox ==============================
Detection of the support files.
Verification of the required files.
Setting up the required environment variables.
The protected environment has been started.
--------------------------------------------------------------------------------
Process being started in forked instance.

* Loading sandboxed shell
*  Log File:           /var/log/sandbox/sandbox-15338.log
*  Debug Log File:     /var/log/sandbox/sandbox-debug-15338.log
*  sandboxon:          turn sandbox on
*  sandboxoff:         turn sandbox off
*  addread <path>:     allow <path> to be read
*  addwrite <path>:    allow <path> to be written
*  adddeny <path>:     deny access to <path>
*  addpredict <path>:  allow fake access to <path>

[s] portage@marcinm /proc $ echo moo > /dev/stderr
bash: /dev/stderr: Permission denied
[s] portage@marcinm /proc $
Comment 13 Marcin Mirosław 2009-10-14 11:26:44 UTC
(In reply to comment #12)

Sorry, user portage..;)
Comment 14 SpanKY gentoo-dev 2009-10-14 11:48:55 UTC
that is a different issue.  notice how it didnt trigger a sandbox violation.  you've changed your uid to portage, but you didnt launch a new pty, so the current pty is still owned by root.

can you emerge netpbm ?
Comment 15 Marcin Mirosław 2009-10-14 12:00:42 UTC
Netpbm emerge without any problem.
Comment 16 Sebastian Luther (few) 2009-10-14 12:08:50 UTC
There is a similar bug for another package: bug 288874. It was marked as duplicate of bug 286660.
Comment 17 SpanKY gentoo-dev 2009-10-14 12:11:10 UTC
guess i should enhance the violation summary to dereference symlinks

i dont suppose your /bin/sh is a static binary ?
file -L /bin/sh
Comment 18 SpanKY gentoo-dev 2009-10-14 12:12:02 UTC
*** Bug 286660 has been marked as a duplicate of this bug. ***
Comment 19 Marcin Mirosław 2009-10-14 12:15:44 UTC
No. It is not static binary:
# file -L /bin/sh
/bin/sh: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
Comment 20 SpanKY gentoo-dev 2009-10-14 12:19:23 UTC
i guess if you edit /usr/bin/pygtk-codegen-2.0 and change "/dev/stderr" to "1>&2", things "work" ?
Comment 21 Marcin Mirosław 2009-10-14 12:38:19 UTC
Yeah, it's fixing the problem  :)
Comment 22 SpanKY gentoo-dev 2009-10-14 12:47:22 UTC
hrm, i wish i could reproduce this issue on my side to poke it deeper

if you edit the gajim ebuild and add:
src_unpack() { unpack ${A}; echo > /dev/stderr; }

does that trigger the failure ?
Comment 23 Marcin Mirosław 2009-10-14 12:53:19 UTC
Yes, it does.
ACCESS DENIED  open_wr:      /dev/stderr
/var/tmp/portage/net-im/gajim-0.12.1/temp/environment: line 3429: /dev/stderr: Permission denied
Comment 24 SpanKY gentoo-dev 2009-10-14 12:57:57 UTC
i'm guessing that also doing `touch /dev/stderr` fails ?

if so, try doing:
SANDBOX_DEBUG=yes strace -f -s 4096 -vvv -o log touch /dev/stderr

then post the "log" file as an attachment and the sandbox output as a comment
Comment 25 Marcin Mirosław 2009-10-14 13:47:29 UTC
(In reply to comment #24)
> i'm guessing that also doing `touch /dev/stderr` fails ?

No.
# touch /dev/stderr
#

> if so, try doing:
> SANDBOX_DEBUG=yes strace -f -s 4096 -vvv -o log touch /dev/stderr

Don't you mean:
SANDBOX_DEBUG=yes strace -f -s 4096 -vvv -o log sandbox touch /dev/stderr
?
Comment 26 SpanKY gentoo-dev 2009-10-14 13:56:00 UTC
no, because running sandbox inside of sandbox wont work

i'm not talking about errors at the command prompt, i'm talking about sb violations inside of the ebuild

so use:
src_unpack() {
  unpack ${A}
  SANDBOX_DEBUG=yes strace -f -s 4096 -vvv -o log touch /dev/stderr
}

if the touch doesnt fail, try: sh -c '> /dev/stderr'
Comment 27 Marcin Mirosław 2009-10-14 14:04:52 UTC
Created attachment 207085 [details]
sandbox+strace log

>>> Unpacking source...
>>> Unpacking gajim-0.12.1.tar.gz to /var/tmp/portage/net-im/gajim-0.12.1/work
ACCESS ALLOWED  execve:       /usr/bin/strace
ACCESS ALLOWED  open_rd:      /usr/bin/strace
ACCESS ALLOWED  open_wr:      /var/tmp/portage/net-im/gajim-0.12.1/work/log
ACCESS ALLOWED  execv:        /usr/bin/touch
ACCESS ALLOWED  open_rd:      /usr/bin/touch
ACCESS DENIED  open_wr:      /dev/stderr
ACCESS DENIED  utimensat:    /dev/stderr
touch: cannot touch `/dev/stderr': Permission denied
>>> Source unpacked in /var/tmp/portage/net-im/gajim-0.12.1/work
--------------------------- ACCESS VIOLATION SUMMARY ---------------------------
LOG FILE "/var/log/sandbox/sandbox-10709.log"

VERSION 1.0
FORMAT: F - Function called
FORMAT: S - Access Status
FORMAT: P - Path as passed to function
FORMAT: A - Absolute Path (not canonical)
FORMAT: R - Canonical Path
FORMAT: C - Command Line

F: open_wr
S: deny
P: /dev/stderr
A: /dev/stderr
R: /dev/stderr
C: touch /dev/stderr

F: utimensat
S: deny
P: /dev/stderr
A: /dev/stderr
R: /dev/stderr
C: touch /dev/stderr
--------------------------------------------------------------------------------
Comment 28 SpanKY gentoo-dev 2009-10-14 14:40:12 UTC
looks like it's because your stderr is a pipe

10754 readlink("/proc/10754/fd/2", "pipe:[402562]"..., 4095) = 13
10754 lstat64("/proc/10754/fd/pipe:[402562]", 0xbfb13ddc) = -1 ENOENT (No such file or directory)

this can be checked quickly by doing:
$ sandbox 'echo | touch /dev/stdin'
ACCESS DENIED  open_wr:      /dev/stdin
ACCESS DENIED  utimensat:    /dev/stdin
touch: cannot touch `/dev/stdin': Permission denied

why exactly is your std* a pipe ?  is there some portage logging option that sets this up ?
Comment 29 Marcin Mirosław 2009-10-14 14:59:57 UTC
> looks like it's because your stderr is a pipe
[...]
> why exactly is your std* a pipe ?  is there some portage logging option that
> sets this up ?

I don't know what to say. I didn't set up stderr as a pipe intentionally, and i didn't setup any super-extra option for portage logging. 
Could it be releated to udev?


Comment 30 SpanKY gentoo-dev 2009-10-14 15:40:46 UTC
i'm not suggesting it's your fault or it's something you need to resolve, i'm just curious how that happened.  it was more of a question for Zac.
Comment 31 Zac Medico gentoo-dev 2009-10-14 20:24:19 UTC
(In reply to comment #28)
> why exactly is your std* a pipe ?  is there some portage logging option that
> sets this up ?

Logging goes through a pipe if pty devices can't be used for some reason:
1) there are no pty devices
2) bug #287648 (workaround for upstream python3 issue)
Comment 32 Zac Medico gentoo-dev 2009-10-14 20:27:33 UTC
(In reply to comment #22)
> hrm, i wish i could reproduce this issue on my side to poke it deeper

You can force pipes by setting _disable_openpty = True inside pym/portage/__init__.py, or installing portage with USE=python3.
Comment 33 Marcin Mirosław 2009-10-15 08:15:13 UTC
(In reply to comment #31)
[...]
> 2) bug #287648 (workaround for upstream python3 issue)

After emerging portage with USE="-python3" , gajim compiles cleanly.
It was long way;)

Comment 34 Zac Medico gentoo-dev 2009-10-16 19:22:38 UTC
I've added a temporary workaround for portage in svn r14612.
Comment 35 Gilles Dartiguelongue (RETIRED) gentoo-dev 2009-10-17 14:19:25 UTC
*** Bug 282514 has been marked as a duplicate of this bug. ***
Comment 36 Samuli Suominen (RETIRED) gentoo-dev 2009-10-20 19:46:45 UTC
*** Bug 289876 has been marked as a duplicate of this bug. ***
Comment 37 Samuli Suominen (RETIRED) gentoo-dev 2009-10-21 20:06:21 UTC
*** Bug 290059 has been marked as a duplicate of this bug. ***
Comment 38 Petr Polezhaev 2009-10-21 20:14:13 UTC
Maybe it will be better to just fix pygtk? It seems to be much faster and much better idea, at least for me. Anyway, usage of /dev/stderr directly is bad style.
Comment 39 SpanKY gentoo-dev 2009-10-21 20:57:21 UTC
other packages are broken by this change.  i'll probably get some time in the next few days to fix sandbox.
Comment 40 AlexeyZ 2009-10-22 18:46:04 UTC
z-esprimo ~ # eselect python list
Available python interpreters:
  [1]   python2.6 *
  [2]   python3.1
z-esprimo ~ # eselect python set 2

Fix same problem with gnome-extra/libgsf-1.14.16.
Comment 41 SpanKY gentoo-dev 2009-10-26 07:11:19 UTC
technically, same issue could come up if the fd were any sort of weird anonymous file like a socket: or whatever else the kernel/userland threw at us.  ive changed the code to ignore broken /proc/*/fd/ symlinks which have a colon in their name like "pipe:[6257865]" or "socket:[6257866]" or ...

this is in sandbox-2.2 now

http://git.overlays.gentoo.org/gitweb/?p=proj/sandbox.git;a=commitdiff;h=f23b9bef900c89c8a4e7c4e220570198257fe03b
Comment 42 Marcin Mirosław 2009-10-26 09:50:47 UTC
Thanks, it works :)
Comment 43 Zac Medico gentoo-dev 2009-10-31 04:37:23 UTC
There's a workaround in portage-2.1.7.2 and portage-2.2_rc47 depends on sandbox-2.2.