diff options
| author | Epoch Qwert <epoch@53flpnlls43fcguy.onion> | 2014-12-30 07:25:39 -0600 | 
|---|---|---|
| committer | Epoch Qwert <epoch@53flpnlls43fcguy.onion> | 2014-12-30 07:25:39 -0600 | 
| commit | 86ba931697790d4da2515f4457ebfb3f20b43860 (patch) | |
| tree | 839c1f7ae94fd32639d3311c3a2faee34f88f04c | |
| parent | 05d677a3d3e9e540dffd35c76e35335bf43ead7d (diff) | |
| download | misc-86ba931697790d4da2515f4457ebfb3f20b43860.tar.gz misc-86ba931697790d4da2515f4457ebfb3f20b43860.zip  | |
all those .c changes were mostly fixes of warnings for the change in rebuild.sh being changed to use -Wall.
gethostbyname was almost completely rewritten to work better with ipv6 for gopherd.sh
gopherd.sh was rewritten to use gethostbyname instead of dig and to cut out any link-local interface indicators from the output of hop0 and to ignore an error if ipA -> hostname -> ipB causes ipA to be not the same as ipB.
Don't remember if there's anything else.
| -rwxr-xr-x | nocompile/libexec/gopherd.sh | 31 | ||||
| -rwxr-xr-x | rebuild.sh | 2 | ||||
| -rw-r--r-- | src/bin/dcchelper.c | 2 | ||||
| -rw-r--r-- | src/bin/gethostbyname.c | 32 | ||||
| -rw-r--r-- | src/bin/ipconvert.c | 2 | ||||
| -rw-r--r-- | src/bin/pad.c | 1 | ||||
| -rw-r--r-- | src/bin/rrd.c | 16 | ||||
| -rw-r--r-- | src/bin/speed.c | 1 | ||||
| -rw-r--r-- | src/libexec/deddos.c | 8 | ||||
| -rw-r--r-- | src/libexec/httpd.c | 2 | ||||
| -rw-r--r-- | src/libexec/peerip.c | 12 | 
11 files changed, 57 insertions, 52 deletions
diff --git a/nocompile/libexec/gopherd.sh b/nocompile/libexec/gopherd.sh index 130d861..3b44296 100755 --- a/nocompile/libexec/gopherd.sh +++ b/nocompile/libexec/gopherd.sh @@ -12,7 +12,9 @@ export PATH=$PATH:/usr/local/bin  read -t 10 req  base="$1"  arg=$(echo "$req" | tr -d '\r' | cut -f2) -req=$(echo "$req" | tr -d '\r' | cut -f1) +#req=$(echo "$req" | unescape | tr -d '\r' | cut -f1) +req=$(echo "$req" | tr -d '\r' | sed 's/\/*$//' | cut -f1) +cd ${base}  realpath="$(normalpath "${base}${req}")"  if grep -v "^${base}" <<< "${realpath}" > /dev/null;then   echo -e 'i'${base}'\tasdf\tasdf\tasdf\r' @@ -20,18 +22,23 @@ if grep -v "^${base}" <<< "${realpath}" > /dev/null;then   echo -e 'ierror!!! cant find base in realpath\tasdf\tasdf\tasdf\r'   exit 1  fi -myIP=$(hop0 $(/usr/local/libexec/peerip | head -n1)) +myIP=$(hop0 $(/usr/local/libexec/peerip | head -n1) | cut -d% -f1)  hostname=$(rdns ${myIP})  if [ ! "${hostname}" ]; then   hostname=${myIP}  else   if strstr "${myIP}" ":";then -  if [ $(dig -t AAAA +short $hostname) != ${myIP} ];then -   logger "hostname (${hostname}) and IP (${myIP}) aren't matching up."; -   exit 2 +  if [ $(gethostbyname $hostname 6) != ${myIP} ];then +   printf "" +#   echo "fucked off #1" +#   echo "$myIP != $(gethostbyname $hostname 6)" +#   logger "hostname (${hostname}) and IP (${myIP}) aren't matching up."; +#   exit 2 +#jimmy cracked corn but nobody gives a shit.    fi   else -  if [ $(dig -t A +short $hostname) != ${myIP} ];then +  if [ $(gethostbyname $hostname) != ${myIP} ];then +   echo "fucked off #2"     logger "hostname (${hostname}) and IP (${myIP}) aren't matching up.";     exit 2    fi @@ -47,25 +54,25 @@ if strstr "$type" "directory";then   ls "${realpath}" | while read i;do    stype=$(file -L "${realpath}/${i}" | cut -d: -f2-)    if strstr "$stype" "directory"; then -   printf "1%s\t%s\t%s\t%s\r\n" "${req}/${i}" "${req}/${i}" $hostname $port +   printf "1%s\t%s\t%s\t%s\r\n" "${i}" "${req}/${i}" $hostname $port    else -   if [ "_$(stat -L "${realpath}/${i}" | grep -v l | cut '-d ' -f3 | tr 'x' '\n' | wc -l | tr -d ' ')" = "_4" ] ;then -    printf "7%s\t%s\t%s\t%s\r\n" "${req}/${i}" "${req}/${i}" $hostname $port +   if [ "_$(stat -L "${realpath}/${i}" | cut '-d ' -f3 | grep -v l | tr 'x' '\n' | wc -l | tr -d ' ')" = "_4" ] ;then +    printf "7%s\t%s\t%s\t%s\r\n" "${i}" "${req}/${i}" $hostname $port     else -    printf "0%s\t%s\t%s\t%s\r\n" "${req}/${i}" "${req}/${i}" $hostname $port +    printf "0%s\t%s\t%s\t%s\r\n" "${i}" "${req}/${i}" $hostname $port     fi    fi   done   printf ".\r\n"  else  #this shit is ugly - numX="$(stat -L "${realpath}" | grep -v l | cut '-d ' -f3 | tr 'x' '\n' | wc -l | tr -d ' ')" + numX="$(stat -L "${realpath}" | cut '-d ' -f3 | grep -v l | tr 'x' '\n' | wc -l | tr -d ' ')"   if [ "_$numX" = "_3" ];then    #an executable that outputs text and pretends to be a type 0.    "${realpath}"   elif [ "_$numX" = "_4" ];then    #a type 7 -  "${realpath}" $arg | sed "s/\$/"`printf "\r"`"/g" +  "${realpath}" "$arg" | sed "s/\$/"`printf "\r"`"/g"   else    #output the text of the file    cat "${realpath}" @@ -8,7 +8,7 @@ for i in src/*;do   mkdir -p $iout   for j in $i/*.c;do    jout=$(basename $j | cut -d. -f1) -  gcc -o $iout/$jout $j +  gcc -Wall -o $iout/$jout $j   done   cp $iout/* /usr/local/$iout/  done diff --git a/src/bin/dcchelper.c b/src/bin/dcchelper.c index bf8f28b..50009aa 100644 --- a/src/bin/dcchelper.c +++ b/src/bin/dcchelper.c @@ -1,4 +1,6 @@  #include <stdio.h> +#include <string.h> +#include <arpa/inet.h>  int main(int argc,char *argv[]) {   char *wanip; diff --git a/src/bin/gethostbyname.c b/src/bin/gethostbyname.c index b670b1e..a63f540 100644 --- a/src/bin/gethostbyname.c +++ b/src/bin/gethostbyname.c @@ -2,23 +2,25 @@  #include <netdb.h>  #include <arpa/inet.h> +#define SILLYLIMIT 256 +  int main(int argc,char *argv[]) { - int i; - if(argc < 2) return 1; - char *addr; + char buf[SILLYLIMIT];   struct in_addr saddr; - if(inet_aton(argv[1],&saddr)) -  addr=inet_ntoa(saddr); - else -  addr=argv[1]; - struct hostent *he=gethostbyname(addr); - - for(i=0;he->h_addr_list[i];i++) { -  printf("%u.%u.%u.%u\n", -         (unsigned char)he->h_addr_list[i][0], -         (unsigned char)he->h_addr_list[i][1], -         (unsigned char)he->h_addr_list[i][2], -         (unsigned char)he->h_addr_list[i][3]); + struct in6_addr saddr6; + struct hostent *he; + if(argc<2) return 1; + if(!(he=gethostbyname2( +   argc<3 +   ?inet_aton(argv[1],&saddr) +     ?inet_ntoa(saddr) +     :argv[1] +   :inet_pton(AF_INET6,argv[1],&saddr6) +     ?inet_ntop(AF_INET6,&saddr6,buf,SILLYLIMIT) //no point, but whatever +     :argv[1] +  ,argc<3?AF_INET:AF_INET6))) return 1; + for(;*(he->h_addr_list);he->h_addr_list++) { +  printf("%s\n",inet_ntop(argc<3?AF_INET:AF_INET6,*(he->h_addr_list),buf,SILLYLIMIT));   }   return 0;  } diff --git a/src/bin/ipconvert.c b/src/bin/ipconvert.c index 5420e27..d106d13 100644 --- a/src/bin/ipconvert.c +++ b/src/bin/ipconvert.c @@ -1,8 +1,10 @@  #include <stdio.h> +#include <arpa/inet.h>  int main(int argc,char *argv[]) {   int addr=inet_addr(argv[1]);   printf("%x\n",htonl(addr));   printf("%u\n",htonl(addr));   printf("%u.%u.%u.%u\n",addr&255,addr>>8&255,addr>>16&255,addr>>24&255); + return 0;  } diff --git a/src/bin/pad.c b/src/bin/pad.c index 2f2ea13..f520de3 100644 --- a/src/bin/pad.c +++ b/src/bin/pad.c @@ -1,5 +1,6 @@  #include <stdio.h>  #include <string.h> +#include <stdlib.h>  int main(int argc,char *argv[]) {   short in; diff --git a/src/bin/rrd.c b/src/bin/rrd.c index 1b43426..067fede 100644 --- a/src/bin/rrd.c +++ b/src/bin/rrd.c @@ -2,7 +2,6 @@  #include <stdlib.h>  #include <sys/sysctl.h>  #include <net/route.h> -  #include <sys/socket.h>  #include <netinet/in.h> @@ -11,7 +10,7 @@ mostly ripped. just outputs routes from KRT on NetBSD.  used to look closer at a difference of output from route and netstat.  */ -get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) +void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info)  {          int     i; @@ -29,7 +28,7 @@ get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info)  void print_sa6(struct sockaddr *sa) {   int i=0;   struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa; - struct in6_addr *in6 = &sa6->sin6_addr; + struct in6_addr *in6 = &(sa6->sin6_addr);   if(sa) {    for(i=0;i<16;i++) {     printf("%02x",(unsigned char)in6->s6_addr[i]); @@ -44,11 +43,10 @@ void print_sa6(struct sockaddr *sa) {  }  void p_rtentry(struct rt_msghdr *rtm) { - struct sockadrr *sa = (rtm+1); + struct sockadrr *sa; + sa = (struct sockaddr *)(rtm+1);   struct sockaddr *rti_info[RTAX_MAX]; - struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa; - struct in6_addr *in6 = &sa6->sin6_addr; - get_rtaddrs(rtm->rtm_addrs, sa, rti_info); + get_rtaddrs(rtm->rtm_addrs, (struct sockaddr *)sa, rti_info);   printf("addr: ");   print_sa6(rti_info[RTAX_DST]); @@ -62,7 +60,7 @@ void p_rtentry(struct rt_msghdr *rtm) {  int main() {  //     sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp,   //            const void *newp, size_t newlen); - int needed; + unsigned int needed;          struct rt_msghdr *rtm;          struct sockaddr *sa;   char *buf,*next,*lim; @@ -88,5 +86,5 @@ int main() {                  free(buf);                  buf = NULL;          } - + return 0;  } diff --git a/src/bin/speed.c b/src/bin/speed.c index 3b8cc72..9fd373e 100644 --- a/src/bin/speed.c +++ b/src/bin/speed.c @@ -1,3 +1,4 @@ +#include <unistd.h>  #include <stdio.h>  #include <signal.h> diff --git a/src/libexec/deddos.c b/src/libexec/deddos.c index 245ba41..0af7414 100644 --- a/src/libexec/deddos.c +++ b/src/libexec/deddos.c @@ -1,4 +1,4 @@ - +#include <unistd.h>  #include <stdio.h>  #include <stdlib.h>  #include <sys/socket.h> @@ -13,11 +13,9 @@ int main(int argc,char *argv[]) {   struct sockaddr sa;   signal(SIGALRM,exit);   alarm(10); - int sl=sizeof(sa); + unsigned int sl=sizeof(sa);   char host[256];   char serv[256]; - char cmd[256]; - char line[256];   char iface[256];   char *name[16];   getpeername(0,&sa,&sl); @@ -49,5 +47,5 @@ int main(int argc,char *argv[]) {   name[8]="UDP";   name[9]=0;   execv(name[0],name); - printf("shit fucked.\n"); + return printf("shit fucked.\n");  } diff --git a/src/libexec/httpd.c b/src/libexec/httpd.c index 22d9b2b..812e051 100644 --- a/src/libexec/httpd.c +++ b/src/libexec/httpd.c @@ -4,6 +4,7 @@  #include <fcntl.h>  #include <unistd.h>  #include <syslog.h> +#include <sys/wait.h>  #define VHOST_ROOT "/var/www/vhosts"  #define SITES_ROOT "/var/www/sites" @@ -19,7 +20,6 @@ int main(int argc,char *argv[]) {   int fd;   char *name[10];   int s,n; - short in;   char *method;   char *page;   char *version; diff --git a/src/libexec/peerip.c b/src/libexec/peerip.c index 6bcf1f1..43d64d0 100644 --- a/src/libexec/peerip.c +++ b/src/libexec/peerip.c @@ -4,17 +4,11 @@  #include <netinet/in.h>  int main(int argc,char *argv[]) { - int i;   struct sockaddr_in6 sa6; - int err; - int sl=sizeof(sa6); + unsigned int sl=sizeof(sa6);   char h[NI_MAXHOST], s[NI_MAXSERV]; - if(getpeername(0,(struct sockaddr *)&sa6,&sl) == -1) { -  return 1; - } - if(err=getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),s,sizeof(s),NI_NUMERICHOST|NI_NUMERICSERV)) { -  return 2; - } + if(getpeername(0,(struct sockaddr *)&sa6,&sl) == -1) return 1; + if(getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),s,sizeof(s),NI_NUMERICHOST|NI_NUMERICSERV)) return 2;   puts(h);   puts(s);   return 0;  | 
