mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
password promting support removed from libcurl
This commit is contained in:
parent
597c1fe6bc
commit
22adcb9cd1
@ -123,6 +123,7 @@ typedef size_t (*curl_read_callback)(char *buffer,
|
|||||||
size_t nitems,
|
size_t nitems,
|
||||||
void *instream);
|
void *instream);
|
||||||
|
|
||||||
|
/* not used since 7.10.8, will be removed in a future release */
|
||||||
typedef int (*curl_passwd_callback)(void *clientp,
|
typedef int (*curl_passwd_callback)(void *clientp,
|
||||||
const char *prompt,
|
const char *prompt,
|
||||||
char *buffer,
|
char *buffer,
|
||||||
@ -503,11 +504,10 @@ typedef enum {
|
|||||||
this option is used only if SSL_VERIFYPEER is true */
|
this option is used only if SSL_VERIFYPEER is true */
|
||||||
CINIT(CAINFO, OBJECTPOINT, 65),
|
CINIT(CAINFO, OBJECTPOINT, 65),
|
||||||
|
|
||||||
/* Function pointer to replace the internal password prompt */
|
/* OBSOLETE since 7.10.8 */
|
||||||
CINIT(PASSWDFUNCTION, FUNCTIONPOINT, 66),
|
CINIT(PASSWDFUNCTION, FUNCTIONPOINT, 66),
|
||||||
|
|
||||||
/* Custom pointer that gets passed as first argument to the password
|
/* OBSOLETE since 7.10.8 */
|
||||||
function */
|
|
||||||
CINIT(PASSWDDATA, OBJECTPOINT, 67),
|
CINIT(PASSWDDATA, OBJECTPOINT, 67),
|
||||||
|
|
||||||
/* Maximum number of http redirects to follow */
|
/* Maximum number of http redirects to follow */
|
||||||
|
@ -64,13 +64,13 @@ endif
|
|||||||
|
|
||||||
libcurl_la_LDFLAGS = $(UNDEF) $(VERSION) $(ARESLIB)
|
libcurl_la_LDFLAGS = $(UNDEF) $(VERSION) $(ARESLIB)
|
||||||
|
|
||||||
libcurl_la_SOURCES = arpa_telnet.h file.c getpass.h netrc.h timeval.c \
|
libcurl_la_SOURCES = arpa_telnet.h file.c netrc.h timeval.c \
|
||||||
base64.c file.h hostip.c progress.c timeval.h base64.h formdata.c \
|
base64.c file.h hostip.c progress.c timeval.h base64.h formdata.c \
|
||||||
hostip.h progress.h cookie.c formdata.h http.c sendf.c cookie.h ftp.c \
|
hostip.h progress.h cookie.c formdata.h http.c sendf.c cookie.h ftp.c \
|
||||||
http.h sendf.h url.c dict.c ftp.h if2ip.c speedcheck.c url.h dict.h \
|
http.h sendf.h url.c dict.c ftp.h if2ip.c speedcheck.c url.h dict.h \
|
||||||
getdate.c if2ip.h speedcheck.h urldata.h getdate.h ldap.c ssluse.c \
|
getdate.c if2ip.h speedcheck.h urldata.h getdate.h ldap.c ssluse.c \
|
||||||
version.c getenv.c ldap.h ssluse.h escape.c mprintf.c telnet.c escape.h \
|
version.c getenv.c ldap.h ssluse.h escape.c mprintf.c telnet.c escape.h \
|
||||||
getpass.c netrc.c telnet.h getinfo.c getinfo.h transfer.c strequal.c \
|
netrc.c telnet.h getinfo.c getinfo.h transfer.c strequal.c \
|
||||||
strequal.h easy.c security.h security.c krb4.c krb4.h memdebug.c \
|
strequal.h easy.c security.h security.c krb4.c krb4.h memdebug.c \
|
||||||
memdebug.h inet_ntoa_r.h http_chunks.c http_chunks.h strtok.c strtok.h \
|
memdebug.h inet_ntoa_r.h http_chunks.c http_chunks.h strtok.c strtok.h \
|
||||||
connect.c connect.h llist.c llist.h hash.c hash.h multi.c \
|
connect.c connect.h llist.c llist.h hash.c hash.h multi.c \
|
||||||
|
224
lib/getpass.c
224
lib/getpass.c
@ -1,224 +0,0 @@
|
|||||||
/* ============================================================================
|
|
||||||
* Copyright (C) 1998 - 2002, Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
||||||
*
|
|
||||||
* Redistribution and use are freely permitted provided that:
|
|
||||||
*
|
|
||||||
* 1) This header remain in tact.
|
|
||||||
* 2) The prototypes for getpass and getpass_r are not changed from:
|
|
||||||
* char *getpass(const char *prompt)
|
|
||||||
* char *getpass_r(const char *prompt, char* buffer, int buflen)
|
|
||||||
* 3) This source code is not used outside of this(getpass.c) file.
|
|
||||||
* 4) Any changes to this(getpass.c) source code are made publicly available.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
||||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
||||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
* ============================================================================
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
* The spirit of this license is to allow use of this source code in any
|
|
||||||
* project be it open or closed but still encourage the use of the open,
|
|
||||||
* library based equivilents.
|
|
||||||
*
|
|
||||||
* Author(s):
|
|
||||||
* Angus Mackay <amackay@gus.ml.org>
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* Daniel Stenberg <daniel@haxx.se>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "setup.h" /* setup.h is required for read() prototype */
|
|
||||||
|
|
||||||
#ifndef HAVE_GETPASS_R
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#ifdef VMS
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include descrip
|
|
||||||
#include starlet
|
|
||||||
#include iodef
|
|
||||||
#include iosbdef
|
|
||||||
char *getpass_r(const char *prompt, char *buffer, size_t buflen)
|
|
||||||
{
|
|
||||||
long sts;
|
|
||||||
short chan;
|
|
||||||
struct _iosb iosb;
|
|
||||||
$DESCRIPTOR(ttdesc, "TT");
|
|
||||||
|
|
||||||
buffer[0]='\0';
|
|
||||||
if ((sts = sys$assign(&ttdesc, &chan,0,0)) & 1) {
|
|
||||||
if (((sts = sys$qiow(0, chan, IO$_READPROMPT | IO$M_NOECHO, &iosb, 0, 0, buffer, buflen, 0, 0, prompt, strlen(prompt))) & 1) && (iosb.iosb$w_status&1)) {
|
|
||||||
buffer[iosb.iosb$w_bcnt] = '\0';
|
|
||||||
}
|
|
||||||
sts = sys$dassgn(chan);
|
|
||||||
}
|
|
||||||
return buffer; /* we always return success */
|
|
||||||
}
|
|
||||||
#else /* VMS */
|
|
||||||
#ifdef HAVE_TERMIOS_H
|
|
||||||
# if !defined(HAVE_TCGETATTR) && !defined(HAVE_TCSETATTR)
|
|
||||||
# undef HAVE_TERMIOS_H
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef RETSIGTYPE
|
|
||||||
# define RETSIGTYPE void
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#ifdef HAVE_TERMIOS_H
|
|
||||||
# include <termios.h>
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_TERMIO_H
|
|
||||||
# include <termio.h>
|
|
||||||
# else
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The last #include file should be: */
|
|
||||||
#ifdef CURLDEBUG
|
|
||||||
#include "memdebug.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *getpass_r(const char *prompt, char *buffer, size_t buflen)
|
|
||||||
{
|
|
||||||
FILE *infp;
|
|
||||||
char infp_fclose = 0;
|
|
||||||
FILE *outfp;
|
|
||||||
RETSIGTYPE (*sigint)();
|
|
||||||
#ifdef SIGTSTP
|
|
||||||
RETSIGTYPE (*sigtstp)();
|
|
||||||
#endif
|
|
||||||
size_t bytes_read;
|
|
||||||
int infd;
|
|
||||||
int outfd;
|
|
||||||
#ifdef HAVE_TERMIOS_H
|
|
||||||
struct termios orig;
|
|
||||||
struct termios noecho;
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_TERMIO_H
|
|
||||||
struct termio orig;
|
|
||||||
struct termio noecho;
|
|
||||||
# else
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sigint = signal(SIGINT, SIG_IGN);
|
|
||||||
#ifdef SIGTSTP
|
|
||||||
sigtstp = signal(SIGTSTP, SIG_IGN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
infp=fopen("/dev/tty", "r");
|
|
||||||
if( NULL == infp )
|
|
||||||
infp = stdin;
|
|
||||||
else
|
|
||||||
infp_fclose = 1;
|
|
||||||
|
|
||||||
outfp = stderr;
|
|
||||||
|
|
||||||
infd = fileno(infp);
|
|
||||||
outfd = fileno(outfp);
|
|
||||||
|
|
||||||
/* dissable echo */
|
|
||||||
#ifdef HAVE_TERMIOS_H
|
|
||||||
tcgetattr(outfd, &orig);
|
|
||||||
|
|
||||||
noecho = orig;
|
|
||||||
noecho.c_lflag &= ~ECHO;
|
|
||||||
tcsetattr(outfd, TCSANOW, &noecho);
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_TERMIO_H
|
|
||||||
ioctl(outfd, TCGETA, &orig);
|
|
||||||
noecho = orig;
|
|
||||||
noecho.c_lflag &= ~ECHO;
|
|
||||||
ioctl(outfd, TCSETA, &noecho);
|
|
||||||
# else
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fputs(prompt, outfp);
|
|
||||||
fflush(outfp);
|
|
||||||
|
|
||||||
bytes_read=read(infd, buffer, buflen);
|
|
||||||
buffer[bytes_read > 0 ? (bytes_read -1) : 0] = '\0';
|
|
||||||
|
|
||||||
/* print a new line if needed */
|
|
||||||
#ifdef HAVE_TERMIOS_H
|
|
||||||
fputs("\n", outfp);
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_TERMIO_H
|
|
||||||
fputs("\n", outfp);
|
|
||||||
# else
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* reset term charectaristics, use TCSAFLUSH incase the
|
|
||||||
* user types more than buflen
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_TERMIOS_H
|
|
||||||
tcsetattr(outfd, TCSAFLUSH, &orig);
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_TERMIO_H
|
|
||||||
ioctl(outfd, TCSETA, &orig);
|
|
||||||
# else
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
signal(SIGINT, sigint);
|
|
||||||
#ifdef SIGTSTP
|
|
||||||
signal(SIGTSTP, sigtstp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(infp_fclose)
|
|
||||||
fclose(infp);
|
|
||||||
|
|
||||||
return buffer; /* we always return success */
|
|
||||||
}
|
|
||||||
#endif /* VMS */
|
|
||||||
#else /* WIN32 */
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <conio.h>
|
|
||||||
char *getpass_r(const char *prompt, char *buffer, int buflen)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
printf("%s", prompt);
|
|
||||||
|
|
||||||
for(i=0; i<buflen; i++) {
|
|
||||||
buffer[i] = getch();
|
|
||||||
if ( buffer[i] == '\r' ) {
|
|
||||||
buffer[i] = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* if user didn't hit ENTER, terminate buffer */
|
|
||||||
if (i==buflen)
|
|
||||||
buffer[buflen-1]=0;
|
|
||||||
|
|
||||||
return buffer; /* we always return success */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ifndef HAVE_GETPASS_R */
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* for consistensy, here's the old-style function: */
|
|
||||||
char *getpass(const char *prompt)
|
|
||||||
{
|
|
||||||
static char buf[256];
|
|
||||||
return getpass_r(prompt, buf, sizeof(buf));
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,35 +0,0 @@
|
|||||||
#ifndef __GETPASS_H
|
|
||||||
#define __GETPASS_H
|
|
||||||
/***************************************************************************
|
|
||||||
* _ _ ____ _
|
|
||||||
* Project ___| | | | _ \| |
|
|
||||||
* / __| | | | |_) | |
|
|
||||||
* | (__| |_| | _ <| |___
|
|
||||||
* \___|\___/|_| \_\_____|
|
|
||||||
*
|
|
||||||
* Copyright (C) 1998 - 2003, 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
|
|
||||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
|
||||||
*
|
|
||||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
||||||
* copies of the Software, and permit persons to whom the Software is
|
|
||||||
* furnished to do so, under the terms of the COPYING file.
|
|
||||||
*
|
|
||||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
||||||
* KIND, either express or implied.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
#ifndef HAVE_GETPASS_R
|
|
||||||
/* If there's a system-provided function named like this, we trust it is
|
|
||||||
also found in one of the standard headers. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returning NULL will abort the continued operation!
|
|
||||||
*/
|
|
||||||
char* getpass_r(const char *prompt, char* buffer, size_t buflen );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -86,7 +86,6 @@
|
|||||||
#include "transfer.h"
|
#include "transfer.h"
|
||||||
#include "sendf.h"
|
#include "sendf.h"
|
||||||
#include "speedcheck.h"
|
#include "speedcheck.h"
|
||||||
#include "getpass.h"
|
|
||||||
#include "progress.h"
|
#include "progress.h"
|
||||||
#include "getdate.h"
|
#include "getdate.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
107
lib/url.c
107
lib/url.c
@ -97,7 +97,6 @@
|
|||||||
#include "if2ip.h"
|
#include "if2ip.h"
|
||||||
#include "transfer.h"
|
#include "transfer.h"
|
||||||
#include "sendf.h"
|
#include "sendf.h"
|
||||||
#include "getpass.h"
|
|
||||||
#include "progress.h"
|
#include "progress.h"
|
||||||
#include "cookie.h"
|
#include "cookie.h"
|
||||||
#include "strequal.h"
|
#include "strequal.h"
|
||||||
@ -241,20 +240,6 @@ CURLcode Curl_close(struct SessionHandle *data)
|
|||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
int my_getpass(void *clientp, const char *prompt, char* buffer, int buflen )
|
|
||||||
{
|
|
||||||
char *retbuf;
|
|
||||||
clientp=NULL; /* prevent compiler warning */
|
|
||||||
|
|
||||||
retbuf = getpass_r(prompt, buffer, buflen);
|
|
||||||
if(NULL == retbuf)
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0; /* success */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CURLcode Curl_open(struct SessionHandle **curl)
|
CURLcode Curl_open(struct SessionHandle **curl)
|
||||||
{
|
{
|
||||||
/* We don't yet support specifying the URL at this point */
|
/* We don't yet support specifying the URL at this point */
|
||||||
@ -287,9 +272,6 @@ CURLcode Curl_open(struct SessionHandle **curl)
|
|||||||
/* use fread as default function to read input */
|
/* use fread as default function to read input */
|
||||||
data->set.fread = (curl_read_callback)fread;
|
data->set.fread = (curl_read_callback)fread;
|
||||||
|
|
||||||
/* set the default passwd function */
|
|
||||||
data->set.fpasswd = my_getpass;
|
|
||||||
|
|
||||||
data->set.infilesize = -1; /* we don't know any size */
|
data->set.infilesize = -1; /* we don't know any size */
|
||||||
|
|
||||||
data->state.current_speed = -1; /* init to negative == impossible */
|
data->state.current_speed = -1; /* init to negative == impossible */
|
||||||
@ -949,25 +931,6 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
|
|||||||
*/
|
*/
|
||||||
data->set.progress_client = va_arg(param, void *);
|
data->set.progress_client = va_arg(param, void *);
|
||||||
break;
|
break;
|
||||||
case CURLOPT_PASSWDFUNCTION:
|
|
||||||
/*
|
|
||||||
* Password prompt callback
|
|
||||||
*/
|
|
||||||
data->set.fpasswd = va_arg(param, curl_passwd_callback);
|
|
||||||
/*
|
|
||||||
* if the callback provided is null, reset the default callback
|
|
||||||
*/
|
|
||||||
if(!data->set.fpasswd)
|
|
||||||
{
|
|
||||||
data->set.fpasswd = my_getpass;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CURLOPT_PASSWDDATA:
|
|
||||||
/*
|
|
||||||
* Custom client data to pass to the password callback
|
|
||||||
*/
|
|
||||||
data->set.passwd_client = va_arg(param, void *);
|
|
||||||
break;
|
|
||||||
case CURLOPT_PROXYUSERPWD:
|
case CURLOPT_PROXYUSERPWD:
|
||||||
/*
|
/*
|
||||||
* user:password needed to use the proxy
|
* user:password needed to use the proxy
|
||||||
@ -1936,8 +1899,6 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
char endbracket;
|
char endbracket;
|
||||||
char user[MAX_CURL_USER_LENGTH];
|
char user[MAX_CURL_USER_LENGTH];
|
||||||
char passwd[MAX_CURL_PASSWORD_LENGTH];
|
char passwd[MAX_CURL_PASSWORD_LENGTH];
|
||||||
bool passwdgiven=FALSE; /* set TRUE if an application-provided password has
|
|
||||||
been set */
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
#ifdef HAVE_SIGACTION
|
#ifdef HAVE_SIGACTION
|
||||||
@ -2157,32 +2118,9 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
if(conn->bits.proxy_user_passwd) {
|
if(conn->bits.proxy_user_passwd) {
|
||||||
char proxyuser[MAX_CURL_USER_LENGTH]="";
|
char proxyuser[MAX_CURL_USER_LENGTH]="";
|
||||||
char proxypasswd[MAX_CURL_PASSWORD_LENGTH]="";
|
char proxypasswd[MAX_CURL_PASSWORD_LENGTH]="";
|
||||||
passwdgiven = FALSE;
|
|
||||||
|
|
||||||
if(*data->set.proxyuserpwd != ':') {
|
sscanf(data->set.proxyuserpwd, "%127[^:]:%127[^\n]",
|
||||||
/* the name is given, get user+password */
|
proxyuser, proxypasswd);
|
||||||
sscanf(data->set.proxyuserpwd, "%127[^:]:%127[^\n]",
|
|
||||||
proxyuser, proxypasswd);
|
|
||||||
if(strchr(data->set.proxyuserpwd, ':'))
|
|
||||||
/* a colon means the password was given, even if blank */
|
|
||||||
passwdgiven = TRUE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* no name given, get the password only */
|
|
||||||
sscanf(data->set.proxyuserpwd+1, "%127[^\n]", proxypasswd);
|
|
||||||
passwdgiven = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check for password, if no ask for one */
|
|
||||||
if( !proxypasswd[0] && !passwdgiven) {
|
|
||||||
if(data->set.fpasswd( data->set.passwd_client,
|
|
||||||
"proxy password:",
|
|
||||||
proxypasswd,
|
|
||||||
sizeof(proxypasswd))) {
|
|
||||||
failf(data, "Bad password from password callback");
|
|
||||||
return CURLE_BAD_PASSWORD_ENTERED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
conn->proxyuser = strdup(proxyuser);
|
conn->proxyuser = strdup(proxyuser);
|
||||||
if(!conn->proxyuser)
|
if(!conn->proxyuser)
|
||||||
@ -2728,7 +2666,6 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
|
|
||||||
user[0] =0; /* to make everything well-defined */
|
user[0] =0; /* to make everything well-defined */
|
||||||
passwd[0]=0;
|
passwd[0]=0;
|
||||||
passwdgiven = FALSE; /* none given so far */
|
|
||||||
|
|
||||||
if (conn->protocol & (PROT_FTP|PROT_HTTP)) {
|
if (conn->protocol & (PROT_FTP|PROT_HTTP)) {
|
||||||
/* This is a FTP or HTTP URL, we will now try to extract the possible
|
/* This is a FTP or HTTP URL, we will now try to extract the possible
|
||||||
@ -2777,9 +2714,6 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
strcpy(passwd, newpasswd);
|
strcpy(passwd, newpasswd);
|
||||||
}
|
}
|
||||||
free(newpasswd);
|
free(newpasswd);
|
||||||
|
|
||||||
/* we have set the password */
|
|
||||||
passwdgiven = TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2795,47 +2729,24 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
* so it doesn't have to be set in this block
|
* so it doesn't have to be set in this block
|
||||||
*/
|
*/
|
||||||
if (data->set.userpwd != NULL) {
|
if (data->set.userpwd != NULL) {
|
||||||
if(*data->set.userpwd != ':') {
|
/* the name is given, get user+password */
|
||||||
/* the name is given, get user+password */
|
sscanf(data->set.userpwd, "%127[^:]:%127[^\n]",
|
||||||
sscanf(data->set.userpwd, "%127[^:]:%127[^\n]",
|
user, passwd);
|
||||||
user, passwd);
|
|
||||||
if(strchr(data->set.userpwd, ':'))
|
|
||||||
/* a colon means the password was given, even if blank */
|
|
||||||
passwdgiven = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* no name given, starts with a colon, get the password only */
|
|
||||||
sscanf(data->set.userpwd+1, "%127[^\n]", passwd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((data->set.use_netrc != CURL_NETRC_IGNORED) &&
|
if (data->set.use_netrc != CURL_NETRC_IGNORED) {
|
||||||
!passwdgiven) { /* need passwd */
|
|
||||||
if(Curl_parsenetrc(conn->hostname,
|
if(Curl_parsenetrc(conn->hostname,
|
||||||
user,
|
user, passwd)) {
|
||||||
passwd)) {
|
|
||||||
infof(data, "Couldn't find host %s in the .netrc file, using defaults",
|
infof(data, "Couldn't find host %s in the .netrc file, using defaults",
|
||||||
conn->hostname);
|
conn->hostname);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
conn->bits.user_passwd = 1; /* enable user+password */
|
conn->bits.user_passwd = 1; /* enable user+password */
|
||||||
passwdgiven = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we have a user but no password, ask for one */
|
|
||||||
if(conn->bits.user_passwd && !passwdgiven ) {
|
|
||||||
if(data->set.fpasswd(data->set.passwd_client,
|
|
||||||
"password:", passwd,
|
|
||||||
sizeof(passwd)))
|
|
||||||
return CURLE_BAD_PASSWORD_ENTERED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* So we could have a password but no user; that's just too bad. */
|
|
||||||
|
|
||||||
/* If our protocol needs a password and we have none, use the defaults */
|
/* If our protocol needs a password and we have none, use the defaults */
|
||||||
if ( (conn->protocol & (PROT_FTP|PROT_HTTP)) &&
|
if ( (conn->protocol & (PROT_FTP|PROT_HTTP)) &&
|
||||||
!conn->bits.user_passwd &&
|
!conn->bits.user_passwd) {
|
||||||
!passwdgiven) {
|
|
||||||
|
|
||||||
strcpy(user, CURL_DEFAULT_USER);
|
strcpy(user, CURL_DEFAULT_USER);
|
||||||
strcpy(passwd, CURL_DEFAULT_PASSWORD);
|
strcpy(passwd, CURL_DEFAULT_PASSWORD);
|
||||||
|
Loading…
Reference in New Issue
Block a user