Package: xinetd
Version: 1:2.3.14-7
Severity: important
Tags: upstream ipv6
I have written the following simple server, that sends to the client the address
of the client itself.
It can work as stand-alone and with xinetd (by passing some random argument on
its
command line).
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void write_client_addr(int fd) {
struct sockaddr_in6 addr;//Local and remote address
socklen_t addr_l=sizeof(struct sockaddr_in6);
char addrbuff[256];
char outputbuff[256];
int outputsize;
getpeername(fd, (struct sockaddr *)&addr, &addr_l);
inet_ntop(AF_INET6, &addr.sin6_addr, addrbuff, INET6_ADDRSTRLEN);
outputsize=snprintf(outputbuff,256,"Your address is %s\n",addrbuff);
write(fd,outputbuff,outputsize);
}
int main(int argc, char *argv[]) {
int client_fd=0;
if (argc==1) {
unsigned short int port=1942;
struct sockaddr_in6 locAddr,farAddr; //Local and remote address
socklen_t ipAddrL,farAddrL;
int s = socket(PF_INET6, SOCK_STREAM, 0);
//Makes port reusable immediately after termination.
int val = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
farAddrL= ipAddrL = sizeof(struct sockaddr_in6);
//Bind
memset(&locAddr, 0, sizeof(locAddr));
locAddr.sin6_family = AF_INET6;
locAddr.sin6_port = htons(port);
locAddr.sin6_addr = in6addr_any;
bind(s, (struct sockaddr *) &locAddr, sizeof(locAddr));
listen(s, 10); //Listen to the socket
client_fd=accept(s, (struct sockaddr *) &farAddr, &farAddrL);
}
write_client_addr(client_fd);
}
If i compile and run that code, and i issue
$ ncat -6 ::ffff:127.0.0.1 1942
The result is:
Your address is ::ffff:127.0.0.1
as expected. It also works connecting to ::1.
Now let's see what happens using it with xinetd:
service www
{
socket_type = stream
wait = no
instances = 5
server = /tmp/a.out
server_args = -T
port = 80
cps = 100 4
flags = IPv6
}
Running:
# ncat -6 ip6-localhost 80
Your address is ::1
And this works.. but running:
# ncat -6 ::ffff:127.0.0.1 80
Your address is ::1036:905a:ff7f:0
And the result changes everytime.
I've flagged this bug as important because my real-life problem allows or
denies access basing on the IP address
so it is not so convenient for me that it happens to be a random number.
Using only IPv4 will work fine.
Bye
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'experimental'), (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.35.7-calipso (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages xinetd depends on:
ii libc6 2.11.2-6 Embedded GNU C Library: Shared lib
ii libwrap0 7.6.q-19 Wietse Venema's TCP wrappers libra
ii netbase 4.43 Basic TCP/IP networking system
ii update-inetd 4.38 inetd configuration file updater
Versions of packages xinetd recommends:
ii logrotate 3.7.8-6 Log rotation utility
ii rsyslog [system-log-daemon] 4.6.4-1 enhanced multi-threaded syslogd
xinetd suggests no packages.
-- no debconf information
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]