summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/Makefile.in10
-rw-r--r--source3/configure.in2
-rw-r--r--source3/include/config.h.in3
-rw-r--r--source3/nsswitch/wins.c94
4 files changed, 91 insertions, 18 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index ae019d6f63..b1b4c6d4ec 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -69,7 +69,7 @@ LOCKDIR = @lockdir@
# man pages language(s)
man_langs = "@manlangs@"
-FLAGS1 = $(CFLAGS) @FLAGS1@ -Iinclude -I$(srcdir)/include -I$(srcdir)/ubiqx -I$(srcdir)/smbwrapper $(CPPFLAGS) -I. -I$(srcdir)
+FLAGS1 = $(CFLAGS) @FLAGS1@ -Iinclude -I$(srcdir)/include -I$(srcdir)/ubiqx -I$(srcdir)/smbwrapper -I$(srcdir)/nsswitch $(CPPFLAGS) -I. -I$(srcdir)
FLAGS2 =
FLAGS3 =
FLAGS4 =
@@ -679,11 +679,11 @@ bin/smbw_sample: $(SMBW_OBJ) utils/smbw_sample.o bin/.dummy
bin/smbwrapper.@SHLIBEXT@: $(PICOBJS)
@echo Linking shared library $@
- @$(LD) $(LDSHFLAGS) -o $@ $(PICOBJS) $(LIBS)
+ @$(LINK) $(LDSHFLAGS) -o $@ $(PICOBJS) $(LIBS)
bin/smbwrapper.32.@SHLIBEXT@: $(PICOBJS32)
@echo Linking shared library $@
- @$(LD) -32 $(LDSHFLAGS) -o $@ $(PICOBJS32) $(LIBS)
+ @$(LINK) -32 $(LDSHFLAGS) -o $@ $(PICOBJS32) $(LIBS)
bin/libsmbclient.@SHLIBEXT@: $(LIBSMBCLIENT_PICOBJS)
echo Linking libsmbclient shared library $@
@@ -701,7 +701,7 @@ bin/smbsh: $(SMBSH_OBJ) bin/.dummy
nsswitch/libnss_wins.so: $(NSS_OBJ)
@echo "Linking $@"
- @$(LD) $(LDSHFLAGS) -o $@ $(NSS_OBJ) -lc
+ @$(LINK) $(LDSHFLAGS) -o $@ $(NSS_OBJ) -lc
bin/winbindd: $(WINBINDD_OBJ) bin/.dummy
@echo Linking $@
@@ -723,7 +723,7 @@ bin/wbinfo: $(WBINFO_OBJ) $(PARAM_OBJ) $(LIB_OBJ) $(NOPROTO_OBJ) \
bin/pam_smbpass.@SHLIBEXT@: $(PAM_SMBPASS_PICOOBJ)
@echo "Linking shared library $@"
- $(LD) $(LDSHFLAGS) -symbolic -o $@ $(PAM_SMBPASS_PICOOBJ) -lpam $(LIBS) -lc
+ $(LINK) $(LDSHFLAGS) -symbolic -o $@ $(PAM_SMBPASS_PICOOBJ) -lpam $(LIBS) -lc
bin/libmsrpc.a: $(LIBMSRPC_PICOBJ)
-$(AR) -rc $@ $(LIBMSRPC_PICOBJ)
diff --git a/source3/configure.in b/source3/configure.in
index 84d20e941a..d88565be38 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -265,7 +265,7 @@ case "$host_os" in
;;
esac
AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
-AC_CHECK_HEADERS(nss.h nss_common.h sys/security.h security/pam_appl.h security/pam_modules.h)
+AC_CHECK_HEADERS(nss.h nss_common.h ns_api.h sys/security.h security/pam_appl.h security/pam_modules.h)
AC_CHECK_HEADERS(stropts.h poll.h)
AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h glob.h)
diff --git a/source3/include/config.h.in b/source3/include/config.h.in
index d00722c5bd..b87a3d4083 100644
--- a/source3/include/config.h.in
+++ b/source3/include/config.h.in
@@ -862,6 +862,9 @@
/* Define if you have the <netinet/tcp.h> header file. */
#undef HAVE_NETINET_TCP_H
+/* Define if you have the <ns_api.h> header file. */
+#undef HAVE_NS_API_H
+
/* Define if you have the <nss.h> header file. */
#undef HAVE_NSS_H
diff --git a/source3/nsswitch/wins.c b/source3/nsswitch/wins.c
index abc7b6f414..0ab0954812 100644
--- a/source3/nsswitch/wins.c
+++ b/source3/nsswitch/wins.c
@@ -23,12 +23,20 @@
#define NO_SYSLOG
#include "includes.h"
-#include <nss.h>
+#ifdef HAVE_NS_API_H
+#undef VOLATILE
+
+#include <ns_daemon.h>
+#define NSD_LOGLEVEL NSD_LOG_MIN
+#endif
#ifndef INADDRSZ
#define INADDRSZ 4
#endif
+static int initialised;
+
+
/* Use our own create socket code so we don't recurse.... */
static int wins_lookup_open_socket_in(void)
@@ -62,20 +70,26 @@ static int wins_lookup_open_socket_in(void)
return res;
}
-struct in_addr *lookup_backend(const char *name, int *count)
+
+static void nss_wins_init(void)
+{
+ initialised = 1;
+ DEBUGLEVEL = 0;
+
+ setup_logging("nss_wins",False);
+ lp_load(dyn_CONFIGFILE,True,False,False);
+ load_interfaces();
+}
+
+static struct in_addr *lookup_backend(const char *name, int *count)
{
int fd;
- static int initialised;
- struct in_addr *ret;
+ struct in_addr *ret = NULL;
struct in_addr p;
int j;
if (!initialised) {
- initialised = 1;
- DEBUGLEVEL = 0;
- setup_logging("nss_wins",True);
- lp_load(dyn_CONFIGFILE,True,False,False);
- load_interfaces();
+ nss_wins_init();
}
*count = 0;
@@ -125,7 +139,60 @@ struct in_addr *lookup_backend(const char *name, int *count)
gethostbyname() - we ignore any domain portion of the name and only
handle names that are at most 15 characters long
**************************************************************************/
-enum nss_status
+#ifdef HAVE_NS_API_H
+/* IRIX version */
+
+int init(void)
+{
+ nsd_logprintf(NSD_LOGLEVEL, "init (wins)\n");
+ nss_wins_init();
+ return NSD_OK;
+}
+
+int lookup(nsd_file_t *rq)
+{
+ char *map;
+ char *key;
+ struct in_addr *ip_list;
+ int count;
+ char response[80];
+
+ nsd_logprintf(NSD_LOGLEVEL, "lookup (wins)\n");
+ if (! rq)
+ return NSD_ERROR;
+
+ map = nsd_attr_fetch_string(rq->f_attrs, "table", (char*)0);
+ if (! map) {
+ rq->f_status = NS_FATAL;
+ return NSD_ERROR;
+ }
+
+ if (strcasecmp(map,"hosts.byname") != 0) {
+ rq->f_status = NS_NOTFOUND;
+ return NSD_NEXT;
+ }
+
+ key = nsd_attr_fetch_string(rq->f_attrs, "key", (char*)0);
+ if (! key || ! *key) {
+ rq->f_status = NS_FATAL;
+ return NSD_ERROR;
+ }
+
+ ip_list = lookup_backend(key, &count);
+
+ if (!ip_list) {
+ rq->f_status = NSS_STATUS_NOTFOUND;
+ return NSD_NEXT;
+ }
+ snprintf(response,79,"%s %s\n",inet_ntoa(*ip_list),key);
+ free(ip_list);
+
+ nsd_set_result(rq,NS_SUCCESS,response,strlen(response),VOLATILE);
+ return NSD_OK;
+}
+
+#else
+NSS_STATUS
_nss_wins_gethostbyname_r(const char *name, struct hostent *he,
char *buffer, size_t buflen, int *errnop,
int *h_errnop)
@@ -134,7 +201,7 @@ _nss_wins_gethostbyname_r(const char *name, struct hostent *he,
struct in_addr *ip_list;
int i, count;
size_t namelen = strlen(name) + 1;
-
+
memset(he, '\0', sizeof(*he));
ip_list = lookup_backend(name, &count);
@@ -164,10 +231,13 @@ _nss_wins_gethostbyname_r(const char *name, struct hostent *he,
host_addresses++;
}
- SAFE_FREE(ip_list);
+ if (ip_list)
+ free(ip_list);
memcpy(buffer, name, namelen);
he->h_name = buffer;
return NSS_STATUS_SUCCESS;
}
+#endif
+