From 020c5449036c461ea1829e854da43429322059d6 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Sun, 24 Apr 2016 06:32:15 -0400 Subject: testing --- test/environment/csh.exp | 43 ++++++++++++++++++++++ test/environment/dash.exp | 41 +++++++++++++++++++++ test/environment/env.exp | 58 ++++++++++++++++++++++++++++++ test/environment/env.profile | 2 ++ test/environment/environment.sh | 47 ++++++++++++++++++++++++ test/environment/firejail-in-firejail.exp | 24 +++++++++++++ test/environment/firejail-in-firejail2.exp | 24 +++++++++++++ test/environment/rlimit-profile.exp | 36 +++++++++++++++++++ test/environment/rlimit.exp | 36 +++++++++++++++++++ test/environment/rlimit.profile | 4 +++ test/environment/shell-none.exp | 48 +++++++++++++++++++++++++ test/environment/shell-none.profile | 1 + test/environment/zsh.exp | 43 ++++++++++++++++++++++ 13 files changed, 407 insertions(+) create mode 100755 test/environment/csh.exp create mode 100755 test/environment/dash.exp create mode 100755 test/environment/env.exp create mode 100644 test/environment/env.profile create mode 100755 test/environment/environment.sh create mode 100755 test/environment/firejail-in-firejail.exp create mode 100755 test/environment/firejail-in-firejail2.exp create mode 100755 test/environment/rlimit-profile.exp create mode 100755 test/environment/rlimit.exp create mode 100644 test/environment/rlimit.profile create mode 100755 test/environment/shell-none.exp create mode 100644 test/environment/shell-none.profile create mode 100755 test/environment/zsh.exp (limited to 'test/environment') diff --git a/test/environment/csh.exp b/test/environment/csh.exp new file mode 100755 index 000000000..10ad3607e --- /dev/null +++ b/test/environment/csh.exp @@ -0,0 +1,43 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --private --tracelog --csh\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "ls -al;pwd\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + ".cshrc" +} +expect { + timeout {puts "TESTING ERROR 1.1\n";exit} + "home" +} +send -- "env | grep SHELL;pwd\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "SHELL" +} +expect { + timeout {puts "TESTING ERROR 2.1\n";exit} + "/bin/csh" +} +expect { + timeout {puts "TESTING ERROR 2.2\n";exit} + "home" +} +send -- "exit\r" +sleep 1 + +puts "\n" + diff --git a/test/environment/dash.exp b/test/environment/dash.exp new file mode 100755 index 000000000..f5a60719e --- /dev/null +++ b/test/environment/dash.exp @@ -0,0 +1,41 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --private --tracelog --shell=/bin/dash\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 1 + +#send -- "ls -al;pwd\r" +#expect { +# timeout {puts "TESTING ERROR 1\n";exit} +# ".zshrc" +#} +#expect { +# timeout {puts "TESTING ERROR 1.1\n";exit} +# "home" +#} + +send -- "env | grep SHELL;pwd\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "SHELL" +} +expect { + timeout {puts "TESTING ERROR 2.1\n";exit} + "/bin/dash" +} +expect { + timeout {puts "TESTING ERROR 2.2\n";exit} + "home" +} +send -- "exit\r" +sleep 1 + +puts "\n" + diff --git a/test/environment/env.exp b/test/environment/env.exp new file mode 100755 index 000000000..a09c3f9c5 --- /dev/null +++ b/test/environment/env.exp @@ -0,0 +1,58 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +#*********************************************** +send -- "firejail --env=ENV1=env1 --env=ENV2=env2 --env=ENV3=env3\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "env | grep ENV1\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "ENV1" +} +send -- "env | grep ENV2\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "ENV2" +} +send -- "env | grep ENV3\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "ENV3" +} +send -- "exit\r" +sleep 1 + +#*********************************************** +send -- "firejail --profile=env.profile\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "Child process initialized" +} +sleep 1 +send -- "env | grep LD_LIBRARY_PATH\r" +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "/opt/test/lib" +} +send -- "env | grep CFLAGS\r" +expect { + timeout {puts "TESTING ERROR 6\n";exit} + "Wall" +} +expect { + timeout {puts "TESTING ERROR 7\n";exit} + "Werror" +} + +puts "\nall done\n" diff --git a/test/environment/env.profile b/test/environment/env.profile new file mode 100644 index 000000000..ba66e6210 --- /dev/null +++ b/test/environment/env.profile @@ -0,0 +1,2 @@ +env LD_LIBRARY_PATH=/opt/test/lib +env CFLAGS="-W -Wall -Werror" diff --git a/test/environment/environment.sh b/test/environment/environment.sh new file mode 100755 index 000000000..3041fcc12 --- /dev/null +++ b/test/environment/environment.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +export MALLOC_CHECK_=3 +export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) + +echo "TESTING: environment variables (test/environment/env.exp)" +./env.exp + +echo "TESTING: shell none(test/environment/shell-none.exp)" +./shell-none.exp + +which dash +if [ "$?" -eq 0 ]; +then + echo "TESTING: dash (test/environment/dash.exp)" + ./dash.exp +else + echo "TESTING: dash not found" +fi + +which csh +if [ "$?" -eq 0 ]; +then + echo "TESTING: csh (test/environment/csh.exp)" + ./csh.exp +else + echo "TESTING: csh not found" +fi + +which zsh +if [ "$?" -eq 0 ]; +then + echo "TESTING: zsh (test/environment/zsh.exp)" + ./csh.exp +else + echo "TESTING: zsh not found" +fi + +echo "TESTING: rlimit (test/environment/rlimit.exp)" +./rlimit.exp + +echo "TESTING: rlimit profile (test/environment/rlimit-profile.exp)" +./rlimit-profile.exp + diff --git a/test/environment/firejail-in-firejail.exp b/test/environment/firejail-in-firejail.exp new file mode 100755 index 000000000..7e7f4fd17 --- /dev/null +++ b/test/environment/firejail-in-firejail.exp @@ -0,0 +1,24 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "firejail\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Warning: an existing sandbox was detected" +} +sleep 1 + +puts "\nall done\n" diff --git a/test/environment/firejail-in-firejail2.exp b/test/environment/firejail-in-firejail2.exp new file mode 100755 index 000000000..5a2213074 --- /dev/null +++ b/test/environment/firejail-in-firejail2.exp @@ -0,0 +1,24 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --noprofile\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "firejail --force\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +sleep 1 + +puts "\nall done\n" diff --git a/test/environment/rlimit-profile.exp b/test/environment/rlimit-profile.exp new file mode 100755 index 000000000..7d2637444 --- /dev/null +++ b/test/environment/rlimit-profile.exp @@ -0,0 +1,36 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --profile=rlimit.profile\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "cat /proc/self/limits; pwd\r" +expect { + timeout {puts "TESTING ERROR 1.1\n";exit} + "Max file size 1024 1024" +} +expect { + timeout {puts "TESTING ERROR 1.2\n";exit} + "Max processes 1000 1000" +} +expect { + timeout {puts "TESTING ERROR 1.3\n";exit} + "Max open files 500 500" +} +expect { + timeout {puts "TESTING ERROR 1.4\n";exit} + "Max pending signals 200 200" +} +expect { + timeout {puts "TESTING ERROR 1.5\n";exit} + "home" +} +sleep 1 +puts "\n" diff --git a/test/environment/rlimit.exp b/test/environment/rlimit.exp new file mode 100755 index 000000000..17d2bd9d1 --- /dev/null +++ b/test/environment/rlimit.exp @@ -0,0 +1,36 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --rlimit-fsize=1024 --rlimit-nproc=1000 --rlimit-nofile=500 --rlimit-sigpending=200\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "cat /proc/self/limits; pwd\r" +expect { + timeout {puts "TESTING ERROR 1.1\n";exit} + "Max file size 1024 1024" +} +expect { + timeout {puts "TESTING ERROR 1.2\n";exit} + "Max processes 1000 1000" +} +expect { + timeout {puts "TESTING ERROR 1.3\n";exit} + "Max open files 500 500" +} +expect { + timeout {puts "TESTING ERROR 1.4\n";exit} + "Max pending signals 200 200" +} +expect { + timeout {puts "TESTING ERROR 1.5\n";exit} + "home" +} +sleep 1 +puts "\n" diff --git a/test/environment/rlimit.profile b/test/environment/rlimit.profile new file mode 100644 index 000000000..271891c03 --- /dev/null +++ b/test/environment/rlimit.profile @@ -0,0 +1,4 @@ + rlimit-fsize 1024 +rlimit-nproc 1000 + rlimit-nofile 500 +rlimit-sigpending 200 \ No newline at end of file diff --git a/test/environment/shell-none.exp b/test/environment/shell-none.exp new file mode 100755 index 000000000..e30008f83 --- /dev/null +++ b/test/environment/shell-none.exp @@ -0,0 +1,48 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --shell=none\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "shell=none configured, but no program specified" +} +sleep 1 + +send -- "firejail --profile=shell-none.profile\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "shell=none configured, but no program specified" +} +sleep 1 + +send -- "firejail --shell=none ls\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "Child process initialized" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "environment.sh" +} +sleep 1 + +send -- "firejail --profile=shell-none.profile ls\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "Child process initialized" +} +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "environment.sh" +} +sleep 1 + + +puts "\nall done\n" + diff --git a/test/environment/shell-none.profile b/test/environment/shell-none.profile new file mode 100644 index 000000000..f16ebe3a0 --- /dev/null +++ b/test/environment/shell-none.profile @@ -0,0 +1 @@ +shell none diff --git a/test/environment/zsh.exp b/test/environment/zsh.exp new file mode 100755 index 000000000..2604b2be5 --- /dev/null +++ b/test/environment/zsh.exp @@ -0,0 +1,43 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --private --tracelog --zsh\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 1 + +send -- "ls -al;pwd\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + ".zshrc" +} +expect { + timeout {puts "TESTING ERROR 1.1\n";exit} + "home" +} +send -- "env | grep SHELL;pwd\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "SHELL" +} +expect { + timeout {puts "TESTING ERROR 2.1\n";exit} + "/usr/bin/zsh" +} +expect { + timeout {puts "TESTING ERROR 2.2\n";exit} + "home" +} +send -- "exit\r" +sleep 1 + +puts "\n" + -- cgit v1.2.3-54-g00ecf