]> andersk Git - moira.git/commitdiff
Allocate a new socket each time rather than keeping one around,
authorwesommer <wesommer>
Wed, 9 Sep 1987 14:59:06 +0000 (14:59 +0000)
committerwesommer <wesommer>
Wed, 9 Sep 1987 14:59:06 +0000 (14:59 +0000)
due to protocol problems.

reg_svr/admin_call.c

index f0359102f559fde6e2b08d23f1da6cf09ce12daf..8348e2ee848efd0e2a6bc7319644b6c3865d6571 100644 (file)
  *     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;
 }
 
This page took 0.068854 seconds and 5 git commands to generate.