Should have thought of this...
[icmp-dn.git] / nss-icmp.c
index 014f257..5bc5ec7 100644 (file)
@@ -1,3 +1,24 @@
+/*
+ *  nss-icmp or libnss_icmp - GNU C Library NSS module to query host
+ *  names by ICMP.
+ *  Copyright (C) 2005 Fredrik Tolf <fredrik@dolda2000.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ *  MA 02111-1307, USA
+ */
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -11,6 +32,7 @@
 #include <nss.h>
 #include <sys/types.h>
 #include <fcntl.h>
+#include <sys/wait.h>
 
 #define CONFIGFILE "/etc/nss-icmp.conf"
 #if 0
@@ -196,6 +218,7 @@ enum nss_status _nss_icmp_gethostbyaddr_r(const void *addr, socklen_t len, int a
     pid_t child;
     int pfd[2];
     int rl;
+    int status;
     struct cache *cc;
     
     if(!inited) {
@@ -289,6 +312,8 @@ enum nss_status _nss_icmp_gethostbyaddr_r(const void *addr, socklen_t len, int a
        addrbuf[rl] = 0;
        close(pfd[0]);
        
+       waitpid(child, &status, 0);
+       
        if((p = strchr(addrbuf, '\n')) == NULL) {
            if(usecache)
                cachenotfound(addr, len, af, nfttl);
@@ -367,3 +392,9 @@ enum nss_status _nss_icmp_gethostbyaddr_r(const void *addr, socklen_t len, int a
     DEBUGP("returning\n");
     return(NSS_STATUS_SUCCESS);
 }
+
+/*
+ * Local Variables:
+ * compile-command: "gcc -shared -Wall -g -o libnss_icmp.so.2 nss-icmp.c"
+ * End:
+ */