* 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.
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;
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;
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();
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.
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;
}