allow IRIX to build nsswitch/libnss_wins.so
authorHerb Lewis <herb@samba.org>
Wed, 12 Dec 2001 16:08:32 +0000 (16:08 +0000)
committerHerb Lewis <herb@samba.org>
Wed, 12 Dec 2001 16:08:32 +0000 (16:08 +0000)
(This used to be commit 564bfd77287b3006c7246065990ca9b91f79826a)

source3/Makefile.in
source3/configure.in
source3/include/config.h.in
source3/nsswitch/wins.c

index ae019d6f63f87d27c8822c4e49d72c88dfda6cf2..b1b4c6d4ecb285abf995548d162436d5ab86af05 100644 (file)
@@ -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) 
index 84d20e941a8cba97fbeeea24123d904e8c4c669a..d88565be38cf0efec2ab2c8d7e56b8e2b4ab4fc6 100644 (file)
@@ -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)
index d00722c5bd677198ac717dc3a8140e63c0306842..b87a3d4083ed038138775faa858c60d1e1efb4a5 100644 (file)
 /* 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
 
index abc7b6f414e0a6a88f8d1a6c6197a6c8474c5014..0ab0954812503f8743dd75ffbd3b32060a9718c7 100644 (file)
 #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
+