minstall: do not drop privileges if msetup also ran under sudo

A user might run `sudo somewrapper` to build and install something with
meson, and it is not actually possible to drop privileges and build,
since the build directory is also owned by root.

A common case of this is `sudo pip install` for projects using
meson-python or other python build-backends that wrap around meson.

Fixes #11665
pull/11667/head
Eli Schwartz 2 years ago
parent 1bc3d91112
commit 9a77c45e41
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 4
      mesonbuild/minstall.py

@ -788,6 +788,10 @@ def rebuild_all(wd: str, backend: str) -> bool:
else:
return None, None
if os.stat(os.path.join(wd, 'build.ninja')).st_uid != int(orig_uid):
# the entire build process is running with sudo, we can't drop privileges
return None, None
env['USER'] = orig_user
env['HOME'] = homedir

Loading…
Cancel
Save