sorah / subsystemctl Goto Github PK
View Code? Open in Web Editor NEWUtility to run systemd in WSL2 with a Linux namespace
License: MIT License
Utility to run systemd in WSL2 with a Linux namespace
License: MIT License
Provided a working solution to this. Enjoy :)
Just a quick note to let you know that I've had a patch accepted into AppArmor (and have a similar one awaiting review for snapd) to support running under WSL:
https://gitlab.com/apparmor/apparmor/-/merge_requests/812
As suggested in the comments there, there's a potential issue with AppArmor profiles leaking from distro to distro and/or from container to container because of WSL's architecture, so to avoid this problem in genie, I've arranged for it to create an AppArmor namespace before starting systemd (if AppArmor support is detected in the kernel) to prevent potential leakage.
Thought I'd let the other authors of WSL systemd hacks know in case you wish to take similar measures. In case it might be useful, my implementation of this can be found here, called from here.
Regards,
Alistair
genie developer
Complete!
[root@NOKIE-x270 home]# neofetch
.. root@NOKIE-x270
.PLTJ. ---------------
<><><><> OS: CentOS Linux 7 (Core) on Windows 10 x86_64
KKSSV' 4KKK LJ KKKL.'VSSKK Kernel: 5.4.91-microsoft-standard-WSL2
KKV' 4KKKKK LJ KKKKAL 'VKK Uptime: 19 mins
V' ' 'VKKKK LJ KKKKV' ' 'V Packages: 1119 (rpm)
.4MA.' 'VKK LJ KKV' '.4Mb. Shell: bash 4.2.46
. KKKKKA.' 'V LJ V' '.4KKKKK . CPU: Intel i7-6600U (4) @ 2.807GHz
.4D KKKKKKKA.'' LJ ''.4KKKKKKK FA. Memory: 168MiB / 12687MiB
<QDD ++++++++++++ ++++++++++++ GFD>
'VD KKKKKKKK'.. LJ ..'KKKKKKKK FV
' VKKKKK'. .4 LJ K. .'KKKKKV '
'VK'. .4KK LJ KKA. .'KV'
A. . .4KKKK LJ KKKKA. . .4
KKA. 'KKKKK LJ KKKKK' .4KK
KKSSA. VKKK LJ KKKV .4SSKK
<><><><>
'MKKM'
''
[root@NOKIE-x270 home]#
โ โ /root/.cargo/bin/subsystemctl exec bash
error: Found argument 'bash' which wasn't expected, or isn't valid in this context
USAGE:
subsystemctl exec [FLAGS] [OPTIONS] [-- ...]
For more information try --help
i am using Windows 11, the latest WSL2. the bash does not exist or invalid.
but all commands are working good in Windows 10 WSL2.
please check, thank you!
by the way, you did a great job for this code, thank you very much!
Good news! everything working smoothly in both CENTOS7 and RHEL7. Just make sure that if you want to port those Linux Distro, make sure to pull the official images in their respective repos
I am having problem using genie as I am using incorrect LINUX DISTRO as i created it by myself. It is much easier to pull official LINUX Distro in their respective official images repositories.
THANK YOU TO THE AUTHOR! SUCH A GREAT WORK!
I am arranging my github profile, and will push/upload all the LINUX DISTRO images I am using!
Running subsystemctl exec -- echo 1
will normally prints 1
, but if you run it in a ssh session, it will show this:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Sys(ENOENT)', src/bottle.rs:385:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
So subsystemctl
is designed to work with root privilege, which I fully acknowledge, but recently I've been experimenting with chmod +s
on the executable.
What I noticed is that, after setting the setuid on subsystemctl
executable, start
and stop
subcommands still require you invoke sudo
, but the behavior of shell
and exec
subcommands is more interesting - you can run them without your current user as root, you can even issue the flag to, by the way, start the systemd container without problem, and you won't be automatically escalated to root if you run setuid-ed subsustemctl as a normal user - you run a new process as exactly who you are.
Just wondering if that was the expected behavior, or whether subsystemctl
is supposed to work with setuid at all.
Thank you ๐
the subsystemctl cannot load KVM inside the cockpit.
probably, the author may include this in his next release?
thank you!
The glxlgears
works just fine, but executing it inside the subsystemctl says that it couldn't open display :0
In this case i use WSL Graphic via /dev/dxg
[root@LAPTOP ~]# subsystemctl start
[root@LAPTOP ~]# DISPLAY=:0 glxgears
Error: couldn't open display :0
https://aur.archlinux.org/packages/subsystemctl
return 404 for now
https://aur.archlinux.org/packages/subsystemctl
404 - Page Not Found
Sorry, the page you've requested does not exist.
I was able to run the subsystemctl in Centos 8, however, it is the same with genie, there are few application that are depreciated, like the firewalld.
All you need to do is to compile to the latest systemd 248.3 or later. and the subsystemctl is working in WSL2.
While in the environment cat /proc/sys/fs/binfmt_misc/WSLInterop
produces this error
Too many levels of symbolic links
This breaks wslu
Executing echo $WSL_DISTRO_NAME
in subsystemctl shell
currently doesn't work, others environment variables such as $DISPLAY
isn't inherited too.
I think it is good to have a way to specify a list of environment variables to clone like genie does.
When inside the systemd environment the windows paths are missing.
These paths are there when outside the system environment.
How do I automatically append windows paths when entering the system environment?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.