Skip to content

Commit

Permalink
gssapi: Remove need for duplicated GSS_C_NT_HOSTBASED_SERVICE definit…
Browse files Browse the repository at this point in the history
…ions

Better code reuse and consistency in calls to gss_import_name().
  • Loading branch information
captain-caveman2k committed Jan 9, 2015
1 parent 99e71e6 commit 355bf01
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 47 deletions.
13 changes: 12 additions & 1 deletion lib/curl_gssapi.h
Expand Up @@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2011 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2011 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -59,6 +59,17 @@ OM_uint32 Curl_gss_init_sec_context(
void Curl_gss_log_error(struct SessionHandle *data, OM_uint32 status,
const char *prefix);

/* Provide some definitions missing in old headers */
#ifdef HAVE_OLD_GSSMIT
#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
#define NCOMPAT 1
#endif

/* Define our privacy and integrity protection values */
#define GSSAUTH_P_NONE 1
#define GSSAUTH_P_INTEGRITY 2
#define GSSAUTH_P_PRIVACY 4

#endif /* HAVE_GSSAPI */

#endif /* HEADER_CURL_GSSAPI_H */
11 changes: 1 addition & 10 deletions lib/curl_sasl_gssapi.c
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014, Steve Holme, <steve_holme@hotmail.com>.
* Copyright (C) 2014 - 2015, Steve Holme, <steve_holme@hotmail.com>.
* Copyright (C) 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
Expand All @@ -27,15 +27,6 @@

#if defined(HAVE_GSSAPI) && defined(USE_KERBEROS5)

#ifdef HAVE_OLD_GSSMIT
#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
#define NCOMPAT 1
#endif

#define GSSAUTH_P_NONE 1
#define GSSAUTH_P_INTEGRITY 2
#define GSSAUTH_P_PRIVACY 4

#include <curl/curl.h>

#include "curl_sasl.h"
Expand Down
15 changes: 3 additions & 12 deletions lib/http_negotiate.c
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand All @@ -22,14 +22,7 @@

#include "curl_setup.h"

#ifdef HAVE_GSSAPI

#if !defined(CURL_DISABLE_HTTP) && defined(USE_SPNEGO)

#ifdef HAVE_OLD_GSSMIT
#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
#define NCOMPAT 1
#endif
#if defined(HAVE_GSSAPI) && !defined(CURL_DISABLE_HTTP) && defined(USE_SPNEGO)

#include "urldata.h"
#include "sendf.h"
Expand Down Expand Up @@ -211,6 +204,4 @@ void Curl_cleanup_negotiate(struct SessionHandle *data)
cleanup(&data->state.proxyneg);
}

#endif /* !CURL_DISABLE_HTTP && USE_SPNEGO */

#endif /* HAVE_GSSAPI */
#endif /* HAVE_GSSAPI && !CURL_DISABLE_HTTP && USE_SPNEGO */
13 changes: 3 additions & 10 deletions lib/krb5.c
Expand Up @@ -2,7 +2,7 @@
*
* Copyright (c) 1995, 1996, 1997, 1998, 1999, 2013 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* Copyright (c) 2004 - 2014 Daniel Stenberg
* Copyright (c) 2004 - 2015 Daniel Stenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -34,13 +34,7 @@

#include "curl_setup.h"

#ifndef CURL_DISABLE_FTP
#ifdef HAVE_GSSAPI

#ifdef HAVE_OLD_GSSMIT
#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
#define NCOMPAT 1
#endif
#if defined(HAVE_GSSAPI) && !defined(CURL_DISABLE_FTP)

#ifdef HAVE_NETDB_H
#include <netdb.h>
Expand Down Expand Up @@ -335,5 +329,4 @@ struct Curl_sec_client_mech Curl_krb5_client_mech = {
krb5_decode
};

#endif /* HAVE_GSSAPI */
#endif /* CURL_DISABLE_FTP */
#endif /* HAVE_GSSAPI && !CURL_DISABLE_FTP */
18 changes: 4 additions & 14 deletions lib/socks_gssapi.c
Expand Up @@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com>
* Copyright (C) 2012 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2012 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand All @@ -23,16 +23,7 @@

#include "curl_setup.h"

#ifndef CURL_DISABLE_PROXY

#ifdef HAVE_GSSAPI
#ifdef HAVE_OLD_GSSMIT
#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
#define NCOMPAT 1
#endif
#ifndef gss_nt_service_name
#define gss_nt_service_name GSS_C_NT_HOSTBASED_SERVICE
#endif
#if defined(HAVE_GSSAPI) && !defined(CURL_DISABLE_PROXY)

#include "curl_gssapi.h"
#include "urldata.h"
Expand Down Expand Up @@ -162,7 +153,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
serviceptr, conn->proxy.name);

gss_major_status = gss_import_name(&gss_minor_status, &service,
gss_nt_service_name, &server);
GSS_C_NT_HOSTBASED_SERVICE, &server);
}

gss_release_buffer(&gss_status, &service); /* clear allocated memory */
Expand Down Expand Up @@ -530,6 +521,5 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,

return CURLE_OK;
}
#endif

#endif /* CURL_DISABLE_PROXY */
#endif /* HAVE_GSSAPI && !CURL_DISABLE_PROXY */

0 comments on commit 355bf01

Please sign in to comment.