summaryrefslogtreecommitdiff
path: root/net/nss_ldap/files/bsdnss.c
diff options
context:
space:
mode:
authorJacques Vidrine <nectar@FreeBSD.org>2003-04-17 14:26:46 +0000
committerJacques Vidrine <nectar@FreeBSD.org>2003-04-17 14:26:46 +0000
commit2cc92ba66e5daa9e3c1d60bb7eca7e815819c5f2 (patch)
tree4e60eb40214e89e6bde1deffb62a01a3a18be059 /net/nss_ldap/files/bsdnss.c
parentPrevious commit was (diff)
Add nss_ldap, an RFC 2307-compliant NSS module. Currently only the
getpwent(3) and getgrent(3) family of functions are supported.
Diffstat (limited to 'net/nss_ldap/files/bsdnss.c')
-rw-r--r--net/nss_ldap/files/bsdnss.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/net/nss_ldap/files/bsdnss.c b/net/nss_ldap/files/bsdnss.c
new file mode 100644
index 000000000000..598bdb7fe94f
--- /dev/null
+++ b/net/nss_ldap/files/bsdnss.c
@@ -0,0 +1,59 @@
+#include <sys/param.h>
+#include <pwd.h>
+#include <grp.h>
+#include <nss.h>
+
+extern enum nss_status _nss_ldap_getgrent_r(struct group *, char *, size_t,
+ int *);
+extern enum nss_status _nss_ldap_getgrnam_r(const char *, struct group *,
+ char *, size_t, int *);
+extern enum nss_status _nss_ldap_getgrgid_r(gid_t gid, struct group *, char *,
+ size_t, int *);
+extern enum nss_status _nss_ldap_setgrent(void);
+extern enum nss_status _nss_ldap_endgrent(void);
+
+extern enum nss_status _nss_ldap_getpwent_r(struct passwd *, char *, size_t,
+ int *);
+extern enum nss_status _nss_ldap_getpwnam_r(const char *, struct passwd *,
+ char *, size_t, int *);
+extern enum nss_status _nss_ldap_getpwuid_r(gid_t gid, struct passwd *, char *,
+ size_t, int *);
+extern enum nss_status _nss_ldap_setpwent(void);
+extern enum nss_status _nss_ldap_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_ldap_getgrnam_r },
+{ NSDB_GROUP, "getgrgid_r", __nss_compat_getgrgid_r, _nss_ldap_getgrgid_r },
+{ NSDB_GROUP, "getgrent_r", __nss_compat_getgrent_r, _nss_ldap_getgrent_r },
+{ NSDB_GROUP, "endgrent", __nss_compat_setgrent, _nss_ldap_setgrent },
+{ NSDB_GROUP, "setgrent", __nss_compat_endgrent, _nss_ldap_endgrent },
+
+{ NSDB_PASSWD, "getpwnam_r", __nss_compat_getpwnam_r, _nss_ldap_getpwnam_r },
+{ NSDB_PASSWD, "getpwuid_r", __nss_compat_getpwuid_r, _nss_ldap_getpwuid_r },
+{ NSDB_PASSWD, "getpwent_r", __nss_compat_getpwent_r, _nss_ldap_getpwent_r },
+{ NSDB_PASSWD, "endpwent", __nss_compat_setpwent, _nss_ldap_setpwent },
+{ NSDB_PASSWD, "setpwent", __nss_compat_endpwent, _nss_ldap_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);
+}