netrc: check %USERPROFILE% as well on Windows

Closes #8855
This commit is contained in:
Wolf Vollprecht 2022-06-02 09:30:52 +02:00 committed by Daniel Stenberg
parent 665138b2dd
commit 4d4eb8e587
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 23 additions and 6 deletions

View file

@ -54,6 +54,10 @@ nss, openssl, rustls, schannel, secure-transport, wolfssl
When the netrc feature is used (\fICURLOPT_NETRC(3)\fP), this variable is
checked as the primary way to find the "current" home directory in which
the .netrc file is likely to exist.
.IP USERPROFILE
When the netrc feature is used (\fICURLOPT_NETRC(3)\fP), this variable is
checked as the secondary way to find the "current" home directory (on Windows
only) in which the .netrc file is likely to exist.
.IP LOGNAME
User name to use when invoking the ntlm-wb tool, if NTLMUSER was not set.
.IP NO_PROXY

View file

@ -361,9 +361,11 @@ similar to the \fICURLOPT_USERPWD(3)\fP option like this:
curl_easy_setopt(easyhandle, CURLOPT_PROXYUSERPWD, "myname:thesecret");
There's a long time Unix "standard" way of storing FTP user names and
passwords, namely in the $HOME/.netrc file. The file should be made private
so that only the user may read it (see also the "Security Considerations"
chapter), as it might contain the password in plain text. libcurl has the
passwords, namely in the $HOME/.netrc file (on Windows, libcurl also checks
the %USERPROFILE% environment variable if %HOME% is unset, and tries
_netrc as name). The file should be made private so that only the user may
read it (see also the "Security Considerations" chapter),
as it might contain the password in plain text. libcurl has the
ability to use this file to figure out what set of user name and password to
use for a particular host. As an extension to the normal functionality,
libcurl also supports this file for non-FTP protocols such as HTTP. To make

View file

@ -32,9 +32,13 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NETRC, long level);
.SH DESCRIPTION
This parameter controls the preference \fIlevel\fP of libcurl between using
user names and passwords from your \fI~/.netrc\fP file, relative to user names
and passwords in the URL supplied with \fICURLOPT_URL(3)\fP. On Windows,
libcurl will use the file as \fI%HOME%/_netrc\fP, but you can also tell
libcurl a different file name to use with \fICURLOPT_NETRC_FILE(3)\fP.
and passwords in the URL supplied with \fICURLOPT_URL(3)\fP.
On Windows, libcurl will use the file as \fI%HOME%/_netrc\fP. If \fI%HOME%\fP
is not set on Windows, libcurl falls back to \fI%USERPROFILE%\fP.
You can also tell libcurl a different file name to use with
\fICURLOPT_NETRC_FILE(3)\fP.
libcurl uses a user name (and supplied or prompted password) supplied with
\fICURLOPT_USERPWD(3)\fP or \fICURLOPT_USERNAME(3)\fP in preference to any of

View file

@ -313,6 +313,13 @@ int Curl_parsenetrc(const char *host,
if(pw) {
home = pw->pw_dir;
}
#elif defined(_WIN32)
}
else {
homea = curl_getenv("USERPROFILE");
if(homea) {
home = homea;
}
#endif
}