From 935f82e7dd4911fde6be9dae960fd1d438542a5d Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Mon, 19 Mar 2018 18:02:02 +0100 Subject: Support 'nft -f -' to read from stdin In libnftables, detect if given filename is '-' and treat it as the common way of requesting to read from stdin, then open /dev/stdin instead. (Calling 'nft -f /dev/stdin' worked before as well, but this makes it official.) With this in place and bash's support for here strings, review all tests in tests/shell for needless use of temp files. Note that two categories of test cases were intentionally left unchanged: - Tests creating potentially large rulesets to avoid running into shell parameter length limits. - Tests for 'include' directive for obvious reasons. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- tests/shell/testcases/nft-f/0005rollback_map_0 | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'tests/shell/testcases/nft-f/0005rollback_map_0') diff --git a/tests/shell/testcases/nft-f/0005rollback_map_0 b/tests/shell/testcases/nft-f/0005rollback_map_0 index ba1fcc59..90108e72 100755 --- a/tests/shell/testcases/nft-f/0005rollback_map_0 +++ b/tests/shell/testcases/nft-f/0005rollback_map_0 @@ -3,14 +3,6 @@ # test a kernel rollback operation # fail reason: invalid map -tmpfile=$(mktemp) -if [ ! -w $tmpfile ] ; then - echo "Failed to create tmp file" >&2 - exit 0 -fi - -trap "rm -rf $tmpfile" EXIT # cleanup if aborted - GOOD_RULESET="table ip t { set t { type ipv4_addr @@ -38,15 +30,13 @@ table ip t2 { } }" -echo "$GOOD_RULESET" > $tmpfile -$NFT -f $tmpfile +$NFT -f - <<< $GOOD_RULESET if [ $? -ne 0 ] ; then echo "E: unable to load good ruleset" >&2 exit 1 fi -echo "$BAD_RULESET" > $tmpfile -$NFT -f $tmpfile 2>/dev/null +$NFT -f - <<< $BAD_RULESET 2>/dev/null if [ $? -eq 0 ] ; then echo "E: bogus ruleset loaded?" >&2 exit 1 -- cgit v1.2.3