A wrapper of `/bin/sh` that limits the available commands.
shell sh zig security

README.md

Limited Shell #

A wrapper of /bin/sh that limits the available commands. Useful if you want to harden your CD pipelines.

Usage #

  1. Change the default shell of the user to /usr/local/bin/limited-shell (or /usr/bin/limited-shell).
  2. Create the config directory /etc/limited-shell.
  3. Create the file /etc/limited-shell/user (replace user by its username).
  4. List allowed commands in this file. You can use * to allow every subcommands.

Now, the user can only use the listed commands.

Build #

This project uses Zig 0.16.

Build it with:

zig build

The binary is in ./zig-out/bin/limited-shell.

Then, you can install it with:

sudo install -m 755 -o root:root ./zig-out/bin/limited-shell /usr/local/bin/limited-shell

Doc #

The manpages are written with scdoc.

You can generate them with:

scdoc < docs/limited-shell.1.scd > docs/limited-shell.1
scdoc < docs/limited-shell.5.scd > docs/limited-shell.5

And you can install them with:

sudo install -m 755 ./docs/limited-shell.1 /usr/local/man/man1/
sudo install -m 755 ./docs/limited-shell.5 /usr/local/man/man5/

Release #

Build the project for being released with:

zig build --release=fast  # or any other release mode

If you want to keep debug information, use:

zig build --release=fast -Dkeep-debug