From d9c687a056e9a6f1a43e1689775b9d8b44736080 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 31 Jan 2013 15:30:21 +0100 Subject: [PATCH] Bug 50145 - make netgroup support optional https://bugs.freedesktop.org/show_bug.cgi?id=50145 netgroups are not defined in POSIX and are not be available on all systems. We check for getnetgrent and innetgr in configure script before using those. While here also replace AM_CONFIG_HEADER with AC_CONFIG_HEADER so it works with automake-1.13. Signed-off-by: Natanael Copa --- configure.ac | 4 ++-- src/polkitbackend/polkitbackendinteractiveauthority.c | 4 ++++ src/polkitbackend/polkitbackendjsauthority.c | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 40f0cd7..1c2abce 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.59c) AC_INIT(polkit, 0.111 http://lists.freedesktop.org/mailman/listinfo/polkit-devel) AM_INIT_AUTOMAKE(polkit, 0.111) -AM_CONFIG_HEADER(config.h) +AC_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -143,7 +143,7 @@ AC_CHECK_LIB(expat,XML_ParserCreate,[EXPAT_LIBS="-lexpat"], [AC_MSG_ERROR([Can't find expat library. Please install expat.])]) AC_SUBST(EXPAT_LIBS) -AC_CHECK_FUNCS(clearenv) +AC_CHECK_FUNCS(clearenv getnetgrent innetgr) if test "x$GCC" = "xyes"; then LDFLAGS="-Wl,--as-needed $LDFLAGS" diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c index 3bd2f0b..502f21a 100644 --- a/src/polkitbackend/polkitbackendinteractiveauthority.c +++ b/src/polkitbackend/polkitbackendinteractiveauthority.c @@ -2103,6 +2103,7 @@ get_users_in_group (PolkitIdentity *group, return ret; } +#if defined(HAVE_GETNETGRENT) static GList * get_users_in_net_group (PolkitIdentity *group, gboolean include_root) @@ -2154,6 +2155,7 @@ get_users_in_net_group (PolkitIdentity *group, endnetgrent (); return ret; } +#endif /* ---------------------------------------------------------------------------------------------------- */ @@ -2243,10 +2245,12 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent, { user_identities = g_list_concat (user_identities, get_users_in_group (identity, FALSE)); } +#if defined(HAVE_GETNETGRENT) else if (POLKIT_IS_UNIX_NETGROUP (identity)) { user_identities = g_list_concat (user_identities, get_users_in_net_group (identity, FALSE)); } +#endif else { g_warning ("Unsupported identity"); diff --git a/src/polkitbackend/polkitbackendjsauthority.c b/src/polkitbackend/polkitbackendjsauthority.c index 28361c3..b22a516 100644 --- a/src/polkitbackend/polkitbackendjsauthority.c +++ b/src/polkitbackend/polkitbackendjsauthority.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "polkitbackendjsauthority.h" @@ -1559,13 +1560,16 @@ js_polkit_user_is_in_netgroup (JSContext *cx, JSBool ret = JS_FALSE; JSString *user_str; JSString *netgroup_str; - char *user; - char *netgroup; JSBool is_in_netgroup = JS_FALSE; if (!dJS_ConvertArguments (cx, argc, JS_ARGV (cx, vp), "SS", &user_str, &netgroup_str)) goto out; +#if defined(HAVE_INNETGR) + { + char *user; + char *netgroup; + user = dJS_EncodeString (cx, user_str); netgroup = dJS_EncodeString (cx, netgroup_str); @@ -1579,6 +1583,8 @@ js_polkit_user_is_in_netgroup (JSContext *cx, dJS_free (cx, netgroup); dJS_free (cx, user); + } +#endif ret = JS_TRUE; -- 1.8.1.2