Edgar Fuß
2013-12-03 17:48:09 UTC
I'm currently porting nss-pam-ldapd to NetBSD and need some advice.
The nss-pam-ldapd clients have originally been designed for glibc and then
extended to support Solaris and FreeBSD NSS via compatibility shims. For
FreeBSD, this is made easier by __nss_compat_xxx() functions in their libc
(lib/libc/net/nss_compat.c) emulating the FreeBSD NSS interface on top of
glibc's. I haven't looked at PAM yet.
I do have a working (at least for NSS and as far as I can currently tell)
package, but I would like someone to have a look at my code, especially the
xxx_r() functions.
I attach both my patches and the resulting files. The patches are against
nss/bsdnss.c and compat/nss_compat.h from nss-pam-ldapd 0.8.13 and
lib/libc/net/nss_compat.c from FreeBSD trunk.
It's somewhat weird that FreeBSD and NetBSD have their NSS module functions
arguments/results the other way round. For getpwnam_r(), FreeBSD returns the
struct passwd * via the method's first argument (cbrv) and the numeric
status result via the last thing in the va_list ap argument, while for
NetBSD, the first thing in the va_list ap is int *retval for the numeric
result and the last one is struct passwd **result for the pointer (and the
method's first argument is unused). On the other hand, for gethostbyname(),
FreeBSD seems to have a pointer to the result as the first thing in
va_list ap, while this time, NetBSD returns the result via the method's
first argument void *cbrv.
I can also post the complete pkgsrc package if that helps.
The nss-pam-ldapd clients have originally been designed for glibc and then
extended to support Solaris and FreeBSD NSS via compatibility shims. For
FreeBSD, this is made easier by __nss_compat_xxx() functions in their libc
(lib/libc/net/nss_compat.c) emulating the FreeBSD NSS interface on top of
glibc's. I haven't looked at PAM yet.
I do have a working (at least for NSS and as far as I can currently tell)
package, but I would like someone to have a look at my code, especially the
xxx_r() functions.
I attach both my patches and the resulting files. The patches are against
nss/bsdnss.c and compat/nss_compat.h from nss-pam-ldapd 0.8.13 and
lib/libc/net/nss_compat.c from FreeBSD trunk.
It's somewhat weird that FreeBSD and NetBSD have their NSS module functions
arguments/results the other way round. For getpwnam_r(), FreeBSD returns the
struct passwd * via the method's first argument (cbrv) and the numeric
status result via the last thing in the va_list ap argument, while for
NetBSD, the first thing in the va_list ap is int *retval for the numeric
result and the last one is struct passwd **result for the pointer (and the
method's first argument is unused). On the other hand, for gethostbyname(),
FreeBSD seems to have a pointer to the result as the first thing in
va_list ap, while this time, NetBSD returns the result via the method's
first argument void *cbrv.
I can also post the complete pkgsrc package if that helps.