diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2022-05-15 05:04:10 +0000 |
---|---|---|
committer | Jan Rybar <jrybar@redhat.com> | 2022-07-14 12:50:49 +0000 |
commit | b57deee8178190a7ecc75290fa13cf7daabc2c66 (patch) | |
tree | 83e43baf32a418b74492b123b4e437641fcdd31f /src/polkit | |
parent | 827b0ddac5b1ef00a47fca4526fcf057bee5f1db (diff) | |
download | polkit-b57deee8178190a7ecc75290fa13cf7daabc2c66.tar.gz |
Make netgroup support optional
On at least Linux/musl and Linux/uclibc, netgroup support is not
available. PolKit fails to compile on these systems for that reason.
This change makes netgroup support conditional on the presence of the
setnetgrent(3) function which is required for the support to work. If
that function is not available on the system, an error will be returned
to the administrator if unix-netgroup: is specified in configuration.
(sam: rebased for Meson and Duktape.)
Closes: https://gitlab.freedesktop.org/polkit/polkit/-/issues/14
Closes: https://gitlab.freedesktop.org/polkit/polkit/-/issues/163
Closes: https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/52
Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
Diffstat (limited to 'src/polkit')
-rw-r--r-- | src/polkit/polkitidentity.c | 17 | ||||
-rw-r--r-- | src/polkit/polkitunixnetgroup.c | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/polkit/polkitidentity.c b/src/polkit/polkitidentity.c index 3aa1f7f..793f17d 100644 --- a/src/polkit/polkitidentity.c +++ b/src/polkit/polkitidentity.c @@ -182,7 +182,15 @@ polkit_identity_from_string (const gchar *str, } else if (g_str_has_prefix (str, "unix-netgroup:")) { +#ifndef HAVE_SETNETGRENT + g_set_error (error, + POLKIT_ERROR, + POLKIT_ERROR_FAILED, + "Netgroups are not available on this machine ('%s')", + str); +#else identity = polkit_unix_netgroup_new (str + sizeof "unix-netgroup:" - 1); +#endif } if (identity == NULL && (error != NULL && *error == NULL)) @@ -344,6 +352,14 @@ polkit_identity_new_for_gvariant (GVariant *variant, GVariant *v; const char *name; +#ifndef HAVE_SETNETGRENT + g_set_error (error, + POLKIT_ERROR, + POLKIT_ERROR_FAILED, + "Netgroups are not available on this machine"); + goto out; +#else + v = lookup_asv (details_gvariant, "name", G_VARIANT_TYPE_STRING, error); if (v == NULL) { @@ -353,6 +369,7 @@ polkit_identity_new_for_gvariant (GVariant *variant, name = g_variant_get_string (v, NULL); ret = polkit_unix_netgroup_new (name); g_variant_unref (v); +#endif } else { diff --git a/src/polkit/polkitunixnetgroup.c b/src/polkit/polkitunixnetgroup.c index 8a2b369..83f8d4a 100644 --- a/src/polkit/polkitunixnetgroup.c +++ b/src/polkit/polkitunixnetgroup.c @@ -194,6 +194,9 @@ polkit_unix_netgroup_set_name (PolkitUnixNetgroup *group, PolkitIdentity * polkit_unix_netgroup_new (const gchar *name) { +#ifndef HAVE_SETNETGRENT + g_assert_not_reached(); +#endif g_return_val_if_fail (name != NULL, NULL); return POLKIT_IDENTITY (g_object_new (POLKIT_TYPE_UNIX_NETGROUP, "name", name, |