Skip to content

Commit e37d8ed

Browse files
nyhwkozaczuk
authored andcommitted
imgedit.py: do not open a port to the entire world
Since commit 464f4e0, imgedit.py opens runs qemu-nbd on a random port, but qemu-nbd needlessly listens to all interfaces - including potentially to connections from the outside world. While the practical risk is minimal (imgedit.py runs for very short duration), there is no need to take it at all - qemu-nbd should only listen to the 127.0.0.1 interface (see issue #709). And in turn, imgedit.py should contact 127.0.0.1 and not rely on the alias "localhost" working for ipv4 (see issue #534). Signed-off-by: Nadav Har'El <[email protected]> Message-Id: <[email protected]>
1 parent 5deec8f commit e37d8ed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/imgedit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ def __init__(self, filename):
5959
self._buf = None
6060
self._closed = True
6161
nbd_port = randint(10809, 20809)
62-
self._process = subprocess.Popen(["qemu-nbd", "-p", str(nbd_port)] + fileformat + [filename], shell=False, stdout=_devnull)
62+
self._process = subprocess.Popen(["qemu-nbd", "-b", "127.0.0.1", "-p", str(nbd_port)] + fileformat + [filename], shell=False, stdout=_devnull)
6363
# wait for qemu-nbd to start: this thing doesn't tell anything on stdout
6464
while True:
6565
try:
66-
self._client = nbd_client("localhost", nbd_port)
66+
self._client = nbd_client("127.0.0.1", nbd_port)
6767
break
6868
except:
6969
if self._process.poll() != None:

0 commit comments

Comments
 (0)