Skip to content

Commit

Permalink
Only match FIFOs by name, not everything
Browse files Browse the repository at this point in the history
Before this change we over-estimated IPC connectivity on Linux (at least) by
blindly assuming that everything named the same with opposing access was an IPC
channel.

With this change in place we only do that for FIFOs, which is how the comments
in the code say things should work.
  • Loading branch information
walles committed Mar 20, 2016
1 parent b8b1ef0 commit 5b3d347
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions px/px_ipc_map.py
Expand Up @@ -59,7 +59,7 @@ def _create_indices(self):
self._plain_name_to_pids = {}
self._name_to_files = {}
self._device_number_to_files = {}
self._name_and_access_to_pids = {}
self._fifo_name_and_access_to_pids = {}
for file in self.files:
if file.device is not None:
add_arraymapping(self._device_to_pids, file.device, file.pid)
Expand All @@ -71,8 +71,9 @@ def _create_indices(self):
if file.device_number is not None:
add_arraymapping(self._device_number_to_files, file.device_number, file)

if file.access is not None:
add_arraymapping(self._name_and_access_to_pids, file.name + file.access, file.pid)
if file.access is not None and file.type == 'FIFO':
add_arraymapping(self._fifo_name_and_access_to_pids,
file.name + file.access, file.pid)

def _get_other_end_pids(self, file):
"""Locate the other end of a pipe / domain socket"""
Expand Down Expand Up @@ -108,12 +109,12 @@ def _get_other_end_pids(self, file):
if candidate.name == file.name:
pids.add(candidate.pid)

if file.access:
if file.access and file.type == 'FIFO':
# On Linux, this is how we identify named FIFOs
opposing_access = {'r': 'w', 'w': 'r'}.get(file.access)
if opposing_access:
name_and_opposing_access = file.name + opposing_access
matching_pids = self._name_and_access_to_pids.get(name_and_opposing_access)
matching_pids = self._fifo_name_and_access_to_pids.get(name_and_opposing_access)
if matching_pids:
pids.update(matching_pids)

Expand Down

0 comments on commit 5b3d347

Please sign in to comment.