aboutsummaryrefslogtreecommitdiffstats
path: root/appl/test/uu_server.c
diff options
context:
space:
mode:
Diffstat (limited to 'appl/test/uu_server.c')
-rw-r--r--appl/test/uu_server.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/appl/test/uu_server.c b/appl/test/uu_server.c
index 43ff5a49c96d..64a2b1279fae 100644
--- a/appl/test/uu_server.c
+++ b/appl/test/uu_server.c
@@ -39,7 +39,7 @@ krb5_context context;
static int
proto (int sock, const char *service)
{
- struct sockaddr_in remote, local;
+ struct sockaddr_storage remote, local;
socklen_t addrlen;
krb5_address remote_addr, local_addr;
krb5_ccache ccache;
@@ -52,25 +52,24 @@ proto (int sock, const char *service)
addrlen = sizeof(local);
if (getsockname (sock, (struct sockaddr *)&local, &addrlen) < 0
- || addrlen != sizeof(local))
+ || addrlen > sizeof(local))
err (1, "getsockname)");
addrlen = sizeof(remote);
if (getpeername (sock, (struct sockaddr *)&remote, &addrlen) < 0
- || addrlen != sizeof(remote))
+ || addrlen > sizeof(remote))
err (1, "getpeername");
status = krb5_auth_con_init (context, &auth_context);
if (status)
krb5_err(context, 1, status, "krb5_auth_con_init");
- local_addr.addr_type = AF_INET;
- local_addr.address.length = sizeof(local.sin_addr);
- local_addr.address.data = &local.sin_addr;
-
- remote_addr.addr_type = AF_INET;
- remote_addr.address.length = sizeof(remote.sin_addr);
- remote_addr.address.data = &remote.sin_addr;
+ status = krb5_sockaddr2address (context, (struct sockaddr *)&local, &local_addr);
+ if (status)
+ krb5_err(context, 1, status, "krb5_sockaddr2address(local)");
+ status = krb5_sockaddr2address (context, (struct sockaddr *)&remote, &remote_addr);
+ if (status)
+ krb5_err(context, 1, status, "krb5_sockaddr2address(remote)");
status = krb5_auth_con_setaddrs (context,
auth_context,
@@ -174,34 +173,11 @@ proto (int sock, const char *service)
static int
doit (int port, const char *service)
{
- int sock, sock2;
- struct sockaddr_in my_addr;
- int one = 1;
-
- sock = socket (AF_INET, SOCK_STREAM, 0);
- if (sock < 0)
- err (1, "socket");
-
- memset (&my_addr, 0, sizeof(my_addr));
- my_addr.sin_family = AF_INET;
- my_addr.sin_port = port;
- my_addr.sin_addr.s_addr = INADDR_ANY;
-
- if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
- (void *)&one, sizeof(one)) < 0)
- warn ("setsockopt SO_REUSEADDR");
-
- if (bind (sock, (struct sockaddr *)&my_addr, sizeof(my_addr)) < 0)
- err (1, "bind");
-
- if (listen (sock, 1) < 0)
- err (1, "listen");
+ rk_socket_t sock;
- sock2 = accept (sock, NULL, NULL);
- if (sock2 < 0)
- err (1, "accept");
+ mini_inetd(port, &sock);
- return proto (sock2, service);
+ return proto(sock, service);
}
int