jakzale / systemd-namespace

A simple utility tool for wsl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WSL Helper for starting systemd

We use this tool to enter all the namespaces associated with the systemd process.

TODO

  • add proper PAM session/login (shadow-utils/login)
  • reimplement nsenter to avoid external call
  • reimplement pgrep to avoid external call
  • move everything to a single C file
  • add install script
    • /etc/wsl.conf
    • improved /etc/profile
  • [-] adopt the suckless C coding style

Other services to be started with systemd

  • keyring/secretservice (gnome-keyring)
  • ssh-agent (or above)
  • gpg-agent (or above)
  • keybase (without gui)

Finding the systemd process

We use the procps library to find the oldest systemd process, and get its pid.

Entering the namespace

In order to enter the systemd process namespace we need to know the following:

  • pid of systemd process,
  • the path of cwd,
  • uid of the current user,
  • gid of the current user,
  • the path to shell.

After that, we enter the following namespaces,

  • the pid namespace, as we need a fresh namespace for the systemd process to run as PID 1, and
  • the mnt namespace, as we need a fresh namespace for the /proc filesystem that matches the new pid namespace.

After that we need to login the user and set all the permissions correctly.

Loggin in the user

Technically, the user is already logged in, however we did not perform

Starting the shell

About

A simple utility tool for wsl

License:Other


Languages

Language:C 94.7%Language:CMake 5.3%