aboutsummaryrefslogtreecommitdiff
path: root/src/appl/simple/client/sim_client.c
diff options
context:
space:
mode:
authorJohn Kohl <jtkohl@mit.edu>1991-04-19 13:13:03 +0000
committerJohn Kohl <jtkohl@mit.edu>1991-04-19 13:13:03 +0000
commit5f4bf38461276ea4af45b537a168c5fe1e471784 (patch)
tree452981001823ffcc0c741161d04ea684faffd243 /src/appl/simple/client/sim_client.c
parent1469a41fe87019a445464ce732854938823687be (diff)
downloadkrb5-5f4bf38461276ea4af45b537a168c5fe1e471784.zip
krb5-5f4bf38461276ea4af45b537a168c5fe1e471784.tar.gz
krb5-5f4bf38461276ea4af45b537a168c5fe1e471784.tar.bz2
(a) connect the socket so getsockname() works properly
(b) clean up some error messages git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1996 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/appl/simple/client/sim_client.c')
-rw-r--r--src/appl/simple/client/sim_client.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/appl/simple/client/sim_client.c b/src/appl/simple/client/sim_client.c
index ef67c15..4430940 100644
--- a/src/appl/simple/client/sim_client.c
+++ b/src/appl/simple/client/sim_client.c
@@ -130,8 +130,8 @@ char *argv[];
printf("Local Kerberos realm is %s\n", c_realm);
/* Get Kerberos realm of host */
- if (retval = krb5_get_host_realm(HOST, &s_realms)) {
- com_err(PROGNAME, retval, "while getting realm for '%s'", HOST);
+ if (retval = krb5_get_host_realm(full_hname, &s_realms)) {
+ com_err(PROGNAME, retval, "while getting realm for '%s'", full_hname);
exit(1);
}
#ifdef DEBUG
@@ -192,9 +192,15 @@ char *argv[];
}
printf("Got credentials for %s.\n", SERVICE);
+ /* "connect" the datagram socket; this is necessary to get a local address
+ properly bound for getsockname() below. */
+
+ if (connect(sock, (struct sockaddr *)&s_sock, sizeof(s_sock)) == -1) {
+ com_err(PROGNAME, errno, "while connecting to server");
+ exit(1);
+ }
/* Send authentication info to server */
- i = sendto(sock, (char *)packet.data, packet.length, flags,
- (struct sockaddr *)&s_sock, sizeof(s_sock));
+ i = send(sock, (char *)packet.data, packet.length, flags);
if (i < 0)
com_err(PROGNAME, errno, "while sending KRB_AP_REQ message");
printf("Sent authentication data: %d bytes\n", i);
@@ -279,13 +285,10 @@ char *argv[];
}
/* Send it */
- i = sendto(sock, (char *)packet.data, packet.length, flags,
- (struct sockaddr *)&s_sock, sizeof(s_sock));
+ i = send(sock, (char *)packet.data, packet.length, flags);
if (i < 0)
com_err(PROGNAME, errno, "while sending SAFE message");
printf("Sent checksummed message: %d bytes\n", i);
- if (i < 0)
- perror("sending safe message");
xfree(packet.data);
/* PREPARE KRB_PRIV MESSAGE */
@@ -306,8 +309,8 @@ char *argv[];
}
/* Send it */
- i = sendto(sock, (char *)packet.data, packet.length, flags,
- (struct sockaddr *)&s_sock, sizeof(s_sock));
+ i = send(sock, (char *)packet.data, packet.length, flags);
+
if (i < 0)
com_err(PROGNAME, errno, "while sending PRIV message");
printf("Sent encrypted message: %d bytes\n", i);