void-packages/srcpkgs/polkit/patches/make-innetgr-optional.patch
Đoàn Trần Công Danh 49cb564d14 srcpkgs/p*: convert patches to -Np1
* par is kept at -Np0

```sh
git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.-][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.-][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

68 lines
2 KiB
Diff

--- a/configure.ac
+++ b/configure.ac
@@ -99,7 +99,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 fdatasync)
+AC_CHECK_FUNCS(clearenv fdatasync getnetgrent)
if test "x$GCC" = "xyes"; then
LDFLAGS="-Wl,--as-needed $LDFLAGS"
--- a/src/polkitbackend/polkitbackendinteractiveauthority.c
+++ b/src/polkitbackend/polkitbackendinteractiveauthority.c
@@ -2228,6 +2228,7 @@ get_users_in_net_group (PolkitIdentity *group,
ret = NULL;
name = polkit_unix_netgroup_get_name (POLKIT_UNIX_NETGROUP (group));
+#if defined HAVE_GETNETGRENT
#ifdef HAVE_SETNETGRENT_RETURN
if (setnetgrent (name) == 0)
{
@@ -2236,6 +2237,7 @@ get_users_in_net_group (PolkitIdentity *group,
}
#else
setnetgrent (name);
+#endif
#endif
for (;;)
@@ -2248,8 +2250,10 @@ get_users_in_net_group (PolkitIdentity *group,
PolkitIdentity *user;
GError *error = NULL;
+#if defined HAVE_GETNETGRENT
if (getnetgrent (&hostname, &username, &domainname) == 0)
break;
+#endif
/* Skip NULL entries since we never want to make everyone an admin
* Skip "-" entries which mean "no match ever" in netgroup land */
@@ -2274,7 +2278,9 @@ get_users_in_net_group (PolkitIdentity *group,
ret = g_list_reverse (ret);
out:
+#if defined HAVE_GETNETGRENT
endnetgrent ();
+#endif
return ret;
}
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -1502,6 +1502,7 @@
JS::CallArgs args = JS::CallArgsFromVp (argc, vp);
+#if defined HAVE_GETNETGRENT
JS::RootedString usrstr (authority->priv->cx);
usrstr = args[0].toString();
user = JS_EncodeStringToUTF8 (cx, usrstr);
@@ -1521,6 +1522,7 @@
JS_free (cx, user);
ret = true;
+#endif
args.rval ().setBoolean (is_in_netgroup);