diff options
author | Sam Hartman <hartmans@mit.edu> | 2011-08-09 20:07:39 +0000 |
---|---|---|
committer | Sam Hartman <hartmans@mit.edu> | 2011-08-09 20:07:39 +0000 |
commit | 1342ba2c1a140ed9d68303c5f8d15d3d87a23022 (patch) | |
tree | ce475a3260d17c905715ebfab84fd54a07e0c1a5 /src/appl | |
parent | fee13cf6ecf3bbc5290a7c13bc93ab1132cbaca4 (diff) | |
download | krb5-1342ba2c1a140ed9d68303c5f8d15d3d87a23022.zip krb5-1342ba2c1a140ed9d68303c5f8d15d3d87a23022.tar.gz krb5-1342ba2c1a140ed9d68303c5f8d15d3d87a23022.tar.bz2 |
Windows fixes for gss-client.c
close(s) -> closesocket(s)
#include "port-sockets.h" (for closesocket())
#include "winsock.h" -> #include "winsock2.h" for consistency with port-sockets.h
call WSAStartup() before using sockets functions on Windows
Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>
Signed-off-by: Sam Hartman <hartmans@painless-security.com>
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25089 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/appl')
-rw-r--r-- | src/appl/gss-sample/gss-client.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/appl/gss-sample/gss-client.c b/src/appl/gss-sample/gss-client.c index d439f23..c8213ed 100644 --- a/src/appl/gss-sample/gss-client.c +++ b/src/appl/gss-sample/gss-client.c @@ -49,7 +49,7 @@ #include <string.h> #ifdef _WIN32 #include <windows.h> -#include <winsock.h> +#include <winsock2.h> #else #include <assert.h> #include <unistd.h> @@ -67,6 +67,7 @@ #include <gssapi/gssapi_krb5.h> #include <gssapi/gssapi_ext.h> #include "gss-misc.h" +#include "port-sockets.h" static int verbose = 1; static int spnego = 0; @@ -113,6 +114,15 @@ connect_to_server(char *host, u_short port) struct sockaddr_in saddr; struct hostent *hp; int s; +#ifdef _WIN32 + WSADATA wsadata; + int wsastartuperror = WSAStartup(0x202, &wsadata); + if (wsastartuperror) + { + fprintf(stderr, "WSAStartup error: %x\n", wsastartuperror); + return -1; + } +#endif if ((hp = gethostbyname(host)) == NULL) { fprintf(stderr, "Unknown host: %s\n", host); @@ -129,7 +139,7 @@ connect_to_server(char *host, u_short port) } if (connect(s, (struct sockaddr *) &saddr, sizeof(saddr)) < 0) { perror("connecting to server"); - (void) close(s); + (void) closesocket(s); return -1; } return s; @@ -462,7 +472,7 @@ call_server(host, port, oid, service_name, gss_flags, auth_flag, if (client_establish_context(s, service_name, gss_flags, auth_flag, v1_format, oid, username, password, &context, &ret_flags) < 0) { - (void) close(s); + (void) closesocket(s); return -1; } @@ -560,7 +570,7 @@ call_server(host, port, oid, service_name, gss_flags, auth_flag, &in_buf, &state, &out_buf); if (maj_stat != GSS_S_COMPLETE) { display_status("wrapping message", maj_stat, min_stat); - (void) close(s); + (void) closesocket(s); (void) gss_delete_sec_context(&min_stat, &context, GSS_C_NO_BUFFER); return -1; @@ -578,7 +588,7 @@ call_server(host, port, oid, service_name, gss_flags, auth_flag, (encrypt_flag ? TOKEN_ENCRYPTED : 0) | (mic_flag ? TOKEN_SEND_MIC : 0))), &out_buf) < 0) { - (void) close(s); + (void) closesocket(s); (void) gss_delete_sec_context(&min_stat, &context, GSS_C_NO_BUFFER); return -1; @@ -588,7 +598,7 @@ call_server(host, port, oid, service_name, gss_flags, auth_flag, /* Read signature block into out_buf */ if (recv_token(s, &token_flags, &out_buf) < 0) { - (void) close(s); + (void) closesocket(s); (void) gss_delete_sec_context(&min_stat, &context, GSS_C_NO_BUFFER); return -1; @@ -600,7 +610,7 @@ call_server(host, port, oid, service_name, gss_flags, auth_flag, &out_buf, &qop_state); if (maj_stat != GSS_S_COMPLETE) { display_status("verifying signature", maj_stat, min_stat); - (void) close(s); + (void) closesocket(s); (void) gss_delete_sec_context(&min_stat, &context, GSS_C_NO_BUFFER); return -1; @@ -628,7 +638,7 @@ call_server(host, port, oid, service_name, gss_flags, auth_flag, maj_stat = gss_delete_sec_context(&min_stat, &context, &out_buf); if (maj_stat != GSS_S_COMPLETE) { display_status("deleting context", maj_stat, min_stat); - (void) close(s); + (void) closesocket(s); (void) gss_delete_sec_context(&min_stat, &context, GSS_C_NO_BUFFER); return -1; @@ -637,7 +647,7 @@ call_server(host, port, oid, service_name, gss_flags, auth_flag, (void) gss_release_buffer(&min_stat, &out_buf); } - (void) close(s); + (void) closesocket(s); return 0; } |