Re: getgrouplist(3) vs. getgroups(3)
- From: Roland Illig <roland illig gmx de>
- To: MC Devel <mc-devel gnome org>
- Subject: Re: getgrouplist(3) vs. getgroups(3)
- Date: Fri, 22 Jul 2005 15:16:47 +0200
Roland Illig wrote:
+ if (!initialized) {
+ uid = getuid ();
+ ngroups = getgroups (0, NULL);
+ if (ngroups != -1) {
/* allocate space for one more element
* than will be filled by getgroups(). */
+ groups = g_new (gid_t, ngroups + 1);
+ ngroups = getgroups (ngroups, groups);
+
+ /* getgroups() may or may not return the effective group ID,
+ * so we always include it at the end of the list. */
+ if (ngroups >= 0) {
+ groups[ngroups++] = getegid();
+ }
+ }
+ initialized = TRUE;
+ }
I felt the need for that comment because otherwise the "+ 1" could
become misinterpreted. Together with the second comment, it should be ok.
Roland
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]