on xenial help sign in
Add upstart job to copy unity8 to a new tmpfs, setcap it, and bind-mount it

back; this is an ugly hack to set CAP_SYS_RESOURCE until we have a root-helper for it.

commit9847e037235a71479c69796ed80a834cfa3cf2f5 authorLoïc Minier <loic.minier@ubuntu.com> dateTue 15 Oct 2013, 16:07 (13 years ago) parentb476889
3 files changed+35
data/unity8-setcap.conf+32 debian/control+2 debian/unity8.install+1
data/unity8-setcap.confnew file+32
@@ -0,0 +1,32 @@
1+# unity8-setcap - ugly hacks to arrange for /usr/bin/unity8 to have CAP_SYS_RESOURCE
2+
3+# XXX replace me with some root-helper to gain CAP_SYS_RESOURCE XXX
4+
5+author "Loïc Minier <loic.minier@ubuntu.com>"
6+description "Ugly hacks to arrange for /usr/bin/unity8 to have CAP_SYS_RESOURCE"
7+
8+# start when first boot-hooks event is emitted and before lightdm (lightdm
9+# starts ubuntu-touch-session which starts unity8); note that /run is
10+# guaranteeds to be be there because lightdm starts on filesystem
11+start on boot-hooks and starting lightdm
12+
13+# NOT a task as otherwise this would block restarting lightdm
14+
15+env RUNDIR=/run/unity8-setcap
16+
17+# work needs to be done in pre-start as this really is a job with nothing to
18+# start
19+pre-start script
20+ if [ ! -e "$RUNDIR" ]; then
21+ mkdir "$RUNDIR"
22+ # /run is noexec, hence mounting another tmpfs exec
23+ # NB: unity8 is 35K; 512K should be enough for everyone
24+ mount -o rw,nosuid,nodev,exec,relatime,mode=755,size=512k -t tmpfs tmpfs "$RUNDIR"
25+ cp -a /usr/bin/unity8 "$RUNDIR"
26+ setcap CAP_SYS_RESOURCE=+ep "$RUNDIR/unity8"
27+ # bind-mount this back as unity8 checks dirname(argv[0]'s) == /usr to
28+ # decide whether it's installed or not
29+ mount --bind "$RUNDIR/unity8" /usr/bin/unity8
30+ fi
31+end script
32+
debian/control+2
@@ -78,6 +78,8 @@ Depends: gsettings-desktop-schemas,
7878 unity8-fake-env | qtubuntu-shell,
7979 unity8-private (= ${binary:Version}),
8080 unity8-private | unity-launcher-impl,
81+# for setcap:
82+ libcap2-bin,
8183 ${misc:Depends},
8284 ${shlibs:Depends},
8385Recommends: ${unity-default-masterscopes},
debian/unity8.install+1
@@ -14,3 +14,4 @@ usr/share/unity8/Shell.qml
1414usr/share/unity8/SideStage
1515usr/share/unity8/graphics
1616data/unity8.conf usr/share/upstart/sessions/
17+data/unity8-setcap.conf etc/init/boot-hooks/