Stackable Wrappers

An implementation of what I said above would be the following.

Create a file called /usr/bin/stackable-wrapper and add:

#!/bin/bash

sw_dir="/etc/wrapper.d"
program_name="$(basename $0)"

if [ -f "${sw_dir}/${program_name}.conf" ]; then
  . "${sw_dir}/${program_name}.conf"
else
  echo "ERROR: File ${sw_dir}/${program_name}.conf doesn't exist!"
  exit 1
fi

# So we don't execute ourselves.
PATH="$(echo ${PATH} | sed -e 's/\/usr\/local\/bin\://g')"

${wrapper_pre} ${program_name} ${wrapper_post}

Then create the config file e.g. /etc/wrapper.d/gpg.conf:

wrapper_pre="torsocks firejail"
wrapper_post="--example"

Then symlink it:

ln -s /usr/bin/stackable-wrapper /usr/local/bin/gpg

Should work fine.

We don’t have to use /usr/local/bin/. We can create our own directory for this and modify $PATH to check it first.

1 Like