From 60352521d18e17ce85b944fb3e6af4c71e926773 Mon Sep 17 00:00:00 2001 From: Ryan Gonzalez Date: Thu, 17 May 2018 09:46:01 -0500 Subject: Fix #3579: Wait for a permissions failure before trying to run pkexec --- mesonbuild/scripts/meson_install.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py index b0c05cb..d3b6437 100644 --- a/mesonbuild/scripts/meson_install.py +++ b/mesonbuild/scripts/meson_install.py @@ -230,10 +230,6 @@ def do_install(log_dir, datafilename): d.destdir = os.environ.get('DESTDIR', '') d.fullprefix = destdir_join(d.destdir, d.prefix) - if not os.access(d.fullprefix, os.W_OK) and shutil.which('pkexec') is not None: - os.execlp('pkexec', 'pkexec', sys.executable, main_file, *sys.argv[1:], - os.getcwd()) - if d.install_umask is not None: os.umask(d.install_umask) @@ -242,15 +238,23 @@ def do_install(log_dir, datafilename): append_to_log('# List of files installed by Meson') append_to_log('# Does not contain files installed by custom scripts.') - d.dirmaker = DirMaker() - with d.dirmaker: - install_subdirs(d) # Must be first, because it needs to delete the old subtree. - install_targets(d) - install_headers(d) - install_man(d) - install_data(d) - restore_selinux_contexts() - run_install_script(d) + try: + d.dirmaker = DirMaker() + with d.dirmaker: + install_subdirs(d) # Must be first, because it needs to delete the old subtree. + install_targets(d) + install_headers(d) + install_man(d) + install_data(d) + restore_selinux_contexts() + run_install_script(d) + except PermissionError: + if shutil.which('pkexec') is not None and 'PKEXEC_UID' not in os.environ: + os.execlp('pkexec', 'pkexec', sys.executable, main_file, *sys.argv[1:], + os.getcwd()) + else: + raise + def install_subdirs(d): for (src_dir, dst_dir, mode, exclude) in d.install_subdirs: -- cgit v1.1