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".

(cherry picked from commit 801c41a11c)
This commit is contained in:
Thomas Haller
2021-02-12 10:17:41 +01:00
parent 4e11b182a0
commit 8f2ca652d9
6 changed files with 37 additions and 19 deletions

1
NEWS
View File

@@ -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. * initrd: support new ip method "link6" for IPv6 link-local only.
* ci: use ci-templates for containers on gitlab-ci. * ci: use ci-templates for containers on gitlab-ci.
* ci: test build against Alpine Linux 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. * Many bugfixes and improvements.
============================================= =============================================

View File

@@ -501,7 +501,7 @@ begin_authentication(AuthRequest *request)
{ {
int fd_flags; int fd_flags;
const char *helper_argv[] = { const char *helper_argv[] = {
POLKIT_PACKAGE_PREFIX "/lib/polkit-1/polkit-agent-helper-1", POLKIT_AGENT_HELPER_1_PATH,
request->username, request->username,
NULL, NULL,
}; };

View File

@@ -109,6 +109,9 @@
/* Define to the full name and version of this package. */ /* Define to the full name and version of this package. */
#mesondefine PACKAGE_STRING #mesondefine PACKAGE_STRING
/* path to polkit-agent-helper-1 binary */
#mesondefine POLKIT_AGENT_HELPER_1_PATH
/* Path to resolvconf */ /* Path to resolvconf */
#mesondefine RESOLVCONF_PATH #mesondefine RESOLVCONF_PATH
@@ -218,9 +221,6 @@
/* Define if you have oFono support (experimental) */ /* Define if you have oFono support (experimental) */
#mesondefine WITH_OFONO #mesondefine WITH_OFONO
/* Define the polkit agent package prefix */
#mesondefine POLKIT_PACKAGE_PREFIX
/* Define if you have PPP support */ /* Define if you have PPP support */
#mesondefine WITH_PPP #mesondefine WITH_PPP

View File

@@ -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_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") 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]) AC_ARG_WITH([polkit-agent-helper-1-path],
if test x"$have_pk_agent" = x"no"; then AS_HELP_STRING([--with-polkit-agent-helper-1-path=PATH],
POLKIT_PACKAGE_PREFIX="/usr" [Path name to the polkit-agent-helper-1 binary from polkit]),
else POLKIT_AGENT_HELPER_1_PATH="$withval",
POLKIT_PACKAGE_PREFIX=`$PKG_CONFIG --variable=prefix polkit-agent-1` 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 fi
AC_DEFINE_UNQUOTED([POLKIT_PACKAGE_PREFIX], test -z "$POLKIT_AGENT_HELPER_1_PATH" && POLKIT_AGENT_HELPER_1_PATH=/usr/lib/polkit-1/polkit-agent-helper-1
["$POLKIT_PACKAGE_PREFIX"], AC_DEFINE_UNQUOTED([POLKIT_AGENT_HELPER_1_PATH],
[polkit-agent package prefix]) ["$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])) AC_ARG_ENABLE(modify-system, AS_HELP_STRING([--enable-modify-system], [Allow users to modify system connections]))
if test "${enable_modify_system}" = "yes"; then if test "${enable_modify_system}" = "yes"; then
@@ -1332,6 +1341,7 @@ if test "${enable_modify_system}" = "yes"; then
else else
echo " policykit: main.auth-polkit=${enable_polkit} (restrictive modify.system)" echo " policykit: main.auth-polkit=${enable_polkit} (restrictive modify.system)"
fi fi
echo " polkit-agent-helper-1: $POLKIT_AGENT_HELPER_1_PATH"
echo " selinux: $have_selinux" echo " selinux: $have_selinux"
echo " systemd-journald: $have_systemd_journal (default: logging.backend=${nm_config_logging_backend_default})" echo " systemd-journald: $have_systemd_journal (default: logging.backend=${nm_config_logging_backend_default})"
echo " hostname persist: ${hostname_persist}" echo " hostname persist: ${hostname_persist}"

View File

@@ -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') enable_modify_system = get_option('modify_system')
polkit_agent_dep = dependency('polkit-agent-1', version: '>= 0.97', required : false) polkit_agent_helper_1_path = get_option('polkit_agent_helper_1_path')
if polkit_agent_dep.found() foreach p : [ '/usr/libexec/polkit-agent-helper-1',
config_h.set_quoted('POLKIT_PACKAGE_PREFIX', polkit_agent_dep.get_pkgconfig_variable('prefix')) '/usr/lib/polkit-1/polkit-agent-helper-1',
else '/usr/lib/policykit-1/polkit-agent-helper-1' ]
config_h.set_quoted('POLKIT_PACKAGE_PREFIX', '/usr') 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 endif
config_h.set_quoted('POLKIT_AGENT_HELPER_1_PATH', polkit_agent_helper_1_path)
crypto = get_option('crypto') crypto = get_option('crypto')
@@ -1016,6 +1022,7 @@ if enable_polkit
output += ' modify.system)' output += ' modify.system)'
endif endif
output += '\n' output += '\n'
output += ' polkit-agent-helper-1: ' + polkit_agent_helper_1_path + '\n'
output += ' selinux: ' + enable_selinux.to_string() + '\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 += ' systemd-journald: ' + enable_systemd_journal.to_string() + ' (default: logging.backend=' + config_logging_backend_default + ')\n'
output += ' hostname persist: ' + hostname_persist + '\n' output += ' hostname persist: ' + hostname_persist + '\n'

View File

@@ -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('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('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('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('selinux', type: 'boolean', value: true, description: 'Build with SELinux')
option('systemd_journal', type: 'boolean', value: true, description: 'Use systemd journal for logging') 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') option('config_logging_backend_default', type: 'combo', choices: ['default', 'syslog', 'journal'], value: 'default', description: 'Default value for logging.backend')