Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
cmd,interfaces: add initial support for Solus #3720
Conversation
zyga
approved these changes
Aug 11, 2017
My initial feeling is LGTM though please check the libraries and remove any unneeded cruft that is just there because we also support a weird hybrid ubuntu 14.04 with deputy systemd that you don't need.
Some of the apparmor rules may need tweaking later on, specifically we might make the opengl parts conditional on solus but I don't think we ought to block on that.
| + /usr/lib64/libcap.so* mr, | ||
| + /usr/lib64/libcgmanager.so* mr, | ||
| + /usr/lib64/libdl-[0-9]*.so* mr, | ||
| + /usr/lib64/libnih.so* mr, |
zyga
Aug 11, 2017
Contributor
libnih is I think only used on 14.04 systems, you may not need those unless they are really present on solus.
| mount options=(rw rslave) -> /tmp/snap.rootfs_*/lib/modules/, | ||
| mount options=(rw rbind) /var/log/ -> /tmp/snap.rootfs_*/var/log/, | ||
| mount options=(rw rslave) -> /tmp/snap.rootfs_*/var/log/, | ||
| mount options=(rw rbind) /usr/src/ -> /tmp/snap.rootfs_*/usr/src/, | ||
| mount options=(rw rslave) -> /tmp/snap.rootfs_*/usr/src/, | ||
| + |
zyga
Aug 11, 2017
Contributor
I'm curious about those two rules, they look fine but I wasn't aware we need them or that we perform those operations.
| + /usr/lib64/libgcc_s.so* mr, | ||
| + | ||
| + # normal libs in order biarch + usr-merged | ||
| + /usr/lib64/libapparmor.so* mr, |
jdstrand
Aug 14, 2017
Contributor
Same comment from me on these. Instead of adding yours, can you instead change this:
/lib/@{multiarch}/ld-*.so mr,
# libc, you are funny
/lib/@{multiarch}/libc{,-[0-9]*}.so* mr,
/lib/@{multiarch}/libpthread{,-[0-9]*}.so* mr,
/lib/@{multiarch}/librt{,-[0-9]*}.so* mr,
/lib/@{multiarch}/libgcc_s.so* mr,
# normal libs in order
/lib/@{multiarch}/libapparmor.so* mr,
/lib/@{multiarch}/libcgmanager.so* mr,
/lib/@{multiarch}/libnih.so* mr,
/lib/@{multiarch}/libnih-dbus.so* mr,
/lib/@{multiarch}/libdbus-1.so* mr,
/lib/@{multiarch}/libudev.so* mr,
/usr/lib/@{multiarch}/libseccomp.so* mr,
/lib/@{multiarch}/libseccomp.so* mr,
to:
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}ld-*.so mrix,
# libc, you are funny
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libc{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libpthread{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}librt{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libgcc_s.so* mr,
# normal libs in order
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libapparmor.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libcgmanager.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libnih.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libnih-dbus.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libdbus-1.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libudev.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libseccomp.so* mr,
| + /usr/lib64/libdbus-1.so* mr, | ||
| + /usr/lib64/libudev.so* mr, | ||
| + /usr/lib64/libseccomp.so* mr, | ||
| + /usr/lib64/libseccomp.so* mr, |
zyga
changed the title from
Add initial support for Solus
to
cmd,interfaces: add initial support for Solus
Aug 11, 2017
| @@ -45,6 +45,9 @@ case "$ID" in | ||
| # patches find their way into the distribution. | ||
| extra_opts="--libexecdir=/usr/lib/snapd --disable-apparmor" | ||
| ;; | ||
| + solus) | ||
| + extra_opts="--with-snap-mount-dir=/snap --enable-merged-usr --enable-nvidia-arch $@" |
ikeydoherty
Aug 11, 2017
Contributor
In the Solus package we do:
%autogen which actually calls ./autogen.sh %CONFOPTS% which passes all the configure arguments along, this makes autogen.sh complete the chain and pass them along to configure so that the whole thing is configured properly in one go
Conan-Kudo
Aug 14, 2017
Contributor
Does anyone actually use this script in packaging? AFAIK, it was originally created for the test harness...
ikeydoherty
Aug 14, 2017
Contributor
Yeah - it lets you configure the snap confine part, I'm using that within the package.yml ...
|
I'd agree that as the Solus support gets fleshed out that we might want that stuff to be conditional to save up spamming the rules/filters, and once we're at the multilib cross-roads we might want some Solus helper code to correctly append to the rules |
niemeyer
requested changes
Aug 12, 2017
Looks reasonable. One question, one problem we need to solve, and we need a review from jdstrand on those rule changes.
| + /usr/lib64/libc{,-[0-9]*}.so* mr, | ||
| + /usr/lib64/libpthread{,-[0-9]*}.so* mr, | ||
| + /usr/lib64/librt{,-[0-9]*}.so* mr, | ||
| + /usr/lib64/libgcc_s.so* mr, |
jdstrand
Aug 14, 2017
Contributor
These rules are fine on their own, but I think we want to make this more futureproof since we're starting to bring on more and more apparmor-enabled distros that don't follow Debian/Ubuntu directories. I suggest instead of your changes, changing these:
/lib/@{multiarch}/ld-*.so mr,
# libc, you are funny
/lib/@{multiarch}/libc{,-[0-9]*}.so* mr,
/lib/@{multiarch}/libpthread{,-[0-9]*}.so* mr,
/lib/@{multiarch}/librt{,-[0-9]*}.so* mr,
/lib/@{multiarch}/libgcc_s.so* mr,
# normal libs in order
/lib/@{multiarch}/libapparmor.so* mr,
/lib/@{multiarch}/libcgmanager.so* mr,
/lib/@{multiarch}/libdl-[0-9]*.so* mr,
/lib/@{multiarch}/libnih.so* mr,
/lib/@{multiarch}/libnih-dbus.so* mr,
/lib/@{multiarch}/libdbus-1.so* mr,
/lib/@{multiarch}/libudev.so* mr,
/usr/lib/@{multiarch}/libseccomp.so* mr,
/lib/@{multiarch}/libseccomp.so* mr,
to:
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}ld-*.so mrix,
# libc, you are funny
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libc{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libpthread{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}librt{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libgcc_s.so* mr,
# normal libs in order
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libapparmor.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libcgmanager.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libdl-[0-9]*.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libnih.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libnih-dbus.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libdbus-1.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libudev.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libseccomp.so* mr,
| + /var/lib/snapd/hostfs/usr/lib*/glx-provider/** rm, | ||
| + /var/lib/snapd/hostfs/usr/lib*/libcuda* rm, | ||
| + /var/lib/snapd/hostfs/usr/lib*/libn* rm, | ||
| + /var/lib/snapd/hostfs/usr/lib*/lib{GL,EGL}* rm, |
niemeyer
Aug 12, 2017
Contributor
Why is that necessary now and wasn't necessary before? @zyga, @mvo?
Note we have some logic under cmd/snap-confine/mount-support-nvidia.c related to this.
ikeydoherty
Aug 12, 2017
Contributor
Well the comment in the context does explain that, its required for Solus NVIDIA libraries, which are accessed under /usr/lib{,64}/glx-provider due to the /usr/lib*/libGL type symlinks, and the rest of the libs (actual NVIDIA ones, not conflicting OpenGL ones) live in the main library directory. And the non-Solus part was never present because the rules were created for Arch Linux which doesn't actually have full apparmor confinement, so it was never exposed until now.
zyga
Aug 13, 2017
•
Contributor
Exactly as @ikeydoherty explained. In solus nvidia layout is similar to arch so snap-confine was built with --with-nvidia-arch which was never confined to begin with.
niemeyer
Aug 14, 2017
Contributor
@zyga Sorry for being a bit slow, here but the question is this: how are people able to use nvidia libraries on Ubuntu if we don't have those rules, and where is the rule in the nvidia support of snap-confine that puts those libraries into /var/lib/snapd/lib/gl as they should be?
zyga
Aug 16, 2017
Contributor
There are two implementations of nvidia support, one for "ubuntu" like systems and one for "arch" like systems. The ubuntu part had the correct apparmor rules because we had to write those. The arch part never had because there was no good place to actually explore and test those. Solus is "arch" like and with enabled apparmor was the first distribution to explore this combination.
zyga
Aug 16, 2017
Contributor
Note that on "arch" like systems /var/lib/snapd/lib/gl contains a tmpfs with a symlink farm so the effective files we access are different from what we did on Ubuntu.
| @@ -32,6 +32,12 @@ if [ ! -z "$1" ]; then | ||
| o=shell | ||
| fi | ||
| +# If the version is passed in the environment during build, let's use that |
niemeyer
Aug 12, 2017
Contributor
That doesn't look right. It implies the logic that is telling the code what its version is will be outside the code itself, which means there's a very realistic probability of updating the code without changing the version. That will create a lot of very confusing issues, including serious breakages as we do take the version into account in some places.
The right way of doing this is running mkversion.sh when the code is extracted from git. The result will then have the version encoded statically and may be shipped anywhere without the git metadata.
ikeydoherty
Aug 12, 2017
Contributor
Yes but this isn't being built from git, it's being built from the vendor tarball (which apparently doesn't know its own version) - thus passing the version in from the package metadata during build
zyga
Aug 13, 2017
Contributor
@niemeyer this matches what we do elsewhere but since we don't want to force people to run dpkg-parsechangelogs we offer a simple "this is the version right here" already (via command line argument). This patch extends the feature to environment value since it is easier to integrate in souls.
Conan-Kudo
Aug 14, 2017
Contributor
I don't know if it's a good idea for mkversion to just be pulling random shell variables. I added the ability to pass it as a parameter so that you can control the input.
ikeydoherty
Aug 14, 2017
Contributor
But mkversion is within the autogen pipeline, so to support correct and proper autogen invocation, the call to mkversion has to "learn" it from somewhere.. I also wouldn't really call it "random" given that its part of the documented ypkg build environment, which is sanely controlled. If it's gonna be that much of a problem I can split it to call mkversion prior to the autogen call, but I'd still need the parameters passed to configure like I'm doing now (Otherwise, it's a pretty pointless autogen)
Conan-Kudo
Aug 14, 2017
Contributor
I suggest calling it before the autogen call, as I do for the Fedora packaging.
niemeyer
Aug 14, 2017
•
Contributor
I don't think we want environment variable, positional parameters, or flag parameters that provide a version into this script. We want this script to tell the version based on the git data, and we want this version to be statically saved into the filesystem so that it can be packed. If we have vendor tarballs that do not contain their own version today, these tarballs are broken and should be fixed. We want the source code to know its version, instead of expecting the person that builds the tarball to keep its version in mind and pass it in via a parameter. That latter approach will definitely result in binaries reporting their version incorrectly eventually.
niemeyer
Aug 14, 2017
Contributor
Let's please fix any such broken tarballs now, while it's early and we haven't suffered any major pain due to that.
codecov-io
commented
Aug 14, 2017
•
Codecov Report
@@ Coverage Diff @@
## master #3720 +/- ##
==========================================
- Coverage 75.7% 75.69% -0.01%
==========================================
Files 391 391
Lines 33936 33938 +2
==========================================
- Hits 25690 25689 -1
- Misses 6420 6423 +3
Partials 1826 1826
Continue to review full report at Codecov.
|
|
I've rebased the PR on master (dropping the commits/merges added on top of the commit) - and removed the |
zyga
requested a review
from
jdstrand
Aug 14, 2017
jdstrand
requested changes
Aug 14, 2017
The security policy overall looks good, but I think we can future-proof a bit more (while still being cautious with our snap-confine's rules) and have a few small changes I'd like to see.
| @@ -67,7 +67,7 @@ func distroSupportsReExec() bool { | ||
| return false | ||
| } | ||
| switch release.ReleaseInfo.ID { | ||
| - case "fedora", "centos", "rhel", "opensuse", "suse", "poky", "arch": | ||
| + case "fedora", "centos", "rhel", "opensuse", "suse", "poky", "arch", "solus": |
jdstrand
Aug 14, 2017
Contributor
Not (necessarily) to be fixed in this PR, but only seeing this code for the first time, I was surprised this list wasn't alphabetized.
Conan-Kudo
Aug 16, 2017
Contributor
I don't know why we don't just have a list where re-exec is enabled rather than a disable list. The enable list is many times shorter (it's just Ubuntu and Debian).
| + /usr/lib64/libc{,-[0-9]*}.so* mr, | ||
| + /usr/lib64/libpthread{,-[0-9]*}.so* mr, | ||
| + /usr/lib64/librt{,-[0-9]*}.so* mr, | ||
| + /usr/lib64/libgcc_s.so* mr, |
jdstrand
Aug 14, 2017
Contributor
These rules are fine on their own, but I think we want to make this more futureproof since we're starting to bring on more and more apparmor-enabled distros that don't follow Debian/Ubuntu directories. I suggest instead of your changes, changing these:
/lib/@{multiarch}/ld-*.so mr,
# libc, you are funny
/lib/@{multiarch}/libc{,-[0-9]*}.so* mr,
/lib/@{multiarch}/libpthread{,-[0-9]*}.so* mr,
/lib/@{multiarch}/librt{,-[0-9]*}.so* mr,
/lib/@{multiarch}/libgcc_s.so* mr,
# normal libs in order
/lib/@{multiarch}/libapparmor.so* mr,
/lib/@{multiarch}/libcgmanager.so* mr,
/lib/@{multiarch}/libdl-[0-9]*.so* mr,
/lib/@{multiarch}/libnih.so* mr,
/lib/@{multiarch}/libnih-dbus.so* mr,
/lib/@{multiarch}/libdbus-1.so* mr,
/lib/@{multiarch}/libudev.so* mr,
/usr/lib/@{multiarch}/libseccomp.so* mr,
/lib/@{multiarch}/libseccomp.so* mr,
to:
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}ld-*.so mrix,
# libc, you are funny
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libc{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libpthread{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}librt{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libgcc_s.so* mr,
# normal libs in order
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libapparmor.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libcgmanager.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libdl-[0-9]*.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libnih.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libnih-dbus.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libdbus-1.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libudev.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libseccomp.so* mr,
| + /usr/lib64/libdl-[0-9]*.so* mr, | ||
| + /usr/lib64/libdbus-1.so* mr, | ||
| + /usr/lib64/libudev.so* mr, | ||
| + /usr/lib64/libseccomp.so* mr, |
| @@ -154,13 +168,15 @@ | ||
| mount options=(rw rslave) -> /tmp/snap.rootfs_*/run/, | ||
| mount options=(rw rbind) {/usr,}/lib/modules/ -> /tmp/snap.rootfs_*/lib/modules/, | ||
| + mount options=(rw rbind) {/usr,}/lib64/modules/ -> /tmp/snap.rootfs_*/lib/modules/, |
jdstrand
Aug 14, 2017
Contributor
Instead of adding your rule, can you change this:
mount options=(rw rbind) {/usr,}/lib/modules/ -> /tmp/snap.rootfs_*/lib/modules/,
to:
mount options=(rw rbind) {/usr,}/lib{,32,64,x32}/modules/ -> /tmp/snap.rootfs_*/lib/modules/,
| @@ -235,6 +251,9 @@ | ||
| /sys/module/nvidia/version r, | ||
| /usr/** r, | ||
| mount options=(rw bind) /usr/lib/nvidia-*/ -> /{tmp/snap.rootfs_*/,}var/lib/snapd/lib/gl/, | ||
| + /tmp/snap.rootfs_*/var/lib/snapd/lib/gl/* w, | ||
| + mount fstype=tmpfs none -> /tmp/snap.rootfs_*/var/lib/snapd/lib/gl/, |
jdstrand
Aug 14, 2017
Contributor
I think you should be able to change this rule to be:
mount fstype=tmpfs options=(rw nodev nosuid) none -> /tmp/snap.rootfs_*/var/lib/snapd/lib/gl/,
Can you do so and verify it still works?
ikeydoherty
Aug 14, 2017
Contributor
That's what I originally had, which is why I stripped options from it (didn't work, I'd copy-edited the other tmpfs one i'd found)
| @@ -235,6 +251,9 @@ | ||
| /sys/module/nvidia/version r, | ||
| /usr/** r, | ||
| mount options=(rw bind) /usr/lib/nvidia-*/ -> /{tmp/snap.rootfs_*/,}var/lib/snapd/lib/gl/, | ||
| + /tmp/snap.rootfs_*/var/lib/snapd/lib/gl/* w, | ||
| + mount fstype=tmpfs none -> /tmp/snap.rootfs_*/var/lib/snapd/lib/gl/, | ||
| + mount options=(remount,ro) -> /tmp/snap.rootfs_*/var/lib/snapd/lib/gl/, |
jdstrand
Aug 14, 2017
Contributor
For consistency with other mount rules in the policy, can you change this rule of yours to be this equivalent rule (options may be space or comma separated):
mount options=(remount ro) -> /tmp/snap.rootfs_*/var/lib/snapd/lib/gl/,
| + /usr/lib64/libdbus-1.so* mr, | ||
| + /usr/lib64/libudev.so* mr, | ||
| + /usr/lib64/libseccomp.so* mr, | ||
| + |
| + /usr/lib64/libgcc_s.so* mr, | ||
| + | ||
| + # normal libs in order biarch + usr-merged | ||
| + /usr/lib64/libapparmor.so* mr, |
jdstrand
Aug 14, 2017
Contributor
Same comment from me on these. Instead of adding yours, can you instead change this:
/lib/@{multiarch}/ld-*.so mr,
# libc, you are funny
/lib/@{multiarch}/libc{,-[0-9]*}.so* mr,
/lib/@{multiarch}/libpthread{,-[0-9]*}.so* mr,
/lib/@{multiarch}/librt{,-[0-9]*}.so* mr,
/lib/@{multiarch}/libgcc_s.so* mr,
# normal libs in order
/lib/@{multiarch}/libapparmor.so* mr,
/lib/@{multiarch}/libcgmanager.so* mr,
/lib/@{multiarch}/libnih.so* mr,
/lib/@{multiarch}/libnih-dbus.so* mr,
/lib/@{multiarch}/libdbus-1.so* mr,
/lib/@{multiarch}/libudev.so* mr,
/usr/lib/@{multiarch}/libseccomp.so* mr,
/lib/@{multiarch}/libseccomp.so* mr,
to:
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}ld-*.so mrix,
# libc, you are funny
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libc{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libpthread{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}librt{,-[0-9]*}.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libgcc_s.so* mr,
# normal libs in order
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libapparmor.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libcgmanager.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libnih.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libnih-dbus.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libdbus-1.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libudev.so* mr,
/{,usr/}lib{,32,64,x32}/{,@{multiarch}/}libseccomp.so* mr,
| + /var/lib/snapd/hostfs/usr/lib*/glx-provider/** rm, | ||
| + /var/lib/snapd/hostfs/usr/lib*/libcuda* rm, | ||
| + /var/lib/snapd/hostfs/usr/lib*/libn* rm, | ||
| + /var/lib/snapd/hostfs/usr/lib*/lib{GL,EGL}* rm, |
jdstrand
Aug 14, 2017
Contributor
I think we want something more like this:
# Solus LDM locations
/var/lib/snapd/hostfs/usr/lib{,32,64}/glx-provider/**.so{,.*} rm,
/var/lib/snapd/hostfs/usr/lib{,32,64}/libcuda*.so{,.*} rm,
/var/lib/snapd/hostfs/usr/lib{,32,64}/libnvidia*.so{,.*} rm,
/var/lib/snapd/hostfs/usr/lib{,32,64}/lib{GL,EGL}.so{,.*} rm,
Can you test and report back any errors? I thought using lib{,32,64} is good for future-proofing, but I also wanted to tighten up the rules to only mmap() .so files. Also, libn* seemed too generic so I guessed you wanted libnvidia*, but please adjust as necessary. If the above doesn't work for you, feel free to adjust and/or paste the apparmor denials.
ikeydoherty
Aug 14, 2017
Contributor
Well libnv maybe, there are a few in there but yeah we'll tighten them up and allow the biarch approach (We do have the lib32 dirs too fwiw)
|
Note if you merge with upstream/master, you'll get #3789 which will address my comments regarding future-proofing the policy. Other comments remain. |
|
I'll try to pick this up and get it merged. |
ikeydoherty commentedAug 11, 2017
•
Edited 1 time
-
ikeydoherty
Aug 14, 2017
$@arguments toconfigurescriptSigned-off-by: Ikey Doherty ikey@solus-project.com