fwgdb: Add --no-ns-pid check
PID namespacing broke fwgdb's ability to transparently hijack the CPU
UART. This patch adds a check to detect PID namespaces and teach users
how to get rid of them. (Also fixes a tiny style issue.)
BUG=chromium:444931
TEST=Ran on Jerry both with and without --no-ns-pid.
Change-Id: I666c56f6a4edfd218460285a9f2b0836dc9e6f07
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/249839
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/fwgdb.py b/scripts/fwgdb.py
index 6216701..f7fc210 100644
--- a/scripts/fwgdb.py
+++ b/scripts/fwgdb.py
@@ -17,6 +17,7 @@
from chromite.cbuildbot import constants
from chromite.lib import commandline
from chromite.lib import cros_build_lib
+from chromite.lib import osutils
from chromite.lib import timeout_util
# pylint: disable=W0622
@@ -46,6 +47,9 @@
def __init__(self, tty):
self._tty = tty
self._processes = None
+ if 'cros_sdk' in osutils.ReadFile('/proc/1/cmdline'):
+ raise OSError('You must run this tool in a chroot that was entered with '
+ '"cros_sdk --no-ns-pid" (see crbug.com/444931 for details)')
def __enter__(self):
lsof = cros_build_lib.RunCommand(
@@ -70,7 +74,7 @@
try:
os.kill(int(p), signal.SIGCONT)
except OSError as e:
- Error("Error when trying to unfreeze process %s: %s" % (p, str(e)))
+ Error('Error when trying to unfreeze process %s: %s' % (p, str(e)))
def ParsePortage(board):