diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-08-16 22:42:53 -0400 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2022-09-02 13:40:05 +0530 |
commit | 4d510f0fe11bcebaf22edd1c9f7221a280699a0f (patch) | |
tree | cb1c09900da45d1243e791098f6b2067fe275625 | |
parent | 8144b3324c0f9ac8b84126dc9d6d06a8ed87fbed (diff) | |
download | meson-4d510f0fe11bcebaf22edd1c9f7221a280699a0f.zip meson-4d510f0fe11bcebaf22edd1c9f7221a280699a0f.tar.gz meson-4d510f0fe11bcebaf22edd1c9f7221a280699a0f.tar.bz2 |
minstall: do not trample install_mode by rpath fixer
install_mode can include the setuid bit, which has the special property
(mentioned in the set_mode logic for minstall itself) of needing to come
last, because it "will get wiped by chmod" (or at least chown).
In fact, it's not just chown that wipes setuid, but other changes as
well, such as the file contents. This is not an issue for install_data /
custom_target, but for compiled outputs, we run depfixer to handle
rpaths. This may or may not cause edits to the binary, depending on
whether we have a build rpath to wipe, or an install rpath to add. (We
also may run `strip`, but that external program already has its own mode
restoration logic.)
Fix this by switching the order of operations around, so that setting
the permissions happens last.
Fixes https://github.com/void-linux/void-packages/issues/38682
-rw-r--r-- | mesonbuild/minstall.py | 3 | ||||
-rw-r--r-- | test cases/common/190 install_mode/meson.build | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index 551f909..a810ccb 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -693,7 +693,6 @@ class Installer: raise MesonException(f'File {fname!r} could not be found') elif os.path.isfile(fname): file_copied = self.do_copyfile(fname, outname, makedirs=(dm, outdir)) - self.set_mode(outname, install_mode, d.install_umask) if should_strip and d.strip_bin is not None: if fname.endswith('.jar'): self.log('Not stripping jar target: {}'.format(os.path.basename(fname))) @@ -723,6 +722,8 @@ class Installer: pass else: raise + # file mode needs to be set last, after strip/depfixer editing + self.set_mode(outname, install_mode, d.install_umask) def rebuild_all(wd: str) -> bool: if not (Path(wd) / 'build.ninja').is_file(): diff --git a/test cases/common/190 install_mode/meson.build b/test cases/common/190 install_mode/meson.build index cae1e91..e877ba7 100644 --- a/test cases/common/190 install_mode/meson.build +++ b/test cases/common/190 install_mode/meson.build @@ -51,6 +51,7 @@ install_man('foo.1', executable('trivialprog', sources : 'trivial.c', install : true, + build_rpath: meson.current_build_dir(), install_mode : ['rwxr-sr-x', 'root', 'root']) # test install_mode in static_library |