Bug 50145 - [PATCH] polkit-0.115 fails to build on POSIX platforms (like Linux/musl) due to requiring netgroup support
Summary: [PATCH] polkit-0.115 fails to build on POSIX platforms (like Linux/musl) due ...
Status: RESOLVED MOVED
Alias: None
Product: PolicyKit
Classification: Unclassified
Component: daemon (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium normal
Assignee: David Zeuthen (not reading bugmail)
QA Contact: David Zeuthen (not reading bugmail)
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2012-05-20 06:31 UTC by Natanael Copa
Modified: 2018-08-20 21:34 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Quick and dirty fix (3.83 KB, patch)
2012-05-20 06:47 UTC, Natanael Copa
Details | Splinter Review
make netgroup support optional (3.92 KB, patch)
2013-01-31 14:38 UTC, Natanael Copa
Details | Splinter Review
make netgroup support optional for version 0.113 (4.00 KB, patch)
2015-10-08 07:52 UTC, René Rhéaume
Details | Splinter Review
Make Netgroup support optional (16.28 KB, patch)
2018-07-11 10:49 UTC, A. Wilcox
Details | Splinter Review
Make Netgroup support optional (8.21 KB, patch)
2018-07-11 10:51 UTC, A. Wilcox
Details | Splinter Review

Description Natanael Copa 2012-05-20 06:31:41 UTC
Fails to build with the error:
  CCLD   polkitd
../../src/polkitbackend/.libs/libpolkit-backend-1.so: undefined reference to `setnetgrent'
../../src/polkitbackend/.libs/libpolkit-backend-1.so: undefined reference to `innetgr'
../../src/polkitbackend/.libs/libpolkit-backend-1.so: undefined reference to `getnetgrent'
../../src/polkitbackend/.libs/libpolkit-backend-1.so: undefined reference to `endnetgrent'
collect2: ld returned 1 exit status
make[1]: *** [polkitd] Error 1
make[1]: Leaving directory `/home/ncopa/aports/main/polkit/src/polkit-0.105/src/polkitd'

The problem is that netgroup (introduced with 674357c20c1b6cb421fea6eb6924b274ec477c0e) is not defined in POSIX and therefore not implemented in uclibc. The netgroup support should be a compiletime option.

Please note that it is during linking that the error happens so the configure script could check for getnetgrent linking.

related bug: #43610
Comment 1 Natanael Copa 2012-05-20 06:47:51 UTC
Created attachment 61878 [details] [review]
Quick and dirty fix

This quick-and-dirty patch makes it compile and should work. You might want add an --disable-netgroups configure option or similar.
Comment 2 Natanael Copa 2013-01-31 14:38:12 UTC
Created attachment 73996 [details] [review]
make netgroup support optional

Updated version of the patch.
Comment 3 René Rhéaume 2015-10-08 07:52:22 UTC
Created attachment 118753 [details] [review]
make netgroup support optional for version 0.113

It also does not work as is with version 0.113 on Lilblue (Gentoo using uclibc as system libc). My patch is a little different from the Natanel's one.
Comment 4 Miloslav Trmac 2015-10-09 10:25:09 UTC
Thanks for the patch.

1. If a system administrator does configure the system to use netgroups, polkit should somehow visibly refuse the configuration instead of silently ignoring it.  Sadly polkit_unix_netgroup_new() cannot fail, so it might mean tracking down the callers and how they are used.  (Then, get_user_in_net_group/js_polkit_user_is_in_netgroup could perhaps be #ifdef-ed to g_assert_not_reached()}.

2. Code-wise, it would be nice to minimize the number of ifdefs/conditions in the code. I guess that would mean having #ifdefs only inside get_users_in_net_group and js_polkit_user_is_in_netgroup instead of removing the functions entirely and then needing more ifdefs in their callers.


Sadly I don’t have _that_ much time for polkit and supporting non-glibc systems is honestly quite low on the priority list; still, 1. above does need to be dealt with before shipping support in an upstream release.
Comment 5 A. Wilcox 2018-07-11 10:49:23 UTC
Created attachment 140555 [details] [review]
Make Netgroup support optional

This patch has been written entirely from scratch by me from the latest Git master.

It takes all of the advice from the last patch's review:

- Show an error if configuration includes 'unix-netgroup:'.
- Put g_assert_not_reached in polkit_unix_netgroup_new since all callers have been modified to error out before it is reached.
- Pass all tests on a glibc/x86_64 machine and a musl/ppc64 machine.
Comment 6 A. Wilcox 2018-07-11 10:51:33 UTC
Created attachment 140556 [details] [review]
Make Netgroup support optional

And this one foregoes adding itself as a new file in the root source tree... whoops.  Sorry about that.
Comment 7 GitLab Migration User 2018-08-20 21:34:45 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/polkit/polkit/issues/14.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.