Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 1 | From 7d5e205aa58a10e7b1ccc2fa75b443508a5c3e18 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 20 Jan 2016 04:31:59 +0000 |
| 4 | Subject: [PATCH] make netgroup support configurable |
| 5 | |
| 6 | Disable using innetgr and *netigrent function if not available |
| 7 | |
| 8 | These functions are not available on all libc implementations e.g. musl |
| 9 | doesnt have them. |
| 10 | |
| 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 12 | --- |
| 13 | Upstream-Status: Pending |
| 14 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 15 | Rebase to 0.115 |
| 16 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
| 17 | --- |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 18 | configure.ac | 2 +- |
| 19 | src/polkitbackend/polkitbackendinteractiveauthority.c | 6 +++++- |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 20 | src/polkitbackend/polkitbackendjsauthority.cpp | 2 ++ |
| 21 | 3 files changed, 8 insertions(+), 2 deletions(-) |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 22 | |
| 23 | diff --git a/configure.ac b/configure.ac |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 24 | index 8b3e1b1..1c392df 100644 |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 25 | --- a/configure.ac |
| 26 | +++ b/configure.ac |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 27 | @@ -99,7 +99,7 @@ AC_CHECK_LIB(expat,XML_ParserCreate,[EXPAT_LIBS="-lexpat"], |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 28 | [AC_MSG_ERROR([Can't find expat library. Please install expat.])]) |
| 29 | AC_SUBST(EXPAT_LIBS) |
| 30 | |
| 31 | -AC_CHECK_FUNCS(clearenv fdatasync) |
| 32 | +AC_CHECK_FUNCS(clearenv fdatasync getnetgrent innetgr) |
| 33 | |
| 34 | if test "x$GCC" = "xyes"; then |
| 35 | LDFLAGS="-Wl,--as-needed $LDFLAGS" |
| 36 | diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 37 | index cb6fdab..de3f752 100644 |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 38 | --- a/src/polkitbackend/polkitbackendinteractiveauthority.c |
| 39 | +++ b/src/polkitbackend/polkitbackendinteractiveauthority.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 40 | @@ -2224,7 +2224,7 @@ get_users_in_group (PolkitIdentity *group, |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 41 | out: |
| 42 | return ret; |
| 43 | } |
| 44 | - |
| 45 | +#if defined HAVE_GETNETGRENT |
| 46 | static GList * |
| 47 | get_users_in_net_group (PolkitIdentity *group, |
| 48 | gboolean include_root) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 49 | @@ -2285,6 +2285,8 @@ get_users_in_net_group (PolkitIdentity *group, |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 50 | return ret; |
| 51 | } |
| 52 | |
| 53 | +#endif |
| 54 | + |
| 55 | /* ---------------------------------------------------------------------------------------------------- */ |
| 56 | |
| 57 | static void |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 58 | @@ -2369,10 +2371,12 @@ authentication_agent_initiate_challenge (AuthenticationAgent *agent, |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 59 | { |
| 60 | user_identities = g_list_concat (user_identities, get_users_in_group (identity, FALSE)); |
| 61 | } |
| 62 | +#if defined HAVE_GETNETGRENT |
| 63 | else if (POLKIT_IS_UNIX_NETGROUP (identity)) |
| 64 | { |
| 65 | user_identities = g_list_concat (user_identities, get_users_in_net_group (identity, FALSE)); |
| 66 | } |
| 67 | +#endif |
| 68 | else |
| 69 | { |
| 70 | g_warning ("Unsupported identity"); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 71 | diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp |
| 72 | index 517f3c6..6042dd2 100644 |
| 73 | --- a/src/polkitbackend/polkitbackendjsauthority.cpp |
| 74 | +++ b/src/polkitbackend/polkitbackendjsauthority.cpp |
| 75 | @@ -1502,6 +1502,7 @@ js_polkit_user_is_in_netgroup (JSContext *cx, |
| 76 | user = JS_EncodeString (cx, args[0].toString()); |
| 77 | netgroup = JS_EncodeString (cx, args[1].toString()); |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 78 | |
| 79 | +#if defined HAVE_INNETGR |
| 80 | if (innetgr (netgroup, |
| 81 | NULL, /* host */ |
| 82 | user, |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 83 | @@ -1509,6 +1510,7 @@ js_polkit_user_is_in_netgroup (JSContext *cx, |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 84 | { |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 85 | is_in_netgroup = true; |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 86 | } |
| 87 | +#endif |
| 88 | |
| 89 | JS_free (cx, netgroup); |
| 90 | JS_free (cx, user); |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 91 | -- |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 92 | 2.7.4 |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 93 | |