Bug 797 - FreeBSD nss module implementation incorrect
FreeBSD nss module implementation incorrect
Status: CLOSED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: winbind
3.0.0
Other FreeBSD
: P3 normal
: none
Assigned To: Tim Potter
:
: 798 (view as bug list)
Depends on: 948
Blocks: 807
  Show dependency treegraph
 
Reported: 2003-11-20 11:55 UTC by Aaron Collins
Modified: 2005-08-24 10:25 UTC (History)
1 user (show)

See Also:


Attachments
winbind_nss_linux.c patch for FreeBSD 5.1 nss support (2.84 KB, patch)
2003-11-25 10:05 UTC, Aaron Collins
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Collins 2003-11-20 11:55:16 UTC
I found that the nsswitch coded didn't support the freebsd 5.1 implementation correctly.  It doesn't ever register the module which accroding to the nsdispatch code is needed.  I created a patch that seems to correct the issue.  Since there is no seperate file for BSD specific code, and the config uses the winbind_nss_linux.c for freebsd also, I just added it there, below is the patch.  The patch is taken from the old BSD port.  Also in order to get the shared object to work after it is compiled it needs to be placed in /usr/lib and a sim link to nss_winbind.so.2 'ln -s /usr/lib/libnss_winbind.so /usr/lib/nss_winbind.so.2'  This should be added to the Samba 3 Howto, I know it states this is needed for solaris, but it says nothing about FreeBSD.

 diff cvs/samba/source/nsswitch/winbind_nss_linux.c /home/hellfire/winbind_nss_linux.c.old               
37,100d36
< 
< 
< #ifdef FREEBSD
< /* Make sure that the module gets registered needed by freebsd 5.1
<    Added By hellfire 11/20/03 taken from the old Ports package
< */
< 
< extern enum nss_status _nss_winbind_getgrent_r(struct group *, char *, size_t,
<     int *);
< extern enum nss_status _nss_winbind_getgrnam_r(const char *, struct group *,
<     char *, size_t, int *);
< extern enum nss_status _nss_winbind_getgrgid_r(gid_t gid, struct group *, char *,
<     size_t, int *);
< extern enum nss_status _nss_winbind_setgrent(void);
< extern enum nss_status _nss_winbind_endgrent(void);
< 
< extern enum nss_status _nss_winbind_getpwent_r(struct passwd *, char *, size_t,
<     int *);
< extern enum nss_status _nss_winbind_getpwnam_r(const char *, struct passwd *,
<     char *, size_t, int *);
< extern enum nss_status _nss_winbind_getpwuid_r(gid_t gid, struct passwd *, char *,
<     size_t, int *);
< extern enum nss_status _nss_winbind_setpwent(void);
< extern enum nss_status _nss_winbind_endpwent(void);
< 
< NSS_METHOD_PROTOTYPE(__nss_compat_getgrnam_r);
< NSS_METHOD_PROTOTYPE(__nss_compat_getgrgid_r);
< NSS_METHOD_PROTOTYPE(__nss_compat_getgrent_r);
< NSS_METHOD_PROTOTYPE(__nss_compat_setgrent);
< NSS_METHOD_PROTOTYPE(__nss_compat_endgrent);
< 
< NSS_METHOD_PROTOTYPE(__nss_compat_getpwnam_r);
< NSS_METHOD_PROTOTYPE(__nss_compat_getpwuid_r);
< NSS_METHOD_PROTOTYPE(__nss_compat_getpwent_r);
< NSS_METHOD_PROTOTYPE(__nss_compat_setpwent);
< NSS_METHOD_PROTOTYPE(__nss_compat_endpwent);
< 
< static ns_mtab methods[] = {
< { NSDB_GROUP, "getgrnam_r", __nss_compat_getgrnam_r, _nss_winbind_getgrnam_r },
< { NSDB_GROUP, "getgrgid_r", __nss_compat_getgrgid_r, _nss_winbind_getgrgid_r },
< { NSDB_GROUP, "getgrent_r", __nss_compat_getgrent_r, _nss_winbind_getgrent_r },
< { NSDB_GROUP, "endgrent",   __nss_compat_setgrent,   _nss_winbind_setgrent },
< { NSDB_GROUP, "setgrent",   __nss_compat_endgrent,   _nss_winbind_endgrent },
< 
< { NSDB_PASSWD, "getpwnam_r", __nss_compat_getpwnam_r, _nss_winbind_getpwnam_r },
< { NSDB_PASSWD, "getpwuid_r", __nss_compat_getpwuid_r, _nss_winbind_getpwuid_r },
< { NSDB_PASSWD, "getpwent_r", __nss_compat_getpwent_r, _nss_winbind_getpwent_r },
< { NSDB_PASSWD, "endpwent",   __nss_compat_setpwent,   _nss_winbind_setpwent },
< { NSDB_PASSWD, "setpwent",   __nss_compat_endpwent,   _nss_winbind_endpwent },
< 
< };
< 
< 
< ns_mtab *
< nss_module_register(const char *source, unsigned int *mtabsize,
<     nss_module_unregister_fn *unreg)
< {
<         *mtabsize = sizeof(methods)/sizeof(methods[0]);
<         *unreg = NULL;
<         return (methods);
< }
< #endif
<
Comment 1 Tim Potter 2003-11-20 22:07:27 UTC
*** Bug 798 has been marked as a duplicate of this bug. ***
Comment 2 Aaron Collins 2003-11-25 10:02:04 UTC
Here is a full patch

*** /home/hellfire/winbind_nss_linux.c.old      Thu Nov 20 12:39:45 2003
--- winbind_nss_linux.c Thu Nov 20 12:33:45 2003
***************
*** 34,39 ****
--- 34,103 ----
  
  extern int winbindd_fd;
  
+ 
+ 
+ #ifdef FREEBSD
+ /* Make sure that the module gets registered needed by freebsd 5.1
+ */
+ 
+ extern enum nss_status _nss_winbind_getgrent_r(struct group *, char *, size_t,
+     int *);
+ extern enum nss_status _nss_winbind_getgrnam_r(const char *, struct group *,
+     char *, size_t, int *);
+ extern enum nss_status _nss_winbind_getgrgid_r(gid_t gid, struct group *, char
 *,
+     size_t, int *);
+ extern enum nss_status _nss_winbind_setgrent(void);
+ extern enum nss_status _nss_winbind_endgrent(void);
+ 
+ extern enum nss_status _nss_winbind_getpwent_r(struct passwd *, char *, size_t
,
+     int *);
+ extern enum nss_status _nss_winbind_getpwnam_r(const char *, struct passwd *,
+     char *, size_t, int *);
+ extern enum nss_status _nss_winbind_getpwuid_r(gid_t gid, struct passwd *, cha
r *,
+     size_t, int *);
+ extern enum nss_status _nss_winbind_setpwent(void);
+ extern enum nss_status _nss_winbind_endpwent(void);
+ 
+ NSS_METHOD_PROTOTYPE(__nss_compat_getgrnam_r);
+ NSS_METHOD_PROTOTYPE(__nss_compat_getgrgid_r);
+ NSS_METHOD_PROTOTYPE(__nss_compat_getgrent_r);
+ NSS_METHOD_PROTOTYPE(__nss_compat_setgrent);
+ NSS_METHOD_PROTOTYPE(__nss_compat_endgrent);
+ 
+ NSS_METHOD_PROTOTYPE(__nss_compat_getpwnam_r);
+ NSS_METHOD_PROTOTYPE(__nss_compat_getpwuid_r);
+ NSS_METHOD_PROTOTYPE(__nss_compat_getpwent_r);
+ NSS_METHOD_PROTOTYPE(__nss_compat_setpwent);
+ NSS_METHOD_PROTOTYPE(__nss_compat_endpwent);
+ 
+ static ns_mtab methods[] = {
+ { NSDB_GROUP, "getgrnam_r", __nss_compat_getgrnam_r, _nss_winbind_getgrnam_r }
,
+ { NSDB_GROUP, "getgrgid_r", __nss_compat_getgrgid_r, _nss_winbind_getgrgid_r }
,
+ { NSDB_GROUP, "getgrent_r", __nss_compat_getgrent_r, _nss_winbind_getgrent_r }
,
+ { NSDB_GROUP, "endgrent",   __nss_compat_setgrent,   _nss_winbind_setgrent },
+ { NSDB_GROUP, "setgrent",   __nss_compat_endgrent,   _nss_winbind_endgrent },
+ 
+ { NSDB_PASSWD, "getpwnam_r", __nss_compat_getpwnam_r, _nss_winbind_getpwnam_r 
},
+ { NSDB_PASSWD, "getpwuid_r", __nss_compat_getpwuid_r, _nss_winbind_getpwuid_r 
},
+ { NSDB_PASSWD, "getpwent_r", __nss_compat_getpwent_r, _nss_winbind_getpwent_r 
},
+ { NSDB_PASSWD, "endpwent",   __nss_compat_setpwent,   _nss_winbind_setpwent },
+ { NSDB_PASSWD, "setpwent",   __nss_compat_endpwent,   _nss_winbind_endpwent },
+ 
+ };
+ 
+ 
+ ns_mtab *
+ nss_module_register(const char *source, unsigned int *mtabsize,
+     nss_module_unregister_fn *unreg)
+ {
+         *mtabsize = sizeof(methods)/sizeof(methods[0]);
+         *unreg = NULL;
+         return (methods);
+ }
+ #endif
+ 
  /* Allocate some space from the nss static buffer.  The buffer and buflen
     are the pointers passed in by the C library to the _nss_ntdom_*
     functions. */
Comment 3 Aaron Collins 2003-11-25 10:05:39 UTC
Created attachment 267 [details]
winbind_nss_linux.c patch for FreeBSD 5.1 nss support

Addind this patch to 3.0.1pre4 (CVS Current) should add the propper support for
FreeBSD nss module implementation.
Comment 4 Tim Potter 2003-11-26 20:57:47 UTC
Is the nss support only in freebsd 5.1?  How about freebsd 5.0?  I'll have to
write a configure test to check the minor version if it's only 5.1. (-:
Comment 5 Tim Potter 2003-11-26 21:10:27 UTC
OK I am going to apply this in a slightly modified form (some small changes to
configure.in and add your code into a new file called
nsswitch/winbind_nss_freebsd.c).

There was no copyright info in the file so I added a GPL header and copyright
2003 Aaron Collins.  If this is not OK please let me know - it's either the GPL
or nothing.  (-:

I'll let the build farm chew over it for a while as I don't have direct access
to any fbsd machines.
Comment 6 Gerald (Jerry) Carter 2003-11-29 10:04:25 UTC
tpot checked in a patch.  Marking as fixed.
Comment 7 Tim Potter 2003-12-10 15:07:51 UTC
Unfortunately the patch doesn't seem to compile.  There are some header files
that need to be included in the winbind_freebsd.c file.  Aaron would you be able
to take a look and perhaps provide a patch?
Comment 8 Gerald (Jerry) Carter 2003-12-12 08:27:53 UTC
reseting target milestone.  3.0.1 has been frozen.  WIll have to 
re-evaluate these.
Comment 9 Gerald (Jerry) Carter 2004-01-14 13:07:49 UTC
This is fixed now wuth the patch from bug 948
Comment 10 Gerald (Jerry) Carter 2005-08-24 10:25:17 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.