-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab73b2a
commit fb5e863
Showing
5 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ pkgs }: | ||
|
||
pkgs.stdenv.mkDerivation { | ||
name = "sudo"; | ||
src = ./sudo.py; | ||
|
||
unpackPhase = '' | ||
runHook preUnpack | ||
cp $src $PWD | ||
runHook postUnpack | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out/bin | ||
echo "#!/usr/bin/env python-suid" > $out/bin/sudo | ||
cat ${./sudo.py} >> $out/bin/sudo | ||
chmod +x $out/bin/sudo | ||
runHook postInstall | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
import shutil | ||
import sys | ||
|
||
|
||
def error(message): | ||
print(message, file=sys.stderr) | ||
sys.exit(1) | ||
|
||
|
||
def main(): | ||
program = os.path.basename(sys.argv[0]) | ||
|
||
if not os.path.exists("/run/dojo/var/root/priviliged"): | ||
error(f"{program}: workspace is not privileged") | ||
|
||
os.setuid(os.geteuid()) | ||
|
||
if len(sys.argv) < 2: | ||
error(f"Usage: {program} <command> [args...]") | ||
|
||
command = sys.argv[1] | ||
command_path = shutil.which(sys.argv[1]) | ||
if not command_path: | ||
error(f"{program}: {command}: command not found") | ||
argv = sys.argv[1:] | ||
|
||
try: | ||
os.execve(command_path, argv, os.environ) | ||
except: | ||
os.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters