s3:auth: only call secrets_fetch_domain_sid() once in finalize_local_nt_token()
[Samba.git] / nsswitch / wins_freebsd.c
blobc1845d2a17327570871c1868e5fa3bfc975777f2
1 /*
2 Unix SMB/CIFS implementation.
4 Copyright (C) Timur I. Bakeyev 2007
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with this library; if not, write to the
18 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
22 #include "winbind_client.h"
24 extern enum nss_status _nss_wins_gethostbyname2_r(const char *name, int af, struct hostent *he,
25 char *buffer, size_t buflen, int *h_errnop);
27 ns_mtab *nss_module_register(const char *source, unsigned int *, nss_module_unregister_fn *);
29 NSS_METHOD_PROTOTYPE(__nss_wins_freebsd_gethostbyname2_r);
31 static ns_mtab methods[] =
33 { NSDB_HOSTS, "getaddrinfo", NULL, NULL },
34 { NSDB_HOSTS, "ghbyname", NULL, NULL },
35 { NSDB_HOSTS, "ghbyaddr", NULL, NULL },
36 { NSDB_HOSTS, "gethostbyaddr_r", NULL, NULL },
37 { NSDB_HOSTS, "gethostbyname2_r", __nss_wins_freebsd_gethostbyname2_r, _nss_wins_gethostbyname2_r },
38 { NSDB_HOSTS, "getnetbyname_r", NULL, NULL },
39 { NSDB_HOSTS, "getnetbyaddr_r", NULL, NULL },
40 { NSDB_HOSTS, "gethostbyname", NULL, NULL },
41 { NSDB_HOSTS, "gethostbyaddr", NULL, NULL },
42 { NSDB_HOSTS, "getnetbyname", NULL, NULL },
43 { NSDB_HOSTS, "getnetbyaddr", NULL, NULL }
46 int
47 __nss_wins_freebsd_gethostbyname2_r(void *retval, void *mdata, va_list ap)
49 int (*fn)(const char *, int, struct hostent *, char *, size_t, int *);
50 const char *hostname;
51 int af;
52 struct hostent *he;
53 char *buffer;
54 size_t buflen;
55 int *h_errnop;
56 enum nss_status status;
58 fn = mdata;
59 hostname = va_arg(ap, const char *);
60 af = va_arg(ap, int);
61 he = va_arg(ap, struct hostent *);
62 buffer = va_arg(ap, char *);
63 buflen = va_arg(ap, size_t);
64 h_errnop = va_arg(ap, int *);
66 status = fn(hostname, af, he, buffer, buflen, h_errnop);
67 status = __nss_compat_result(status, *h_errnop);
68 if (status == NS_SUCCESS)
69 *(struct hostent **)retval = he;
71 return (status);
74 ns_mtab *
75 nss_module_register(const char *source __unused, unsigned int *mtabsize,
76 nss_module_unregister_fn *unreg)
78 *mtabsize = sizeof(methods) / sizeof(methods[0]);
79 *unreg = NULL;
80 return (methods);