From 0c47e3585f3e4a2f365ad83c81f9095712fc34f3 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Wed, 1 Jun 2016 11:40:24 -0400 Subject: fixed globbing dot files --- src/firejail/fs.c | 2 +- test/fs/fs.sh | 3 +++ test/fs/option_blacklist_glob.exp | 32 ++++++++++++++++++++++++++++++++ test/fs/testdir1/.directory/file | 0 test/fs/testdir1/.file | 0 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100755 test/fs/option_blacklist_glob.exp create mode 100644 test/fs/testdir1/.directory/file create mode 100644 test/fs/testdir1/.file diff --git a/src/firejail/fs.c b/src/firejail/fs.c index cfb724696..c38a9a32e 100644 --- a/src/firejail/fs.c +++ b/src/firejail/fs.c @@ -361,7 +361,7 @@ static void globbing(OPERATION op, const char *pattern, const char *noblacklist[ glob_t globbuf; // Profiles contain blacklists for files that might not exist on a user's machine. // GLOB_NOCHECK makes that okay. - int globerr = glob(pattern, GLOB_NOCHECK | GLOB_NOSORT, NULL, &globbuf); + int globerr = glob(pattern, GLOB_NOCHECK | GLOB_NOSORT | GLOB_PERIOD, NULL, &globbuf); if (globerr) { fprintf(stderr, "Error: failed to glob pattern %s\n", pattern); exit(1); diff --git a/test/fs/fs.sh b/test/fs/fs.sh index b49aadf02..08888020c 100755 --- a/test/fs/fs.sh +++ b/test/fs/fs.sh @@ -45,6 +45,9 @@ echo "TESTING: blacklist directory (test/fs/option_blacklist.exp)" echo "TESTING: blacklist file (test/fs/option_blacklist_file.exp)" ./option_blacklist_file.exp +echo "TESTING: blacklist glob (test/fs/option_blacklist_glob.exp)" +./option_blacklist_glob.exp + echo "TESTING: bind as user (test/fs/option_bind_user.exp)" ./option_bind_user.exp diff --git a/test/fs/option_blacklist_glob.exp b/test/fs/option_blacklist_glob.exp new file mode 100755 index 000000000..01939736d --- /dev/null +++ b/test/fs/option_blacklist_glob.exp @@ -0,0 +1,32 @@ +#!/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 --blacklist=testdir1/*\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 1 +send -- "cd testdir1\r" +sleep 1 + +send -- "cat .file\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Permission denied" +} + +send -- "ls .directory\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "Permission denied" +} + +puts "\n" + diff --git a/test/fs/testdir1/.directory/file b/test/fs/testdir1/.directory/file new file mode 100644 index 000000000..e69de29bb diff --git a/test/fs/testdir1/.file b/test/fs/testdir1/.file new file mode 100644 index 000000000..e69de29bb -- cgit v1.2.3-54-g00ecf