Bug 1232 - Fix for winbind_nss get{pw,gr}ent on FreeBSD
Fix for winbind_nss get{pw,gr}ent on FreeBSD
Status: CLOSED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: winbind
3.0.2a
All FreeBSD
: P3 major
: none
Assigned To: Samba Bugzilla Account
http://lists.samba.org/archive/samba-...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-03-31 05:55 UTC by Landon Fuller
Modified: 2005-11-14 09:28 UTC (History)
0 users

See Also:


Attachments
Patch to fix getgrent and getpwent on FreeBSD (2.15 KB, patch)
2004-03-31 05:56 UTC, Landon Fuller
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Landon Fuller 2004-03-31 05:55:22 UTC
For simplicity, I will explain the getgrent case below. The getpwent case
is exactly the same; simply substitute 'pw' for 'gr' and you'll understand
it perfectly. I'm new to the code base; I apologize for anything I've
missed.

In winbindd_group.c, winbindd_getgrent() checks that state->getgrent_state
is not NULL before proceeding:
        if (!(ent = state->getgrent_state))
                return WINBINDD_ERROR;

There are four conditions under which state->getgrent_state will be NULL:
    1) winbindd_setgrent() has not been called
    2) The end of the group list has been reached, and
state->getgrent_state has been set to NULL.
    3) winbindd_endgrent() has been called.
    4) The associated client connection has been closed

Condition #1 is breaks user/group enumeration and 'supplementary' groups
on FreeBSD; setgrent() is not called (by libc or otherwise) prior to
getgrent(),and so winbindd_getgrent() immediately returns WINBINDD_ERROR.

In my patch, I have added two additional variables to the winbindd_cli_state
structure:
    BOOL getpwent_initialized;
    BOOL getgrent_initialized;

With the patch:
    winbindd_setgrent() sets state->getgrent_initialized to True;
    winbindd_endgrent() sets state->getgrent_initialized to False;
    In winbindd_getgrent(), if state->getgrent_initialized is False,
    winbindd_setgrent() is called;

Since getgrent_state signifies end-of-list with NULL, it can not also be
used to signify that the list has not been initialized.

With attached patch, user and group enumeration works on FreeBSD 5.2.1
Comment 1 Landon Fuller 2004-03-31 05:56:03 UTC
Created attachment 461 [details]
Patch to fix getgrent and getpwent on FreeBSD
Comment 2 Gerald (Jerry) Carter 2004-04-28 12:27:18 UTC
Looks good.  Will test and then check in for 3.0.3.
Comment 3 Gerald (Jerry) Carter 2005-08-24 10:18:27 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.
Comment 4 Gerald (Jerry) Carter 2005-11-14 09:28:47 UTC
database cleanup