From: wesommer Date: Wed, 9 Sep 1987 14:59:06 +0000 (+0000) Subject: Allocate a new socket each time rather than keeping one around, X-Git-Tag: BETA5-24-88~53 X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/3004ebdbcb68b84f0b5cce320d62508708da0ef4?hp=4297fecb32cfa679d7611d2adb3274f2dc366393 Allocate a new socket each time rather than keeping one around, due to protocol problems. --- diff --git a/reg_svr/admin_call.c b/reg_svr/admin_call.c index f0359102..8348e2ee 100644 --- a/reg_svr/admin_call.c +++ b/reg_svr/admin_call.c @@ -11,9 +11,13 @@ * Completely gutted and rewritten by Bill Sommerfeld, August 1987 * * $Log$ - * Revision 1.3 1987-09-04 22:30:34 wesommer - * Un-crock the KDC host (oops -- this one got distributed!!). + * Revision 1.4 1987-09-09 14:59:06 wesommer + * Allocate a new socket each time rather than keeping one around, + * due to protocol problems. * + * Revision 1.3 87/09/04 22:30:34 wesommer + * Un-crock the KDC host (oops -- this one got distributed!!). + * * Revision 1.2 87/08/22 17:13:59 wesommer * Make admin_errmsg external rather than static. * Crock up KDC host. @@ -71,8 +75,7 @@ int admin_call_init() if (!inited) { struct hostent *hp; /* host to talk to */ struct servent *sp; /* service to talk to */ - int on = 1; /* ioctl argument */ - + init_kadm_err_tbl(); if (status = get_krbrlm(krbrlm, 1)) { status += krb_err_base; @@ -98,39 +101,6 @@ int admin_call_init() bcopy((char *)hp->h_addr, (char *)&admin_addr.sin_addr, hp->h_length); admin_addr.sin_port = sp->s_port; - /* - * Set up socket. - */ - - admin_fd = socket(hp->h_addrtype, SOCK_DGRAM, 0); - if (admin_fd < 0) { - status = errno; - goto punt; - } - - bzero((char *)&my_addr, sizeof(my_addr)); - - my_addr.sin_family = admin_addr.sin_family; - my_addr.sin_addr.s_addr = gethostid(); - - if (bind(admin_fd, &my_addr, sizeof(my_addr)) < 0) { - status = errno; - goto punt; - } - - my_addr_len = sizeof(my_addr); - - if (getsockname(admin_fd, (struct sockaddr *)&my_addr, - &my_addr_len) < 0) { - status = errno; - goto punt; - } - - if (ioctl(admin_fd, FIONBIO, (char *)&on) < 0) { - status = errno; - goto punt; - } - inited = 1; } return 0; @@ -177,6 +147,8 @@ admin_call(opcode, pname, old_passwd, new_passwd, crypt_passwd) struct sockaddr rec_addr; /* Address we got reply from */ int rec_addr_len; /* Length of that address */ + int on = 1; /* ioctl argument */ + if (!inited) { status = admin_call_init(); @@ -233,6 +205,39 @@ admin_call(opcode, pname, old_passwd, new_passwd, crypt_passwd) goto bad; } + /* + * Set up socket. + */ + + admin_fd = socket(admin_addr.sin_family, SOCK_DGRAM, 0); + if (admin_fd < 0) { + status = errno; + goto bad; + } + + bzero((char *)&my_addr, sizeof(my_addr)); + + my_addr.sin_family = admin_addr.sin_family; + my_addr.sin_addr.s_addr = gethostid(); + + if (bind(admin_fd, &my_addr, sizeof(my_addr)) < 0) { + status = errno; + goto bad; + } + + my_addr_len = sizeof(my_addr); + + if (getsockname(admin_fd, (struct sockaddr *)&my_addr, + &my_addr_len) < 0) { + status = errno; + goto bad; + } + + if (ioctl(admin_fd, FIONBIO, (char *)&on) < 0) { + status = errno; + goto bad; + } + /* * Encrypt the message using the session key. * Since this contains passwords, it must be kept from prying eyes. @@ -383,6 +388,12 @@ bad: bzero((char *)sess_key, sizeof(sess_key)); bzero((char *)sess_sched, sizeof(sess_sched)); bzero(pvt_buf, sizeof(pvt_buf)); + + if (admin_fd >= 0) { + (void) close(admin_fd); + admin_fd = -1; + } + return status; }