#675788 schroot: PulseAudio not working in a default desktop schroot

Package:
schroot
Source:
schroot
Description:
Execute commands in a chroot environment
Submitter:
Luca Capello
Date:
2015-02-04 21:39:04 UTC
Severity:
wishlist
#675788#5
Date:
2012-06-03 11:06:33 UTC
From:
To:
Hi there!

With the latest upgrade, /etc/schroot/desktop/fstab gained PulseAudio
support (BTW, there is an extra space before the target folder):

#675788#10
Date:
2012-06-05 09:16:15 UTC
From:
To:
The desktop profile was user-contributed, and I don't use it myself
other than trivial testing that it works for basic stuff.  If you
could let me know what's needed, I'll be happy to update the profile.
Note that if it's backward-compatible with earlier distributions, then
that's even better.


Thanks,
Roger

#675788#19
Date:
2014-11-24 14:03:59 UTC
From:
To:
severity 675788 wishlist
tags 675788 + moreinfo wontfix
thanks

In the absence of the needed information to make things work, I won't
be able to fix this bug.  Did you get this working at all?  If you have
an updated configuration to share that would be very useful.

Marking as moreinfo/wontfix for the time being, and reducing the
severity since desktop stuff inside schroot is not something we can
support well, unfortunately, and it's only got more complex and
fragile.


Regards,
Roger

#675788#24
Date:
2015-01-06 17:44:34 UTC
From:
To:
Hi,

While debugging a similar issue (I was trying to run skype inside a
chroot without sharing my home directory), I found this bug report, and
I think I can give the missing information to solve it.

When running skype, I was getting errors about not being able to create
directories under /run/user. Then I found this webpage that lists all
the needed locations that need to be replicated:
http://www.freedesktop.org/wiki/Software/PulseAudio/FAQ/#index36h3
(although I did not share ~/.pulse and it still worked).

In particular, pulseaudio needed the $XDG_RUNTIME_DIR location, which is
in /run/user when using systemd. I tried at first to bind mount /run,
but that did not work: each user has a tmpfs with special mount options
to force the UID which do not seem to be replicated when bind mounting
the parent dir, so the files appear as owned by root.

The problem now is that schroot does not seem to have any way to tell it
to mount directories based on environment variables.. I don't know the
code to suggest a workaround, but maybe one option would be to add a
configuration value that enables automatic mounting of the user's XDG_*
directories?

#675788#29
Date:
2015-01-07 13:34:21 UTC
From:
To:
Such logic isn't built in to schroot.  But it's easy to add support using
a custom setup script.  It can look at the environment and ensure that
XDG_XXX_DIR is bind mounted into the chroot.  This should probably be done
by default for the desktop profile if it's set.  However, this type of
thing is going to be fraught with problems due to the way systemd
deletes the directory when the session ends, since a schroot session can
persist for much longer.  XDG_XXX_DIR is quite poorly-specified and it's
likely we won't be able to do a good job of supporting it.  That said,
any improvements, even if imperfect, would be welcome.


Regards,
Roger

#675788#34
Date:
2015-02-04 19:12:57 UTC
From:
To:
Although this is not the right solution (as the XDG vars might point to
some other location), the problem with the systemd-related mounts is
solved if instead of using bind-mounts one uses rbind-mounts (recursive
bind).

I changed my desktop/fstab file and now I get sound with no errors:

/dev           /dev            none    rw,rbind         0       0
/run           /run            none    rw,rbind         0       0
#/run/lock      /run/lock       none    rw,bind         0       0
#/dev/shm       /dev/shm        none    rw,bind         0       0
#/run/shm       /run/shm        none    rw,bind         0       0

Found this by chance. I was reading instructions to set up a schroot for
ubuntu[0], and noticed they used rbinds, which I had never heard of
before! After reading the manpage, I thought this could work, and it did.

[0]: https://wiki.ubuntu.com/DebootstrapChroot

#675788#39
Date:
2015-02-04 21:30:42 UTC
From:
To:
+++ Martín Ferrari [2015-02-04 19:12 +0000]:

I found another circumstance that was fixed by using rbind, but at the
time this did not sit well with autofs. I don't know if that has
changed in the last 3 years:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=648459

Wookey

#675788#44
Date:
2015-02-04 21:36:52 UTC
From:
To:
We deliberately removed the use of rbind mounts because it broke
systemd users' systems.  Until then they used to be the default.

The bug is that rbinding a directory containing an autofs mount
results in a deadlocked system due to a kernel bug.  Maybe that's
fixed now.  This used to be the case for /dev and /sys.

I'd not be averse to restoring the use of rbind mounts.  HOWEVER,
we can't do this unconditionally.  We do need to know, if it is
fixed, which kernel version fixed it so that we can degrade to
a plain bind mount in the face of a buggy kernel version.  Since
it system is completely unusable shortly after doing the rbind
with autofs, it's not acceptable to do this blindly.


Regards,
Roger