fix up usage msg
authorJohn Kohl <jtkohl@mit.edu>
Fri, 8 Mar 1991 16:43:17 +0000 (16:43 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Fri, 8 Mar 1991 16:43:17 +0000 (16:43 +0000)
add init_ets();
check sender addr

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1875 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/simple/server/sim_server.c

index b734531455d63d1d0bd2bd0283dc2bd67edb20ef..a3b383466b57e5fa8ad8f48c08b7581f0c2f5a58 100644 (file)
@@ -59,10 +59,12 @@ char *argv[];
     krb5_tkt_authent *ad;
 
     if (argc != 2) {
-       fprintf(stderr, "usage: %s <hostname>\n",PROGNAME);
+       fprintf(stderr, "usage: %s <servername>\n",PROGNAME);
        exit(1);
     }
 
+    krb5_init_ets();
+
     if (retval = krb5_parse_name(SNAME, &sprinc)) {
        com_err(PROGNAME, retval, "while parsing server name %s", SNAME);
        exit(1);
@@ -108,18 +110,26 @@ char *argv[];
 
     /* GET KRB_AP_REQ MESSAGE */
 
-    i = read(sock, (char *)pktbuf, sizeof(pktbuf));
+    /* use "recvfrom" so we know client's address */
+    i = sizeof(c_sock);
+    i = recvfrom(sock, (char *)pktbuf, sizeof(pktbuf), flags,
+                (struct sockaddr *)&c_sock, &i);
     if (i < 0) {
        perror("receiving datagram");
        exit(1);
     }
+
     printf("Received %d bytes\n", i);
     packet.length = i;
     packet.data = (krb5_pointer) pktbuf;
 
+    foreign_addr.addrtype = c_sock.sin_family;
+    foreign_addr.length = sizeof(c_sock.sin_addr);
+    foreign_addr.contents = (krb5_octet *)&c_sock.sin_addr;
+
     /* Check authentication info */
     if (retval = krb5_rd_req_simple(&packet, sprinc,
-                                   0, /* ignore sender address for now */
+                                   &foreign_addr,
                                    &ad)) {
        com_err(PROGNAME, retval, "while reading request");
        exit(1);