a312cf4
From 9698db7fd56b08cc8f9bdeb2182bc9afdbcb4f90 Mon Sep 17 00:00:00 2001
a312cf4
From: Daniel Stenberg <daniel@haxx.se>
a312cf4
Date: Fri, 12 Aug 2011 14:48:32 +0200
a312cf4
Subject: [PATCH 1/2] added --delegation
a312cf4
a312cf4
Using this option with an argument being set to one of
a312cf4
none/policy/always instructs libcurl how to deal with GSS
a312cf4
credentials. Or rather how it tells the server that delegation is fine
a312cf4
or not.
a312cf4
a312cf4
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a312cf4
---
a312cf4
 src/main.c |   29 ++++++++++++++++++++++++++---
a312cf4
 1 files changed, 26 insertions(+), 3 deletions(-)
a312cf4
a312cf4
diff --git a/src/main.c b/src/main.c
a312cf4
index d85bf62..3a2595c 100644
a312cf4
--- a/src/main.c
a312cf4
+++ b/src/main.c
a312cf4
@@ -659,6 +659,7 @@ struct Configurable {
a312cf4
                              basically each given URL to transfer */
a312cf4
   struct OutStruct *outs;
a312cf4
   bool xattr; /* store metadata in extended attributes */
a312cf4
+  long gssapi_delegation;
a312cf4
 };
a312cf4
 
a312cf4
 #define WARN_PREFIX "Warning: "
a312cf4
@@ -817,6 +818,7 @@ static void help(void)
a312cf4
     "    --data-binary <data> HTTP POST binary data (H)",
a312cf4
     "    --data-urlencode <name=data/name@filename> "
a312cf4
     "HTTP POST data url encoded (H)",
a312cf4
+    "    --delegation STRING GSS-API delegation permission",
a312cf4
     "    --digest        Use HTTP Digest Authentication (H)",
a312cf4
     "    --disable-eprt  Inhibit using EPRT or LPRT (F)",
a312cf4
     "    --disable-epsv  Inhibit using EPSV (F)",
a312cf4
@@ -1823,6 +1825,18 @@ static int sockoptcallback(void *clientp, curl_socket_t curlfd,
a312cf4
   return 0;
a312cf4
 }
a312cf4
 
a312cf4
+static long delegation(struct Configurable *config,
a312cf4
+                       char *str)
a312cf4
+{
a312cf4
+  if(curlx_raw_equal("none", str))
a312cf4
+    return CURLGSSAPI_DELEGATION_NONE;
a312cf4
+  if(curlx_raw_equal("policy", str))
a312cf4
+    return CURLGSSAPI_DELEGATION_POLICY_FLAG;
a312cf4
+  if(curlx_raw_equal("always", str))
a312cf4
+    return CURLGSSAPI_DELEGATION_FLAG;
a312cf4
+  warnf(config, "unrecognized delegation method '%s', using none\n", str);
a312cf4
+  return CURLGSSAPI_DELEGATION_NONE;
a312cf4
+}
a312cf4
 
a312cf4
 static ParameterError getparameter(char *flag, /* f or -long-flag */
a312cf4
                                    char *nextarg, /* NULL if unset */
a312cf4
@@ -1942,6 +1956,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
a312cf4
     {"$D", "proto",      TRUE},
a312cf4
     {"$E", "proto-redir", TRUE},
a312cf4
     {"$F", "resolve",    TRUE},
a312cf4
+    {"$G", "delegation", TRUE},
a312cf4
     {"0", "http1.0",     FALSE},
a312cf4
     {"1", "tlsv1",       FALSE},
a312cf4
     {"2", "sslv2",       FALSE},
a312cf4
@@ -2516,6 +2531,9 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
a312cf4
         if(err)
a312cf4
           return err;
a312cf4
         break;
a312cf4
+      case 'G': /* --delegation LEVEL */
a312cf4
+        config->gssapi_delegation = delegation(config, nextarg);
a312cf4
+        break;
a312cf4
       }
a312cf4
       break;
a312cf4
     case '#': /* --progress-bar */
a312cf4
@@ -5564,9 +5582,14 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
a312cf4
           /* new in 7.21.3 */
a312cf4
           my_setopt(curl, CURLOPT_RESOLVE, config->resolve);
a312cf4
 
a312cf4
-        /* TODO: new in ### */
a312cf4
-        curl_easy_setopt(curl, CURLOPT_TLSAUTH_USERNAME, config->tls_username);
a312cf4
-        curl_easy_setopt(curl, CURLOPT_TLSAUTH_PASSWORD, config->tls_password);
a312cf4
+        /* new in 7.21.4 */
a312cf4
+        my_setopt_str(curl, CURLOPT_TLSAUTH_USERNAME, config->tls_username);
a312cf4
+        my_setopt_str(curl, CURLOPT_TLSAUTH_PASSWORD, config->tls_password);
a312cf4
+
a312cf4
+        /* new in 7.22.0 */
a312cf4
+        if(config->gssapi_delegation)
a312cf4
+          my_setopt_str(curl, CURLOPT_GSSAPI_DELEGATION,
a312cf4
+                        config->gssapi_delegation);
a312cf4
 
a312cf4
         retry_numretries = config->req_retry;
a312cf4
 
a312cf4
-- 
a312cf4
1.7.4.4
a312cf4
a312cf4
a312cf4
From 8e404e1c3846cc98a1977514af5b0432ae2de755 Mon Sep 17 00:00:00 2001
a312cf4
From: Daniel Stenberg <daniel@haxx.se>
a312cf4
Date: Fri, 12 Aug 2011 23:51:41 +0200
a312cf4
Subject: [PATCH 2/2] docs: --delegation
a312cf4
a312cf4
a312cf4
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a312cf4
---
a312cf4
 docs/curl.1 |   12 ++++++++++++
a312cf4
 1 files changed, 12 insertions(+), 0 deletions(-)
a312cf4
a312cf4
diff --git a/docs/curl.1 b/docs/curl.1
a312cf4
index 812b2eb..eee3481 100644
a312cf4
--- a/docs/curl.1
a312cf4
+++ b/docs/curl.1
a312cf4
@@ -320,6 +320,18 @@ URL-encode that data and pass it on in the POST. The name part gets an equal
a312cf4
 sign appended, resulting in \fIname=urlencoded-file-content\fP. Note that the
a312cf4
 name is expected to be URL-encoded already.
a312cf4
 .RE
a312cf4
+.IP "--delegation LEVEL"
a312cf4
+Set \fILEVEL\fP to tell the server what it is allowed to delegate when it
a312cf4
+comes to user credentials. Used with GSS/kerberos.
a312cf4
+.RS
a312cf4
+.IP "none"
a312cf4
+Don't allow any delegation.
a312cf4
+.IP "policy"
a312cf4
+Delegates if and only if the OK-AS-DELEGATE flag is set in the Kerberos
a312cf4
+service ticket, which is a matter of realm policy.
a312cf4
+.IP "always"
a312cf4
+Unconditionally allow the server to delegate.
a312cf4
+.RE
a312cf4
 .IP "--digest"
a312cf4
 (HTTP) Enables HTTP Digest authentication. This is a authentication that
a312cf4
 prevents the password from being sent over the wire in clear text. Use this in
a312cf4
-- 
a312cf4
1.7.4.4
a312cf4