1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
--- polkit-0.113/configure.ac
+++ polkit-0.113-optional-netgroup/configure.ac
@@ -158,7 +158,7 @@ AC_CHECK_LIB(expat,XML_ParserCreate,[EXP
[AC_MSG_ERROR([Can't find expat library. Please install expat.])])
AC_SUBST(EXPAT_LIBS)
-AC_CHECK_FUNCS(clearenv fdatasync)
+AC_CHECK_FUNCS(clearenv fdatasync getnetgrent)
if test "x$GCC" = "xyes"; then
LDFLAGS="-Wl,--as-needed $LDFLAGS"
--- polkit-0.113/src/polkitbackend/init.js
+++ polkit-0.113-optional-netgroup/src/polkitbackend/init.js
@@ -29,7 +29,10 @@ function Subject() {
};
this.isInNetGroup = function(netGroup) {
- return polkit._userIsInNetGroup(this.user, netGroup);
+ if (polkit._userIsInNetGroup)
+ return polkit._userIsInNetGroup(this.user, netGroup);
+ else
+ return false;
};
this.toString = function() {
--- polkit-0.113/src/polkitbackend/polkitbackendinteractiveauthority.c
+++ polkit-0.113-optional-netgroup/src/polkitbackend/polkitbackendinteractiveauthority.c
@@ -2214,6 +2214,7 @@ get_users_in_group (PolkitIdentity
return ret;
}
+#ifdef HAVE_GETNETGRENT
static GList *
get_users_in_net_group (PolkitIdentity *group,
gboolean include_root)
@@ -2269,6 +2270,7 @@ get_users_in_net_group (PolkitIdentity
endnetgrent ();
return ret;
}
+#endif
/* ---------------------------------------------------------------------------------------------------- */
@@ -2355,10 +2357,12 @@ authentication_agent_initiate_challenge
{
user_identities = g_list_concat (user_identities, get_users_in_group (identity, FALSE));
}
+#ifdef 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");
--- polkit-0.113/src/polkitbackend/polkitbackendjsauthority.c
+++ polkit-0.113-optional-netgroup/src/polkitbackend/polkitbackendjsauthority.c
@@ -189,13 +189,16 @@ static JSClass js_polkit_class = {
static JSBool js_polkit_log (JSContext *cx, unsigned argc, jsval *vp);
static JSBool js_polkit_spawn (JSContext *cx, unsigned argc, jsval *vp);
+#ifdef HAVE_GETNETGRENT
static JSBool js_polkit_user_is_in_netgroup (JSContext *cx, unsigned argc, jsval *vp);
-
+#endif
static JSFunctionSpec js_polkit_functions[] =
{
JS_FS("log", js_polkit_log, 0, 0),
JS_FS("spawn", js_polkit_spawn, 0, 0),
+#ifdef HAVE_GETNETGRENT
JS_FS("_userIsInNetGroup", js_polkit_user_is_in_netgroup, 0, 0),
+#endif
JS_FS_END
};
@@ -1498,7 +1501,7 @@ js_polkit_spawn (JSContext *cx,
/* ---------------------------------------------------------------------------------------------------- */
-
+#ifdef HAVE_GETNETGRENT
static JSBool
js_polkit_user_is_in_netgroup (JSContext *cx,
unsigned argc,
@@ -1535,7 +1538,7 @@ js_polkit_user_is_in_netgroup (JSContext
out:
return ret;
}
-
+#endif
/* ---------------------------------------------------------------------------------------------------- */
--- polkit-0.113/test/polkitbackend/test-polkitbackendjsauthority.c
+++ polkit-0.113-optional-netgroup/test/polkitbackend/test-polkitbackendjsauthority.c
@@ -137,12 +137,14 @@ test_get_admin_identities (void)
"unix-group:users"
}
},
+#ifdef HAVE_GETNETGRENT
{
"net.company.action3",
{
"unix-netgroup:foo"
}
},
+#endif
};
guint n;
@@ -258,7 +260,7 @@ static const RulesTestCase rules_test_ca
NULL,
POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED,
},
-
+#if HAVE_GETNETGRENT
/* check netgroup membership */
{
/* john is a member of netgroup 'foo', see test/etc/netgroup */
@@ -276,7 +278,7 @@ static const RulesTestCase rules_test_ca
NULL,
POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED,
},
-
+#endif
/* spawning */
{
"spawning_non_existing_helper",
|