netrc: don't ignore the login name specified with "--user"

- for "--netrc", don't ignore the login/password specified with "--user",
  only ignore the login/password in the URL.
  This restores the netrc behaviour of curl 7.61.1 and earlier.
- fix the documentation of CURL_NETRC_REQUIRED
- improve the detection of login/password changes when reading .netrc
- don't read .netrc if both login and password are already set

Fixes #3213
Closes #3224
This commit is contained in:
Michael Kaufmann 2018-11-03 16:58:18 +01:00
parent a77b640cc0
commit 53db15ba55
6 changed files with 83 additions and 55 deletions

View file

@ -5,7 +5,7 @@ Added: 7.21.5
Mutexed: netrc
---
This option is similar to --netrc, except that you provide the path (absolute
or relative) to the netrc file that Curl should use. You can only specify one
or relative) to the netrc file that curl should use. You can only specify one
netrc file per invocation. If several --netrc-file options are provided,
the last one will be used.

View file

@ -47,20 +47,21 @@ standard Unix ftp client does). It should only be readable by user.
\fIlevel\fP should be set to one of the values described below.
.IP CURL_NETRC_OPTIONAL
The use of your \fI~/.netrc\fP file is optional, and information in the URL is
to be preferred. The file will be scanned for the host and user name (to
find the password only) or for the host only, to find the first user name and
password after that \fImachine\fP, which ever information is not specified in
the URL.
The use of the \fI~/.netrc\fP file is optional, and information in the URL is
to be preferred. The file will be scanned for the host and user name (to find
the password only) or for the host only, to find the first user name and
password after that \fImachine\fP, which ever information is not specified.
Undefined values of the option will have this effect.
.IP CURL_NETRC_IGNORED
The library will ignore the file and use only the information in the URL.
The library will ignore the \fI~/.netrc\fP file.
This is the default.
.IP CURL_NETRC_REQUIRED
This value tells the library that use of the file is required, to ignore the
information in the URL, and to search the file for the host only.
The use of the \fI~/.netrc\fP file is required, and information in the URL is
to be ignored. The file will be scanned for the host and user name (to find
the password only) or for the host only, to find the first user name and
password after that \fImachine\fP, which ever information is not specified.
.SH DEFAULT
CURL_NETRC_IGNORED
.SH PROTOCOLS