blob: 4e3af876e59fdb19dc80244a71b4f2b5f28e31ea [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001From 7d5e205aa58a10e7b1ccc2fa75b443508a5c3e18 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 20 Jan 2016 04:31:59 +0000
4Subject: [PATCH] make netgroup support configurable
5
6Disable using innetgr and *netigrent function if not available
7
8These functions are not available on all libc implementations e.g. musl
9doesnt have them.
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13Upstream-Status: Pending
14
15 configure.ac | 2 +-
16 src/polkitbackend/polkitbackendinteractiveauthority.c | 6 +++++-
17 src/polkitbackend/polkitbackendjsauthority.c | 5 ++---
18 3 files changed, 8 insertions(+), 5 deletions(-)
19
20diff --git a/configure.ac b/configure.ac
21index 07982d1..21590b2 100644
22--- a/configure.ac
23+++ b/configure.ac
24@@ -158,7 +158,7 @@ AC_CHECK_LIB(expat,XML_ParserCreate,[EXPAT_LIBS="-lexpat"],
25 [AC_MSG_ERROR([Can't find expat library. Please install expat.])])
26 AC_SUBST(EXPAT_LIBS)
27
28-AC_CHECK_FUNCS(clearenv fdatasync)
29+AC_CHECK_FUNCS(clearenv fdatasync getnetgrent innetgr)
30
31 if test "x$GCC" = "xyes"; then
32 LDFLAGS="-Wl,--as-needed $LDFLAGS"
33diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c
34index 7019356..cf39d77 100644
35--- a/src/polkitbackend/polkitbackendinteractiveauthority.c
36+++ b/src/polkitbackend/polkitbackendinteractiveauthority.c
37@@ -2213,7 +2213,7 @@ get_users_in_group (PolkitIdentity *group,
38 out:
39 return ret;
40 }
41-
42+#if defined HAVE_GETNETGRENT
43 static GList *
44 get_users_in_net_group (PolkitIdentity *group,
45 gboolean include_root)
46@@ -2270,6 +2270,8 @@ get_users_in_net_group (PolkitIdentity *group,
47 return ret;
48 }
49
50+#endif
51+
52 /* ---------------------------------------------------------------------------------------------------- */
53
54 static void
55@@ -2355,10 +2357,12 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent,
56 {
57 user_identities = g_list_concat (user_identities, get_users_in_group (identity, FALSE));
58 }
59+#if defined HAVE_GETNETGRENT
60 else if (POLKIT_IS_UNIX_NETGROUP (identity))
61 {
62 user_identities = g_list_concat (user_identities, get_users_in_net_group (identity, FALSE));
63 }
64+#endif
65 else
66 {
67 g_warning ("Unsupported identity");
68diff --git a/src/polkitbackend/polkitbackendjsauthority.c b/src/polkitbackend/polkitbackendjsauthority.c
69index 097dcc5..e59b3f7 100644
70--- a/src/polkitbackend/polkitbackendjsauthority.c
71+++ b/src/polkitbackend/polkitbackendjsauthority.c
72@@ -1498,7 +1498,6 @@ js_polkit_spawn (JSContext *cx,
73
74 /* ---------------------------------------------------------------------------------------------------- */
75
76-
77 static JSBool
78 js_polkit_user_is_in_netgroup (JSContext *cx,
79 unsigned argc,
80@@ -1518,6 +1517,7 @@ js_polkit_user_is_in_netgroup (JSContext *cx,
81 user = JS_EncodeString (cx, user_str);
82 netgroup = JS_EncodeString (cx, netgroup_str);
83
84+#if defined HAVE_INNETGR
85 if (innetgr (netgroup,
86 NULL, /* host */
87 user,
88@@ -1525,6 +1525,7 @@ js_polkit_user_is_in_netgroup (JSContext *cx,
89 {
90 is_in_netgroup = JS_TRUE;
91 }
92+#endif
93
94 JS_free (cx, netgroup);
95 JS_free (cx, user);
96@@ -1536,8 +1537,6 @@ js_polkit_user_is_in_netgroup (JSContext *cx,
97 return ret;
98 }
99
100-
101-
102 /* ---------------------------------------------------------------------------------------------------- */
103
104 typedef struct
105--
1062.7.0
107