[912] in Kerberos-V5-bugs
Re: KDC should allow port to be specified on the command line
daemon@ATHENA.MIT.EDU (Barry Jaspan)
Fri Oct 28 15:31:39 1994
Date: Fri, 28 Oct 94 15:33:30 EDT
From: "Barry Jaspan" <bjaspan@cam.ov.com>
To: krb5-bugs@MIT.EDU
There was a bug in the patch to network.c that we submitted on 2 Sep
1994. The variable primary_port was declared extern int instead of
extern short and the code path did not properly create the socket if
primary_port was specified. The patch below fixes the problem and
*replaces* the earlier patch. If you need a patch relative to the
earlier patch (because you've already applied it and other changes)
we can provide one.
Barry Jaspan, bjaspan@cam.ov.com
--- snip snip ---
*** network.c 1994/05/20 02:34:44 1.3
--- network.c 1994/10/13 17:42:35
***************
*** 1,6 ****
/*
* $Source: /afs/gza.com/product/secure/src/krb5/kdc/RCS/network.c,v $
! * $Author: jik $
*
* Copyright 1990 by the Massachusetts Institute of Technology.
*
--- 1,6 ----
/*
* $Source: /afs/gza.com/product/secure/src/krb5/kdc/RCS/network.c,v $
! * $Author: bjaspan $
*
* Copyright 1990 by the Massachusetts Institute of Technology.
*
***************
*** 26,32 ****
#if !defined(lint) && !defined(SABER)
static char rcsid_network_c[] =
! "$Id: network.c,v 1.3 1994/05/20 02:34:44 jik Exp $";
#endif /* !lint & !SABER */
#include <krb5/copyright.h>
--- 26,32 ----
#if !defined(lint) && !defined(SABER)
static char rcsid_network_c[] =
! "$Id: network.c,v 1.5 1994/10/13 17:42:34 bjaspan Exp $";
#endif /* !lint & !SABER */
#include <krb5/copyright.h>
***************
*** 51,56 ****
--- 51,57 ----
extern char *krb5_kdc_udp_portname;
extern char *krb5_kdc_sec_udp_portname;
extern int errno;
+ extern short primary_port;
static int udp_port_fd = -1;
static int sec_udp_port_fd = -1;
***************
*** 67,88 ****
FD_ZERO(&select_fds);
select_nfsd = 0;
! sp = getservbyname(krb5_kdc_udp_portname, "udp");
! if (!sp) {
! com_err(prog, 0, "%s/udp service unknown\n",
! krb5_kdc_udp_portname);
! return KDC5_NOPORT;
}
if ((udp_port_fd = socket(PF_INET, SOCK_DGRAM, 0)) == -1) {
! retval = errno;
! com_err(prog, 0, "Cannot create server socket");
! return retval;
}
! memset((char *)&sin, 0, sizeof(sin));
! sin.sin_port = sp->s_port;
if (bind(udp_port_fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
retval = errno;
! com_err(prog, 0, "Cannot bind server socket");
return retval;
}
FD_SET(udp_port_fd, &select_fds);
--- 68,98 ----
FD_ZERO(&select_fds);
select_nfsd = 0;
! memset((char *)&sin, 0, sizeof(sin));
! if (primary_port) {
! com_err(prog, 0, "using exiting primary port %d", primary_port);
! sin.sin_port = htons(primary_port);
! }
! else {
! sp = getservbyname(krb5_kdc_udp_portname, "udp");
! if (!sp) {
! com_err(prog, 0, "%s/udp service unknown\n",
! krb5_kdc_udp_portname);
! return KDC5_NOPORT;
! }
! sin.sin_port = sp->s_port;
}
+
if ((udp_port_fd = socket(PF_INET, SOCK_DGRAM, 0)) == -1) {
! retval = errno;
! com_err(prog, 0, "Cannot create server socket");
! return retval;
}
! com_err(prog, 0, "creating server socket %d", udp_port_fd);
!
if (bind(udp_port_fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
retval = errno;
! com_err(prog, 0, "Cannot bind server socket to fd %d", udp_port_fd);
return retval;
}
FD_SET(udp_port_fd, &select_fds);