diff -urN chillispot-1.1.0.original/config.h.in chillispot-1.1.0/config.h.in --- chillispot-1.1.0.original/config.h.in Sun Sep 24 20:34:53 2006 +++ chillispot-1.1.0/config.h.in Thu Oct 12 03:33:29 2006 @@ -52,6 +52,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `clearenv' function. */ +#undef HAVE_CLEARENV + /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP diff -urN chillispot-1.1.0.original/src/chilli.c chillispot-1.1.0/src/chilli.c --- chillispot-1.1.0.original/src/chilli.c Sun Sep 24 18:48:25 2006 +++ chillispot-1.1.0/src/chilli.c Thu Oct 12 03:33:56 2006 @@ -284,11 +284,21 @@ return 0; } +#ifdef HAVE_CLEARENV if (clearenv() != 0) { sys_err(LOG_ERR, __FILE__, __LINE__, errno, "clearenv() did not return 0!"); exit(0); } +#else + extern char **environ; + environ[0] = NULL; + if (environ[0] != NULL) { + sys_err(LOG_ERR, __FILE__, __LINE__, errno, + "Venture37 doesn't know what he's doing!!!"); + exit(0); + } +#endif set_env("DEV", tun->devname, 0, NULL, NULL, NULL); set_env("NET", NULL, 0, &appconn->net, NULL, NULL); diff -urN chillispot-1.1.0.original/src/tun.c chillispot-1.1.0/src/tun.c --- chillispot-1.1.0.original/src/tun.c Sun Sep 24 18:48:25 2006 +++ chillispot-1.1.0/src/tun.c Thu Oct 12 03:33:45 2006 @@ -366,7 +366,7 @@ this->addrs++; return 0; -#elif defined (__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) +#elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) int fd; struct ifaliasreq areq; @@ -445,7 +445,7 @@ #if defined(__linux__) ifr.ifr_netmask.sa_family = AF_INET; -#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) +#elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) ((struct sockaddr_in *) &ifr.ifr_addr)->sin_len = sizeof (struct sockaddr_in); ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_len = @@ -497,7 +497,7 @@ ((struct sockaddr_in *) &ifr.ifr_netmask)->sin_addr.s_addr = netmask->s_addr; -#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) +#elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = netmask->s_addr; @@ -526,7 +526,7 @@ tun_sifflags(this, IFF_UP | IFF_RUNNING); -#if defined(__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) +#if defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) tun_addroute(this, dstaddr, addr, netmask); this->routes = 1; #endif @@ -585,7 +585,7 @@ close(fd); return 0; -#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) +#elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) struct { struct rt_msghdr rt; @@ -674,7 +674,7 @@ #if defined(__linux__) struct ifreq ifr; -#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) +#elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) char devname[IFNAMSIZ+5]; /* "/dev/" + ifname */ int devnum; struct ifaliasreq areq; @@ -722,7 +722,7 @@ ioctl((*tun)->fd, TUNSETNOCSUM, 1); /* Disable checksums */ return 0; -#elif defined(__FreeBSD__) defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) +#elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) /* Find suitable device */ for (devnum = 0; devnum < 255; devnum++) { /* TODO 255 */ @@ -854,7 +854,7 @@ int tun_decaps(struct tun_t *this) { -#if defined(__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) +#if defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__APPLE__) unsigned char buffer[PACKET_MAX]; int status; @@ -910,7 +910,7 @@ return write(tun->fd, buffer, len+4); -#elif defined(__linux__) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__APPLE__) +#elif defined (__linux__) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__APPLE__) return write(tun->fd, pack, len); @@ -951,11 +951,21 @@ return 0; } +#ifdef HAVE_CLEARENV if (clearenv() != 0) { sys_err(LOG_ERR, __FILE__, __LINE__, errno, "clearenv() did not return 0!"); exit(0); } +#else + extern char **environ; + environ[0] = NULL; + if (environ[0] != NULL) { + sys_err(LOG_ERR, __FILE__, __LINE__, errno, + "Venture37 doesn't know what he's doing!!!"); + exit(0); + } +#endif if (setenv("DEV", tun->devname, 1) != 0) { sys_err(LOG_ERR, __FILE__, __LINE__, errno,