odd issue when running dbus-launch [cause found, but no fix found yet]

Vulpes Velox v.velox at vvelox.net
Mon Dec 18 23:44:22 PST 2006

On Tue, 19 Dec 2006 07:45:48 +0100
Thiago Macieira <thiago at kde.org> wrote:

> Vulpes Velox wrote:
> >On Tue, 19 Dec 2006 01:39:41 +0100
> >
> >Thiago Macieira <thiago at kde.org> wrote:
> >> Vulpes Velox wrote:
> >> >> I had understood that the program I gave you worked
> >> >> out-of-the-box. If it didn't, tell me. What is the value of
> >> >> "ng" in the test program after the first getgrouplist?
> >> >
> >> >For the both tests, I left it at the default value of 17. For
> >> >the second test I added the user to more groups. Past 16 it
> >> >fails.
> >>
> >> You still haven't given me the value I want: the value of ng
> >> after getgrouplist fails.
> >
> >It fails at being a member of 17 group or more, like I have said
> >in the last email.
> I know. What is the value of ng after that happens?

I must be a little confused, after what happens? 

ng never changes once it is set. The value of ng is what is causing
the failure. It should be set at NGROUPS_MAX + 1. This is to make
sure it can include the maximum number of groups that the system
regards it's self as supporting. The reason for the + 1 is because
the user's main group tends to get included twice for some reason.

ng is the the integer being passed to getgrouplist and it represents
the size of the array that the number of groups the user is a member
of is expected to fit in.

The error happens because I have created a user that is in more
groups than the value of ng allows for.

Currently digging through the dbus-sysdeps-unix.c trying to figure
out what a few parts do. Going to site down and look at it more
in depth tomorrow. I can read some of it currently, but not all I
need to. I can say the error is happening some where between line
1285 and 1319. It has a fall back for if buf_count is to low, but I
am not sure exactly what that is doing right now.

snipped from GETGROUPLIST(3)...
     #include <unistd.h>

     getgrouplist(const char *name, gid_t basegid, gid_t *groups,
         int *ngroups);

     The getgrouplist() function reads through the group file and
calculates the group access list for the user specified in name.  The
basegid is automatically included in the groups list.  Typically this
value is given as the group number from the password file.

     The resulting group list is returned in the array pointed to by
groups. The caller specifies the size of the groups array in the
integer pointed to by ngroups; the actual number of groups found is
returned in ngroups.

     The getgrouplist() function returns -1 if the size of the group
list is too small to hold all the user's groups.  Here, the group
array will be filled with as many groups as will fit.

More information about the dbus mailing list