X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/718bc25cabe5cfcf45ecae449a1ab3bbdd1fab09..55534a8784fbd98de52aff854618374d0abdba51:/reg_svr/admin_call.c diff --git a/reg_svr/admin_call.c b/reg_svr/admin_call.c index 67d01d3f..8348e2ee 100644 --- a/reg_svr/admin_call.c +++ b/reg_svr/admin_call.c @@ -11,9 +11,20 @@ * Completely gutted and rewritten by Bill Sommerfeld, August 1987 * * $Log$ - * Revision 1.1 1987-08-07 13:50:37 wesommer - * Initial revision + * 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. + * + * Revision 1.1 87/08/07 13:50:37 wesommer + * Initial revision + * */ #ifndef lint @@ -51,7 +62,7 @@ static struct sockaddr_in my_addr; /* address bound to admin_fd. */ static int my_addr_len; /* size of above address. */ static char krbrlm[REALM_SZ]; /* Local kerberos realm */ -static char admin_errmsg[BUFSIZ]; /* Server error message */ +char admin_errmsg[BUFSIZ]; /* Server error message */ /* * Initialize socket, etc. to use to talk to admin_server. @@ -64,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; @@ -91,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; @@ -170,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(); @@ -226,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. @@ -376,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; }