Skip to content

Instantly share code, notes, and snippets.

@pothos
pothos / systemd-sudo.sh
Created January 26, 2022 12:31
systemd-sudo.sh: a non-setuid sudo-alike using systemd-run
#!/bin/bash
set -euo pipefail
MYNAME=$(basename "${0}")
opts=$(getopt --name "$MYNAME" --options 'hVsEnu:g:D:' \
--longoptions 'help,version,shell,preserve-env,non-interactive,user:,group:,chdir:' -- "${@}")
eval set -- "${opts}"
U=0