Commit f2584627 authored by Steve Holme's avatar Steve Holme
Browse files

curl_easy_setopt: Added the ability to set the login options separately

Rather than set the authentication options as part of the login details
specified in the URL, or via the older CURLOPT_USERPWD option, added a
new libcurl option to allow the login options to be set separately.
parent 6901861f
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -1164,14 +1164,23 @@ user name to use for the transfer.
authentication. You should not use this option together with the (older)
CURLOPT_USERPWD option.

In order to specify the password to be used in conjunction with the user name
use the \fICURLOPT_PASSWORD\fP option.  (Added in 7.19.1)
To specify the password and login options, along with the user name, use the
\fICURLOPT_PASSWORD\fP and \fICURLOPT_OPTIONS\fP options or alternatively use
the older \CURLOPT_USERPWD\fP option instead. (Added in 7.19.1)
.IP CURLOPT_PASSWORD
Pass a char * as parameter, which should be pointing to the zero terminated
password to use for the transfer.

The CURLOPT_PASSWORD option should be used in conjunction with
the \fICURLOPT_USERNAME\fP option. (Added in 7.19.1)
The CURLOPT_PASSWORD option should be used in conjunction with the
\fICURLOPT_USERNAME\fP option. (Added in 7.19.1)
.IP CURLOPT_OPTIONS
Pass a char * as parameter, which should be pointing to the zero terminated
options string to use for the transfer.

\CURLOPT_OPTIONS\fP can be used to set protocol specific authentication options,
such as the preferred authentication mechanism via "AUTH=NTLM" or "AUTH=*", and
should be used in conjunction with the \fICURLOPT_USERNAME\fP option. (Added in
7.34.0)
.IP CURLOPT_PROXYUSERNAME
Pass a char * as parameter, which should be pointing to the zero terminated
user name to use for the transfer while connecting to Proxy.
+1 −0
Original line number Diff line number Diff line
@@ -417,6 +417,7 @@ CURLOPT_NOSIGNAL 7.10
CURLOPT_NOTHING                 7.1.1         7.11.1      7.11.0
CURLOPT_OPENSOCKETDATA          7.17.1
CURLOPT_OPENSOCKETFUNCTION      7.17.1
CURLOPT_OPTIONS                 7.34.0
CURLOPT_PASSWDDATA              7.4.2         7.11.1      7.15.5
CURLOPT_PASSWDFUNCTION          7.4.2         7.11.1      7.15.5
CURLOPT_PASSWORD                7.19.1
+5 −2
Original line number Diff line number Diff line
@@ -827,10 +827,10 @@ typedef enum {
  /* Name of proxy to use. */
  CINIT(PROXY, OBJECTPOINT, 4),

  /* "name:password" to use when fetching. */
  /* "user:password;options" to use when fetching. */
  CINIT(USERPWD, OBJECTPOINT, 5),

  /* "name:password" to use with proxy. */
  /* "user:password" to use with proxy. */
  CINIT(PROXYUSERPWD, OBJECTPOINT, 6),

  /* Range to get, specified as an ASCII string. */
@@ -1569,6 +1569,9 @@ typedef enum {
   * Only supported by the c-ares DNS backend */
  CINIT(DNS_LOCAL_IP6, OBJECTPOINT, 223),

  /* Set authentication options directly */
  CINIT(OPTIONS, OBJECTPOINT, 224),

  CURLOPT_LASTENTRY /* the last unused */
} CURLoption;

+1 −0
Original line number Diff line number Diff line
@@ -269,6 +269,7 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
   (option) == CURLOPT_DNS_INTERFACE ||                                       \
   (option) == CURLOPT_DNS_LOCAL_IP4 ||                                       \
   (option) == CURLOPT_DNS_LOCAL_IP6 ||                                       \
   (option) == CURLOPT_OPTIONS ||                                             \
   0)

/* evaluates to true if option takes a curl_write_callback argument */
+13 −1
Original line number Diff line number Diff line
@@ -1560,6 +1560,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
                               &data->set.str[STRING_PASSWORD],
                               &data->set.str[STRING_OPTIONS]);
    break;

  case CURLOPT_USERNAME:
    /*
     * authentication user name to use in the operation
@@ -1567,6 +1568,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
    result = setstropt(&data->set.str[STRING_USERNAME],
                       va_arg(param, char *));
    break;

  case CURLOPT_PASSWORD:
    /*
     * authentication password to use in the operation
@@ -1574,6 +1576,15 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
    result = setstropt(&data->set.str[STRING_PASSWORD],
                       va_arg(param, char *));
    break;

  case CURLOPT_OPTIONS:
    /*
     * authentication options to use in the operation
     */
    result = setstropt(&data->set.str[STRING_OPTIONS],
                       va_arg(param, char *));
    break;

  case CURLOPT_XOAUTH2_BEARER:
    /*
     * XOAUTH2 bearer token to use in the operation
@@ -1581,6 +1592,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
    result = setstropt(&data->set.str[STRING_BEARER],
                       va_arg(param, char *));
    break;

  case CURLOPT_POSTQUOTE:
    /*
     * List of RAW FTP commands to use after a transfer
@@ -4824,7 +4836,7 @@ static CURLcode override_login(struct SessionHandle *data,
}

/*
 * Set password so it's available in the connection.
 * Set the login details so they're available in the connection
 */
static CURLcode set_login(struct connectdata *conn,
                          const char *user, const char *passwd,
Loading