diff options
author | epochqwert <epoch@hacking.allowed.org> | 2015-07-04 08:39:28 -0500 |
---|---|---|
committer | epochqwert <epoch@hacking.allowed.org> | 2015-07-04 08:39:28 -0500 |
commit | b6a347373a6c933a457ed588e3ce9c6b5178d8ba (patch) | |
tree | 5a78389e7a3c10c8bd93da7fe807ab1b6644e6fd /src | |
parent | 75f05369650cc05002b9c131a8453714dcf14dde (diff) | |
download | misc-b6a347373a6c933a457ed588e3ce9c6b5178d8ba.tar.gz misc-b6a347373a6c933a457ed588e3ce9c6b5178d8ba.zip |
don't remember except for greed.sh
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/great.c | 31 | ||||
-rw-r--r-- | src/libexec/httpd.c | 10 |
2 files changed, 13 insertions, 28 deletions
diff --git a/src/bin/great.c b/src/bin/great.c index 9a554fc..f3bae17 100644 --- a/src/bin/great.c +++ b/src/bin/great.c @@ -16,14 +16,13 @@ int main(int argc,char *argv[]) { struct sockaddr_in from; char in; socklen_t sl=sizeof(struct sockaddr_in); - int so_link=socket(AF_LINK,SOCK_DGRAM,0); int so_inet=socket(AF_INET,SOCK_DGRAM,0); int so=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP); memset(&sa,0,(size_t)sizeof(struct sockaddr_in)); memset(&from,0,(size_t)sizeof(struct sockaddr_in)); if(argc < 4) { - printf("usage: %s interface address port",argv[0]); - printf("example: %s gre0 192.168.0.2 1013",argv[0]); + printf("usage: %s interface address port\n",argv[0]); + printf("example: %s gre0 192.168.0.2 1013\n",argv[0]); return 1; } sa.sin_addr.s_addr=inet_addr(argv[2]); @@ -35,26 +34,14 @@ int main(int argc,char *argv[]) { printf("setting remote end to %s:%d\n",inet_ntoa(addr),ntohs(from.sin_port)); connect(so,(struct sockaddr *)&from,sl); -//name this stuff better and test if it needs to be refilled each time. - struct ifreq *asdf; - asdf=malloc(sizeof(struct ifreq)); + struct ifreq *data; + data=malloc(sizeof(struct ifreq)); - memset(asdf,0,sizeof(struct ifreq)); - strcpy(asdf->ifr_name,argv[1]); - printf("destroy: %d\n",ioctl(so_link,SIOCIFDESTROY,asdf));//destroy + memset(data,0,sizeof(struct ifreq)); + strcpy(data->ifr_name,argv[1]); + data->ifr_value=so; + printf("gressock: %d\n",ioctl(so_inet,GRESSOCK,data));//set socket - memset(asdf,0,sizeof(struct ifreq)); - strcpy(asdf->ifr_name,argv[1]); - printf("create: %d\n",ioctl(so_link,SIOCIFCREATE,asdf));//create - - memset(asdf,0,sizeof(struct ifreq)); - strcpy(asdf->ifr_name,argv[1]); - asdf->ifr_flags=IPPROTO_UDP; - printf("proto: %d\n",ioctl(so_link,GRESPROTO,asdf));//link0 link2 - - memset(asdf,0,sizeof(struct ifreq)); - strcpy(asdf->ifr_name,argv[1]); - asdf->ifr_value=so; - printf("gressock: %d\n",ioctl(so_inet,GRESSOCK,asdf));//set socket + free(data); return 0; } diff --git a/src/libexec/httpd.c b/src/libexec/httpd.c index d6e99ba..2840ce2 100644 --- a/src/libexec/httpd.c +++ b/src/libexec/httpd.c @@ -72,16 +72,14 @@ int main(int argc,char *argv[]) { if(getpeername(0,(struct sockaddr *)&sa6,&sl) == -1) syslog(LOG_WARNING,"getpeername: %m"); + getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),p,sizeof(p),NI_NUMERICHOST|NI_NUMERICSERV); - if((pwd=getpwuid(getuid()))) { - setenv("USER",pwd->pw_name,1); - } - if(gethostname(h,NI_MAXHOST) != -1) { - setenv("HOST",h,1); - } setenv("REMOTE_ADDR",h,1); setenv("REMOTE_PORT",p,1); + if((pwd=getpwuid(getuid()))) setenv("USER",pwd->pw_name,1); + if(gethostname(h,NI_MAXHOST) != -1) setenv("HOST",h,1); + if(getsockname(0,(struct sockaddr *)&sa6,&sl) == -1) syslog(LOG_WARNING,"getsockname: %m"); getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),p,sizeof(p),NI_NUMERICHOST|NI_NUMERICSERV); |