-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[WIP] Add LXC package #4555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[WIP] Add LXC package #4555
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really interesting PR, well done. I will certainly give it a shot when I find cycles.
Things that's worth looking:
- Check at using a
conf/privilege
(@hgy59 or @publicarray may be able to give pointers) - For
apparmor
I haven't found much in the DSM7 dev manual (https://global.download.synology.com/download/Document/Software/DeveloperGuide/Firmware/DSM/7.0/enu/DSM_Developer_Guide_7_0_Beta.pdf). Perhaps worth contacting Synology to get advices?
I'm not sure what the correct way is to do this. This package is a bit weird in that it needs the I did not know how to use the "generic service support" variables when I do not actually have some kind of daemon to run so I wrote a temporary workaround. Unfortunately it conflicted with a recent commit so I just removed it when I rebased my work for the pull request. |
@rbrownwsws have you already solved the cross compile issue in the configure step of lxc?
|
@hgy59 I've not had a go at cross-compiling yet. So far I have only been trying to get it working on my own machine. In this case it might just be as simple as adding something like |
I tried the fix and compiled |
From the GitHub action it seems like I was lucky with my choice and there are some other problems with cross compiling. It looks to be mainly related to compiling the iptables stuff. Iptables and the xt_CHECKSUM kernel module are not strictly necessary but I included them to get the default networking running. If the default networking was disabled LXC might work fine on them, you would just have to set up the network yourself (or ideally patch the network script so that does not need xt_CHECKSUM). Annoyingly a lot of the other failures seem to be unrelated to my code. I bumped the version of libcap so github is trying to build ntopng which depends on it. The ntopng build then seems to be failing because it depends on a vulnerable version of expat which has been taken down to prevent people from using it. |
As part of working on getting the LXC AppArmor profiles working I've made a package for the AppArmor user space tools: https://github.com/rbrownwsws/spksrc/tree/apparmor/pr Edit: I have merged a more up-to-date version of this with the branch lxc/pr now It looks like it works but I have not really taken it for a spin yet. I'm leaving further testing for the weekend. I'm afraid it's probably a bit yucky as I have no idea what I am doing with cross-compiling the python binding code. I just took a stab at different CFLAGS etc. until I stopped getting errors and then bundled all of python to make it easier for me. I don't know if I'm doing something wrong but you also have to compile in two passes:
I've not done a proper pull request at the moment because I worry that I'll waste a lot of your GitHub Actions budget with it just spending ages building python then failing 11 times. Is there some way to opt-out from a pull request being built by GitHub Actions? I have only tried building for arch-apollolake-6.2 so far because the long build time and having to do two passes is a bit annoying. |
There is no opt-out for github actions implemented now, but you are free to cancel the github action when you are ignoring the results anyway (just one click on sometimes we wish to opt-out packages that are known to fail like ffsync... |
It turns out that I have made some changes to the build so it will hopefully build for all arches. 88f281 and generic arches will attempt to create the default network without using xt_CHECKSUM. I don't know how important that rule is but they must have had a reason for it so the default networking on 88f281 and generic arches may be broken / act a bit weird. I have not put a
BTW @hgy59 I cannot see the |
Squashed commit of the following: commit aacea9f23a7dd6e40d6552325adf307be8b931d5 Author: Ross Brown <[email protected]> Date: Tue Apr 20 01:42:49 2021 +0000 Refactor libapparmor/apparmor.mk commit c54454e2380e293d4167554f82105fe2582e768f Author: Ross Brown <[email protected]> Date: Mon Apr 19 19:41:46 2021 +0000 Mark more arches as unsupported commit ee9ce3685d6986428ec342d6f1b0a117966bcdcb Author: Ross Brown <[email protected]> Date: Mon Apr 19 03:04:31 2021 +0000 Make aa-utils use package conf dir by default commit 04ceaa0ba6ab663dca5ff2c415b21b82e5f68bfa Author: Ross Brown <[email protected]> Date: Mon Apr 19 00:42:34 2021 +0000 Enable single pass builds commit 1343f6057380334258d7d2bcd0daec1fe24e1232 Author: Ross Brown <[email protected]> Date: Sun Apr 18 23:38:05 2021 +0000 Edit libapparmor comment to match siblings commit 6183da9ffcfdfc39a65e4fb2af202d14daaefbb2 Author: Ross Brown <[email protected]> Date: Sun Apr 18 23:36:53 2021 +0000 Mark libapparmor as not supporting generic arches commit 5e769acfd29734ccede8b2e1a5c983b3a792abe2 Author: Ross Brown <[email protected]> Date: Sun Apr 18 23:29:48 2021 +0000 Fix install dirs for misc extra files commit 6b561b9f1baa610be35d41950ec40434af6713fe Author: Ross Brown <[email protected]> Date: Sun Apr 18 23:09:46 2021 +0000 Tidy up Makefiles commit 894dcdeb5a7064da861faafa035c398f2ca47c20 Author: Ross Brown <[email protected]> Date: Sun Apr 18 22:57:12 2021 +0000 Fix PLISTs commit 77fe4ea4fb7548a4b9b74cf150ddfed929506df2 Author: Ross Brown <[email protected]> Date: Sun Apr 18 22:37:05 2021 +0000 Fix easyprof data paths commit 6126e9a290d5025d6d087043a05a3d0dbccf034e Author: Ross Brown <[email protected]> Date: Sun Apr 18 22:34:55 2021 +0000 Switch to using git format-patch for patches commit b38b538e012fc1a78b9c3d4e49c43feaeb61dd84 Author: Ross Brown <[email protected]> Date: Sun Apr 18 22:27:47 2021 +0000 Use variables instead of patches to set destdirs commit fabd7793b372ffcff7e0316b364f8758a6ff3f4d Author: Ross Brown <[email protected]> Date: Sat Apr 17 00:54:38 2021 +0000 Tidy up apparmor-utils output commit 2cdbedc0f93691a5dd188ce5893497800f71cb97 Author: Ross Brown <[email protected]> Date: Sat Apr 17 00:36:07 2021 +0000 Fix installation of "apparmor" python module commit 1395a2a395e10d157eef4755d4aa5d95281e505e Author: Ross Brown <[email protected]> Date: Fri Apr 16 20:47:05 2021 +0000 Fix spk version commit baec955687562bf939ea0a53a1c47168325ccf67 Author: Ross Brown <[email protected]> Date: Fri Apr 16 20:44:06 2021 +0000 Fix easyprof commit e336ace9e2dfdbd7f0d69682dcad33ca2401a632 Author: Ross Brown <[email protected]> Date: Fri Apr 16 19:35:06 2021 +0000 Fix shebangs for apparmor-utils commit 9910cfd772e12c79bd3af104fe12ff9d171975ea Author: Ross Brown <[email protected]> Date: Fri Apr 16 19:23:36 2021 +0000 Create "aa-clean" target to clean up apparmor builds commit 3fe4dc3e2f26ab2f117e4a89c690ad41de45fe6e Author: Ross Brown <[email protected]> Date: Fri Apr 16 16:59:15 2021 +0000 First full build commit 0e2669c6675bf809738f2b83073cedee8a3b107f Author: Ross Brown <[email protected]> Date: Fri Apr 16 16:11:21 2021 +0000 Fix copy-paste error in apparmor-utils Makefile commit f21487abcc706c4c074214686c59f7d362ba209b Author: Ross Brown <[email protected]> Date: Fri Apr 16 15:06:48 2021 +0000 Build apparmor-profiles commit 4e190080eb095aac8b27f964134379357cc96d82 Author: Ross Brown <[email protected]> Date: Fri Apr 16 14:32:38 2021 +0000 Got apparmor-parser building commit 821ca40bd9aaaa77f24d960a10b8f23730e1b40f Author: Ross Brown <[email protected]> Date: Fri Apr 16 13:45:29 2021 +0000 Get apparmor-binutils working commit 8160cb292ccc75d715d7b19c2e3ee7c4bc69a5db Author: Ross Brown <[email protected]> Date: Fri Apr 16 12:33:42 2021 +0000 Fix hardcoded work dir commit 40c3f65731d1c9b420a07bc18511af23a6aeaee1 Author: Ross Brown <[email protected]> Date: Fri Apr 16 12:22:52 2021 +0000 Start work getting other parts of apparmor working commit ffa7c698bb0e0bb294a1c8b5540988ef4c9d2167 Author: Ross Brown <[email protected]> Date: Fri Apr 16 11:47:37 2021 +0000 Update libapparmor PLIST for python binding commit ffeb81e48130e93596f63a29d4f0669e8eccf789 Author: Ross Brown <[email protected]> Date: Fri Apr 16 11:41:44 2021 +0000 Build libapparmor python binding with no errors commit 73411de391bd5f611ed0369317051065a15df1a4 Author: Ross Brown <[email protected]> Date: Fri Apr 16 00:28:36 2021 +0000 Got past ./configure! commit e5089cf188ae92f747c92f2424df727fe56c20f5 Author: Ross Brown <[email protected]> Date: Thu Apr 15 23:29:57 2021 +0000 Making progress on building python binding commit 7d1ae281bc02a93588457a87b3992909e57bbe07 Author: Ross Brown <[email protected]> Date: Thu Apr 15 18:56:17 2021 +0000 More experiments with building apparmor python binding commit 1b9a5d574bd3643678875704752fe19a07cd7e55 Author: Ross Brown <[email protected]> Date: Thu Apr 15 14:19:53 2021 +0000 Update fix-install-dirs patch for new AppArmor version commit 6d7098e63ec1a6052df5e844cd7a5a89568d2c3a Author: Ross Brown <[email protected]> Date: Thu Apr 15 13:58:16 2021 +0000 Update apparmor to latest stable version commit 93cc5b53c857c57abeba354c1120e3fc963781fd Author: Ross Brown <[email protected]> Date: Thu Apr 15 12:46:16 2021 +0000 Got libapparmor building (without bindings) commit 9fdf2297082eb5739102dc960520e2a966c05d96 Author: Ross Brown <[email protected]> Date: Thu Apr 15 07:17:58 2021 +0000 More libapparmor WIP commit 775a9f6d73de329fee168e17c7cc0006dfab80a9 Author: Ross Brown <[email protected]> Date: Wed Apr 14 18:36:07 2021 +0000 Still trying to get libapparmor to build commit bbf2ede3af91b757562ddc2e511ddef8310e165c Author: Ross Brown <[email protected]> Date: Tue Apr 13 14:11:57 2021 +0000 Try to build libapparmor commit 5f6d77cb117f435a850c1f175cb6843001f63967 Author: Ross Brown <[email protected]> Date: Tue Apr 13 09:50:20 2021 +0000 Create initial working version N.B. Command links end up in a weird place
FYI @th0ma7 and @hgy59 I am probably going to stop here for now. Privileged containers seem to work fine but I cannot get the AppArmor profiles or unprivileged containers to work. I think I have hit a wall where the Synology provided kernel is just too old for those features to work as intended without significant workarounds. An older version of LXC might work better with the current Synology provided kernel but it would probably mean going back from LXC 4.0 to LXC 2.0 which is EOL on 1st June 2021. I might come back to this when the DSM7 kernel is released to see if they have updated to a new enough kernel for things to work better. I am happy to make tweaks if you are interested in merging any parts of this. |
I wonder if it should be "easier" to use LXC inside "debian chroot" (instead of natively on DSM) - as far as this package/concept is refactored to work again in DSM 6 and/or 7 |
@ymartin59 I am afraid I do not think "debian chroot" will help. I could not get unprivileged containers working because it relies on user namespaces. Unfortunately Synology did not enable them in their kernel and I do not think you can "module" that feature in. This leaves you with needing to compile a custom kernel with Something funny is going on with the AppArmor profiles. They use a syntax too new for the Synology version of |
It would be worth to give it another try today with DSM 7 |
Motivation: Add a package for
LXC
. Unlike the existingdocker
package which focuses on application containers LXC allows for the easy creation of system containers that have a more VM like experience.Linked issues:
Checklist
all-supported
completed successfullyFor the last couple of days I have been playing with LXC to see if I can use the limited resources of my NAS more efficiently when I do not need full VM levels of isolation. I don't know if I will get around to making this a fully polished package but I thought I would share what I have done so far in case anyone else is interested.
Privileged containers with a bridge+NAT network seem to be working fine. I have not tried unprivileged containers or other network configurations yet.
N.B. This package does not activate the AppArmor profiles at the moment so will be less secure than docker containers. You should not use it to host any possibly risky services as it will be easier for malicious users to escape the container than normal.
So far I have only been been building for my DS918+ (arch-apollolake-6.2) but the LXC github claims it should work on at least the following architectures:
Quick instructions if you want to have a go but have not used LXC before:
P.S. Thanks for your great project. It made things so much easier than having to faff around with the Synology package toolkit.