1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

Fix stdin issues with missing config filename ifquery for disable_cli_interfacesfile

Ticket: CM-7066
Reviewed By: roopa
Testing Done: unit tested and wrote new testcase in testifupdown2

Use case for ifquery where stdin used with -i breaks
because interfacesfileiobuf was not checked in addition to interfacesfilename.

Testcase like:

echo '[{"name": "swp1","auto": true,"config": {"address": "10.10.10.10/24"}}]' | ifquery -i - -t json swp1

would fail because while -i was given with stdin, the check for missing filename would produce an error.

It was also decided by consensus that the ifquery command does not need to have a check for
disable_cli_interfacesfile since a query "should" not pose a security check.

(I've also added some test cases for this in cl-tests).

(cherry picked from commit 4d37e932b43da87a9240a866be2d8b9508a9c7eb)
This commit is contained in:
Sam Tannous
2015-10-09 18:00:49 -04:00
committed by Roopa Prabhu
parent 67cfaeb1cf
commit c28fc55eb9
2 changed files with 6 additions and 3 deletions

View File

@@ -434,8 +434,9 @@ class networkInterfaces():
Assumes networkinterfaces parser object is initialized with the
parser arguments
"""
if self.interfacesfile == None:
self.logger.warn('no network interfaces file defined in ifupdown2.conf')
if not self.interfacesfile and not self.interfacesfileiobuf:
self.logger.warn('no terminal line stdin used or ')
self.logger.warn('no network interfaces file defined.')
return
if self.interfacesfileformat == 'json':