Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 459856 - media-sound/pulseaudio - allow per-user pulseaudio daemon, allow thunderbird to start pulseaudio, and few small fixes
Summary: media-sound/pulseaudio - allow per-user pulseaudio daemon, allow thunderbird ...
Status: VERIFIED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: SELinux (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Sven Vermeulen (RETIRED)
URL:
Whiteboard: sec-policy r1
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-01 10:49 UTC by vespian
Modified: 2013-06-16 17:58 UTC (History)
1 user (show)

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


Attachments
Patch in git format-patch format (0001-Pulseaudio-fixes.patch,3.31 KB, patch)
2013-03-01 10:51 UTC, vespian
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description vespian 2013-03-01 10:49:08 UTC
Hi everybody, 


Pulseaudio policy currently does not allow for per-user daemon instance. On top of that there are few small things that this patch fixes as well. Please see the attached file.


Thanks!
pr

Reproducible: Always

Steps to Reproduce:
1.setup per-user pulseaudio setup
2.enable selinux
3.reboot, or issue pulseaudio -k
Actual Results:  
AVC denials


Portage 2.1.11.50 (default/linux/amd64/13.0/selinux, gcc-4.6.3, glibc-2.15-r3, 3.7.1 x86_64)
=================================================================
System uname: Linux-3.7.1-x86_64-AMD_FX-tm-6100_Six-Core_Processor-with-gentoo-2.1
KiB Mem:     8113244 total,   6018336 free
KiB Swap:    4192628 total,   4192628 free
Timestamp of tree: Fri, 15 Feb 2013 23:15:01 +0000
ld GNU ld (GNU Binutils) 2.22
app-shells/bash:          4.2_p37
dev-java/java-config:     2.1.12-r1
dev-lang/python:          2.7.3-r2, 3.2.3
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.11.8
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.4_p6-r1, 1.11.6
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.6.3
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.6 (virtual/os-headers)
sys-libs/glibc:           2.15-r3
Repositories: gentoo x-overlays
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/lib/hsqldb"
CONFIG_PROTECT_MASK="${EPREFIX}/etc/gconf /etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs candy config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch protect-owned sandbox selinux sesandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://mirror.netcologne.de/gentoo/ http://gentoo.prz.rzeszow.pl ftp://ftp.rhnet.is/pub/gentoo/"
LANG="pl_PL.utf8"
LC_ALL="pl_PL"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j7"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/overlays"
SYNC="rsync://rsync3.pl.gentoo.org/gentoo-portage"
USE="X Xaw3d a52 aac acpi alsa amd64 apache2 arts avx bash-completion berkdb bzip2 cairo cdda cdparanoia cdr cli consolekit cracklib crypt cups cxx dbus declarative dri dts dvd dvdr dvdread encode exif fam fbcon ffmpeg fftw firefox flac fortran ftp gdbm gif glitz gphoto2 gpm gtk gtk2 iconv icu ipv6 java javascript jpeg jpeg2k kde kipi lcms libnotify lm_sensors mad mmx mmxext mng modules motif mp3 mpeg mudflap multilib ncurses nls nptl nsplugin ogg open_perms opengl openmp pam pango pcre pdf phonon plasma png policykit ppds pulseaudio python qt3 qt3support qt4 quicktime readline sdl selinux session slang spell sse sse2 ssl ssse3 startup-notification svg tcpd tiff truetype ubac udev udisks unicode usb v4l vcd vorbis w32codecs x264 xcomposite xfs xinerama xml xscreensaver xulrunner xv xvid xvmc zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="pl en" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="v4l fglrx" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 vespian 2013-03-01 10:51:00 UTC
Created attachment 340620 [details, diff]
Patch in git format-patch format
Comment 2 Sven Vermeulen (RETIRED) gentoo-dev 2013-03-17 10:14:57 UTC
Stuff like the following should be best done through an interface:

"""
+pulseaudio_domtrans(user_t);
+pulseaudio_signull(user_t);
+pulseaudio_stream_connect(user_t);
+
+#User should be able to manage its daemon:
+#user_t
+manage_files_pattern(user_t,pulseaudio_home_t,pulseaudio_home_t);
+read_lnk_files_pattern(user_t,pulseaudio_home_t,pulseaudio_home_t);
+setattr_dirs_pattern(user_t,pulseaudio_home_t,pulseaudio_home_t);
"""

There is the pulseaudio_role() interface that is meant to allow user domains to use pulseaudio which includes most (all?) of the above, so perhaps all you need to do is call

"""
pulseaudio_role(user_r, user_t)
"""

and the same for staff?
Comment 3 vespian 2013-03-19 20:33:33 UTC
(In reply to comment #2)
(...)

Yeah, using interface is a better approach. I did not check for it earlier :(

The problem is that if you use this interface:

pulseaudio_role(user_r, user_t)
pulseaudio_role(staff_r, staff_t)

,it results in a conflict:

pulseaudio.te":232:ERROR 'duplicate filename transition for: filename_trans .pulse staff_t user_home_dir_t:dir' at token ';' on line 12211

or with more details:

budrys targeted # pwd
/var/tmp/portage/sec-policy/selinux-pulseaudio-9999/work/targeted
budrys targeted # grep \"\.pulse\" ./tmp/pulseaudio.tmp
##### begin userdom_user_home_dir_filetrans(user_t,pulseaudio_home_t,dir,".pulse") depth: 2
        type_transition user_t user_home_dir_t:dir pulseaudio_home_t ".pulse";
##### end userdom_user_home_dir_filetrans(user_t,pulseaudio_home_t,dir,".pulse") depth: 1
##### begin userdom_user_home_dir_filetrans(staff_t,pulseaudio_home_t,dir,".pulse") depth: 2
        type_transition staff_t user_home_dir_t:dir pulseaudio_home_t ".pulse";
##### end userdom_user_home_dir_filetrans(staff_t,pulseaudio_home_t,dir,".pulse") depth: 1
##### begin userdom_user_home_dir_filetrans(pulseaudio_t,pulseaudio_home_t,dir,".pulse") depth: 1
        type_transition pulseaudio_t user_home_dir_t:dir pulseaudio_home_t ".pulse";
##### end userdom_user_home_dir_filetrans(pulseaudio_t,pulseaudio_home_t,dir,".pulse") depth: 0
##### begin pulseaudio_home_filetrans_pulseaudio_home(pulseaudio_client,dir,".pulse") depth: 1
##### begin userdom_user_home_dir_filetrans(pulseaudio_client,pulseaudio_home_t,dir,".pulse") depth: 2
        type_transition pulseaudio_client user_home_dir_t:dir pulseaudio_home_t ".pulse";
##### end userdom_user_home_dir_filetrans(pulseaudio_client,pulseaudio_home_t,dir,".pulse") depth: 1
##### end pulseaudio_home_filetrans_pulseaudio_home(pulseaudio_client,dir,".pulse") depth: 0

IMO we can remove offending rule and take Fedoras approach - modify the userdom_base_user_template granting all the users access to pulseaudio. 



What do you think ? I can try to prepare the patches.
pr
Comment 4 vespian 2013-03-19 21:05:48 UTC
(In reply to comment #3)

...or we can try to use pulseaudio_domtrans. The same effect but without conflicts.

This way or another I think that there should be a permission for user domains to start and use the pulseaudio daemon by default.



pr
Comment 5 Sven Vermeulen (RETIRED) gentoo-dev 2013-03-20 08:46:47 UTC
That collision is, I think, a bug in the policy (which was merged by fedora to upstream).

pulseaudio_role calls pulseaudio_run, which calls pulseaudio_domtrans, which marks the domain as a pulseaudio_client.

However, pulseaudio_role also directly sets the userdom_user_home_dir_filetrans, which is already done because of the mapping towards the pulseaudio_client attribute.

I'll doublecheck, but I'll probably remove the explicit userdom_user_home_dir_filetrans from the pulseaudio_role() interface.
Comment 6 Sven Vermeulen (RETIRED) gentoo-dev 2013-04-11 07:22:59 UTC
The file translations have been removed (also pushed upstream); the unprivuser (user_t) and staff (staff_t) now have pulseaudio_role set too.

Fixed in repo, will be in rev 13
Comment 7 Sven Vermeulen (RETIRED) gentoo-dev 2013-05-06 18:26:18 UTC
In main tree,  ~arch'ed (20130424-r1 release)
Comment 8 Sven Vermeulen (RETIRED) gentoo-dev 2013-06-16 17:58:08 UTC
Now stable in repo