From 99a9f8d680ea5a613506d5f0a1804bf97a5d69f3 Mon Sep 17 00:00:00 2001 From: Austin Morton Date: Mon, 20 May 2019 19:44:40 -0400 Subject: Add private-cwd option to control working directory within jail --- test/fs/fs.sh | 3 +++ test/fs/private-cwd.exp | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 test/fs/private-cwd.exp (limited to 'test') diff --git a/test/fs/fs.sh b/test/fs/fs.sh index 0fc216b20..7e1d46f0a 100755 --- a/test/fs/fs.sh +++ b/test/fs/fs.sh @@ -69,6 +69,9 @@ echo "TESTING: empty private-etc (test/fs/private-etc-empty.exp)" echo "TESTING: private-bin (test/fs/private-bin.exp)" ./private-bin.exp +echo "TESTING: private-cwd (test/fs/private-cwd.exp)" +./private-cwd.exp + echo "TESTING: macros (test/fs/macro.exp)" ./macro.exp diff --git a/test/fs/private-cwd.exp b/test/fs/private-cwd.exp new file mode 100755 index 000000000..0fa87a92f --- /dev/null +++ b/test/fs/private-cwd.exp @@ -0,0 +1,52 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2019 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "cd /tmp\r" +after 100 + +# testing profile and private +send -- "firejail --private-cwd\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "pwd\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "$env(HOME)" +} +after 100 + +send -- "exit\r" +sleep 1 + +send -- "cd /\r" +after 100 + +# testing profile and private +send -- "firejail --private-cwd=/tmp\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "pwd\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "/tmp" +} +after 100 + +send -- "exit\r" +sleep 1 + +puts "all done\n" -- cgit v1.2.3-54-g00ecf