diff options
author | Thomas Haller <thaller@redhat.com> | 2021-02-12 10:17:41 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-02-12 11:34:24 +0100 |
commit | 801c41a11c2cd37dc1271c026edc0a3292cc69b8 (patch) | |
tree | 5d19243026b53d77c834da407d78a927ad491139 | |
parent | 2e334f54b27f91f40c3aa8bdba3254e2284d30bd (diff) | |
download | NetworkManager-801c41a11c2cd37dc1271c026edc0a3292cc69b8.tar.gz |
build: make path to polkit-agent-helper-1 binary configurable
Add new configure option to set the path to "polkit-agent-helper-1".
The path cannot be obtained from pkg-config and `pkg-config
--variable=prefix polkit-agent-1` is not good enough.
On Fedora, the path is "/usr/lib/polkit-1/polkit-agent-helper-1".
On Debian Buster, the path is "/usr/lib/policykit-1/polkit-agent-helper-1"
On Debian Sid, the path is "/usr/libexec/polkit-agent-helper-1" (but
currently it is also symlinked from "/usr/lib/policykit-1/polkit-agent-helper-1".
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | clients/common/nm-polkit-listener.c | 2 | ||||
-rw-r--r-- | config.h.meson | 6 | ||||
-rw-r--r-- | configure.ac | 28 | ||||
-rw-r--r-- | meson.build | 17 | ||||
-rw-r--r-- | meson_options.txt | 2 |
6 files changed, 37 insertions, 19 deletions
@@ -28,6 +28,7 @@ USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE! * initrd: support new ip method "link6" for IPv6 link-local only. * ci: use ci-templates for containers on gitlab-ci. * ci: test build against Alpine Linux on gitlab-ci. +* build: new configure option to set path to "polkit-agent-helper-1". * Many bugfixes and improvements. ============================================= diff --git a/clients/common/nm-polkit-listener.c b/clients/common/nm-polkit-listener.c index db21abfc98..357e1efb8b 100644 --- a/clients/common/nm-polkit-listener.c +++ b/clients/common/nm-polkit-listener.c @@ -501,7 +501,7 @@ begin_authentication(AuthRequest *request) { int fd_flags; const char *helper_argv[] = { - POLKIT_PACKAGE_PREFIX "/lib/polkit-1/polkit-agent-helper-1", + POLKIT_AGENT_HELPER_1_PATH, request->username, NULL, }; diff --git a/config.h.meson b/config.h.meson index bb5458aa64..a911dbe257 100644 --- a/config.h.meson +++ b/config.h.meson @@ -109,6 +109,9 @@ /* Define to the full name and version of this package. */ #mesondefine PACKAGE_STRING +/* path to polkit-agent-helper-1 binary */ +#mesondefine POLKIT_AGENT_HELPER_1_PATH + /* Path to resolvconf */ #mesondefine RESOLVCONF_PATH @@ -218,9 +221,6 @@ /* Define if you have oFono support (experimental) */ #mesondefine WITH_OFONO -/* Define the polkit agent package prefix */ -#mesondefine POLKIT_PACKAGE_PREFIX - /* Define if you have PPP support */ #mesondefine WITH_PPP diff --git a/configure.ac b/configure.ac index 63bc6831c8..2bf5e4e069 100644 --- a/configure.ac +++ b/configure.ac @@ -642,16 +642,25 @@ fi AC_DEFINE_UNQUOTED(NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT, "$enable_polkit", [The default value of the auth-polkit configuration option]) AC_SUBST(NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_TEXT, "$enable_polkit") -PKG_CHECK_MODULES(POLKIT, [polkit-agent-1 >= 0.97], [have_pk_agent=yes],[have_pk_agent=no]) -if test x"$have_pk_agent" = x"no"; then - POLKIT_PACKAGE_PREFIX="/usr" -else - POLKIT_PACKAGE_PREFIX=`$PKG_CONFIG --variable=prefix polkit-agent-1` +AC_ARG_WITH([polkit-agent-helper-1-path], + AS_HELP_STRING([--with-polkit-agent-helper-1-path=PATH], + [Path name to the polkit-agent-helper-1 binary from polkit]), + POLKIT_AGENT_HELPER_1_PATH="$withval", + POLKIT_AGENT_HELPER_1_PATH="") +if test -z "$POLKIT_AGENT_HELPER_1_PATH" ; then + for p in /usr/libexec/polkit-agent-helper-1 \ + /usr/lib/polkit-1/polkit-agent-helper-1 \ + /usr/lib/policykit-1/polkit-agent-helper-1 ; do + if test -f "$p" ; then + POLKIT_AGENT_HELPER_1_PATH="$p" + break + fi + done fi -AC_DEFINE_UNQUOTED([POLKIT_PACKAGE_PREFIX], - ["$POLKIT_PACKAGE_PREFIX"], - [polkit-agent package prefix]) - +test -z "$POLKIT_AGENT_HELPER_1_PATH" && POLKIT_AGENT_HELPER_1_PATH=/usr/lib/polkit-1/polkit-agent-helper-1 +AC_DEFINE_UNQUOTED([POLKIT_AGENT_HELPER_1_PATH], + ["$POLKIT_AGENT_HELPER_1_PATH"], + [path to polkit-agent-helper-1 binary]) AC_ARG_ENABLE(modify-system, AS_HELP_STRING([--enable-modify-system], [Allow users to modify system connections])) if test "${enable_modify_system}" = "yes"; then @@ -1332,6 +1341,7 @@ if test "${enable_modify_system}" = "yes"; then else echo " policykit: main.auth-polkit=${enable_polkit} (restrictive modify.system)" fi +echo " polkit-agent-helper-1: $POLKIT_AGENT_HELPER_1_PATH" echo " selinux: $have_selinux" echo " systemd-journald: $have_systemd_journal (default: logging.backend=${nm_config_logging_backend_default})" echo " hostname persist: ${hostname_persist}" diff --git a/meson.build b/meson.build index 0ea0592419..9d3d08c4f6 100644 --- a/meson.build +++ b/meson.build @@ -514,12 +514,18 @@ config_h.set_quoted('NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT', config_auth_polkit_def enable_modify_system = get_option('modify_system') -polkit_agent_dep = dependency('polkit-agent-1', version: '>= 0.97', required : false) -if polkit_agent_dep.found() - config_h.set_quoted('POLKIT_PACKAGE_PREFIX', polkit_agent_dep.get_pkgconfig_variable('prefix')) -else - config_h.set_quoted('POLKIT_PACKAGE_PREFIX', '/usr') +polkit_agent_helper_1_path = get_option('polkit_agent_helper_1_path') +foreach p : [ '/usr/libexec/polkit-agent-helper-1', + '/usr/lib/polkit-1/polkit-agent-helper-1', + '/usr/lib/policykit-1/polkit-agent-helper-1' ] + if polkit_agent_helper_1_path == '' and run_command('test', '-f', p).returncode() == 0 + polkit_agent_helper_1_path = p + endif +endforeach +if polkit_agent_helper_1_path == '' + polkit_agent_helper_1_path = '/usr/lib/polkit-1/polkit-agent-helper-1' endif +config_h.set_quoted('POLKIT_AGENT_HELPER_1_PATH', polkit_agent_helper_1_path) crypto = get_option('crypto') @@ -1016,6 +1022,7 @@ if enable_polkit output += ' modify.system)' endif output += '\n' +output += ' polkit-agent-helper-1: ' + polkit_agent_helper_1_path + '\n' output += ' selinux: ' + enable_selinux.to_string() + '\n' output += ' systemd-journald: ' + enable_systemd_journal.to_string() + ' (default: logging.backend=' + config_logging_backend_default + ')\n' output += ' hostname persist: ' + hostname_persist + '\n' diff --git a/meson_options.txt b/meson_options.txt index d4f62829fa..71de3206e6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -16,7 +16,7 @@ option('suspend_resume', type: 'combo', choices: ['upower', 'systemd', 'elogind' option('polkit', type: 'boolean', value: true, description: 'User auth-polkit configuration option.') option('config_auth_polkit_default', type: 'combo', choices: ['default', 'true', 'false', 'root-only'], value: 'default', description: 'Default value for configuration main.auth-polkit.') option('modify_system', type: 'boolean', value: false, description: 'Allow users to modify system connections') -option('polkit_agent', type: 'boolean', value: false, description: 'enable polkit agent for clients') +option('polkit_agent_helper_1_path', type: 'string', value: '', description: 'Path name to the polkit-agent-helper-1 binary from polkit') option('selinux', type: 'boolean', value: true, description: 'Build with SELinux') option('systemd_journal', type: 'boolean', value: true, description: 'Use systemd journal for logging') option('config_logging_backend_default', type: 'combo', choices: ['default', 'syslog', 'journal'], value: 'default', description: 'Default value for logging.backend') |