]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
tests: iptables-test: Print errors to stderr
authorPhil Sutter <phil@nwl.cc>
Thu, 12 Aug 2021 17:14:13 +0000 (19:14 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 13 Sep 2021 15:00:51 +0000 (17:00 +0200)
No big deal, just pass the extra parameter to the four error print
calls.

Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables-test.py

index 01966f916957bd0d0d299cfb1442528dc9903f24..1790da3d0b0748e7d8a44f39be1718969b053457 100755 (executable)
@@ -47,7 +47,7 @@ def print_error(reason, filename=None, lineno=None):
     Prints an error with nice colors, indicating file and line number.
     '''
     print(filename + ": " + Colors.RED + "ERROR" +
-        Colors.ENDC + ": line %d (%s)" % (lineno, reason))
+        Colors.ENDC + ": line %d (%s)" % (lineno, reason), file=sys.stderr)
 
 
 def delete_rule(iptables, rule, filename, lineno):
@@ -368,11 +368,12 @@ def main():
         EXECUTEABLE = "xtables-nft-multi"
 
     if os.getuid() != 0:
-        print("You need to be root to run this, sorry")
+        print("You need to be root to run this, sorry", file=sys.stderr)
         return
 
     if not args.netns and not args.no_netns and not spawn_netns():
-        print("Cannot run in own namespace, connectivity might break")
+        print("Cannot run in own namespace, connectivity might break",
+              file=sys.stderr)
 
     if not args.host:
         os.putenv("XTABLES_LIBDIR", os.path.abspath(EXTENSIONS_PATH))
@@ -388,7 +389,7 @@ def main():
     try:
         log_file = open(LOGFILE, 'w')
     except IOError:
-        print("Couldn't open log file %s" % LOGFILE)
+        print("Couldn't open log file %s" % LOGFILE, file=sys.stderr)
         return
 
     if args.filename: