[6785] in Kerberos
solaris 2.4 / getsockname bug
daemon@ATHENA.MIT.EDU (Victor Dmitri Schoeman)
Wed Feb 28 18:39:06 1996
To: kerberos@MIT.EDU
Date: Wed, 28 Feb 1996 18:05:15 -0500
From: Victor Dmitri Schoeman <vs0r+@andrew.cmu.edu>
I was wondering if anyone has compiled kerberos 5b5 on solaris 2.4. As
far as I can tell an error with getsockname() is causing krb5_mk_safe
to fail. Rather than filling out the host's ip address the structure
is filled with all 0s. Thus when a server attempts to verify the
sender's address it fails.
As far as I can tell this is a bug which only seems to affect solaris.
(SunOS 4.1.3 works correctly with this call) Is there a patch for
kerberos that I am currently missing (or one for solaris I suppose).
If not, I'll make my own patch and send it in to krb5-bugs to see if
they'll include it as a workaround (or at least mention of it) in the
documentation since it took me a couple of days to track down and
prove what was happening.
I've isolated the incorrect behavior in the following program - which
fairly closely models the calls kerberos uses to get the ip address.
Under SunOS 4.1.3 it prints out the ip address. Under Solaris 2.4 it
prints out all 0s. (Even if I take the binary from SunOS and move it
to Solaris, it still prints out all 0s)
Thanks,
Dmitri
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
main()
{
int sockfd;
struct sockaddr_in cli_addr, serv_addr;
int i;
memset((char *) &serv_addr,0,sizeof(serv_addr));
serv_addr.sin_family=AF_INET;
serv_addr.sin_addr.s_addr=inet_addr("155.157.99.46");
serv_addr.sin_port = htons(6543);
if((sockfd = socket(AF_INET, SOCK_DGRAM, 0))<0)
{
printf("couldn't assign sock\n");
return;
}
memset((char *) &cli_addr,0,sizeof(cli_addr));
cli_addr.sin_family=AF_INET;
if(bind(sockfd, (struct sockaddr *) &cli_addr, sizeof(cli_addr))<0)
{
printf("in bind\n");
return;
}
if(connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr))==-1)
{
printf("couldn't connect");
return;
}
memset((char *) &cli_addr,0,sizeof(cli_addr));
i=sizeof(cli_addr);
if(getsockname(sockfd, (struct sockaddr *) &cli_addr,&i)<0)
{
printf("couldn't getsockname");
return;
}
printf("hostip = %d.%d.%d.%d\n",cli_addr.sin_addr.S_un.S_un_b.s_b1,
cli_addr.sin_addr.S_un.S_un_b.s_b2,
cli_addr.sin_addr.S_un.S_un_b.s_b3,
cli_addr.sin_addr.S_un.S_un_b.s_b4);
}