Skip to content

Commit

Permalink
iptables: Avoid stderr trashing when invoked as non-root
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Sep 11, 2017
1 parent 0bdc11d commit c8c61f7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions completions/iptables
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _iptables()

case $prev in
-*[AIDRPFXLZ])
COMPREPLY=( $( compgen -W '`iptables $table -nL | \
COMPREPLY=( $( compgen -W '`iptables $table -nL 2>/dev/null | \
command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur" ) )
;;
-*t)
Expand All @@ -26,17 +26,17 @@ _iptables()
-j)
if [[ "$table" == "-t filter" || -z "$table" ]]; then
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT
`iptables $table -nL | command sed -ne "$chain" \
`iptables $table -nL 2>/dev/null | command sed -ne "$chain" \
-e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
"$cur" ) )
elif [[ $table == "-t nat" ]]; then
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT MIRROR SNAT
DNAT MASQUERADE `iptables $table -nL | \
DNAT MASQUERADE `iptables $table -nL 2>/dev/null | \
command sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \
-- "$cur" ) )
elif [[ $table == "-t mangle" ]]; then
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT MARK TOS
`iptables $table -nL | command sed -ne "$chain" \
`iptables $table -nL 2>/dev/null | command sed -ne "$chain" \
-e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
"$cur" ) )
fi
Expand Down

0 comments on commit c8c61f7

Please sign in to comment.