cros_sdk: check for nosuid mount before entering

Sometimes people mount their fs where they check out CrOS to with nosuid
enabled.  This breaks us, so add an explicit check.  The single statvfs
call should not be large overhead.

BUG=None
TEST=`cros_sdk` works when mounted with suid
TEST=`cros_sdk` fails when mounted with nosuid

Change-Id: Iac8ab68d026891d7b4c1da479e3da232ff356936
Reviewed-on: https://chromium-review.googlesource.com/58501
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index c951cf5..1192ebd 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -166,6 +166,11 @@
 def EnterChroot(chroot_path, cache_dir, chrome_root, chrome_root_mount,
                 additional_args):
   """Enters an existing SDK chroot"""
+  st = os.statvfs(os.path.join(chroot_path, 'usr', 'bin', 'sudo'))
+  # The os.ST_NOSUID constant wasn't added until python-3.2.
+  if st.f_flag & 0x2:
+    cros_build_lib.Die('chroot cannot be in a nosuid mount')
+
   cmd = ENTER_CHROOT + ['--chroot', chroot_path, '--cache_dir', cache_dir]
   if chrome_root:
     cmd.extend(['--chrome_root', chrome_root])