]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
url: fix netrc info message
authorJay Satiro <raysatiro@yahoo.com>
Wed, 20 Sep 2023 22:59:45 +0000 (18:59 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Sun, 24 Sep 2023 07:37:13 +0000 (03:37 -0400)
- Fix netrc info message to use the generic ".netrc" filename if the
  user did not specify a netrc location.

- Update --netrc doc to add that recent versions of curl on Windows
  prefer .netrc over _netrc.

Before:
* Couldn't find host google.com in the (nil) file; using defaults

After:
* Couldn't find host google.com in the .netrc file; using defaults

Closes https://github.com/curl/curl/pull/11904

docs/cmdline-opts/netrc.d
lib/url.c

index 46e8778fa08458cf412730bf86e1f1c840c6539a..f0ec75f37840e9b9422dcf7b769a28805f91247e 100644 (file)
@@ -10,13 +10,16 @@ See-also: netrc-file config user
 Mutexed: netrc-file netrc-optional
 Multi: boolean
 ---
-Makes curl scan the *.netrc* (*_netrc* on Windows) file in the user's home
-directory for login name and password. This is typically used for FTP on
-Unix. If used with HTTP, curl enables user authentication. See *netrc(5)* and
-*ftp(1)* for details on the file format. Curl does not complain if that file
-does not have the right permissions (it should be neither world- nor
-group-readable). The environment variable "HOME" is used to find the home
-directory.
+Makes curl scan the *.netrc* file in the user's home directory for login name
+and password. This is typically used for FTP on Unix. If used with HTTP, curl
+enables user authentication. See *netrc(5)* and *ftp(1)* for details on the
+file format. Curl does not complain if that file does not have the right
+permissions (it should be neither world- nor group-readable). The environment
+variable "HOME" is used to find the home directory.
+
+On Windows two filenames in the home directory are checked: *.netrc* and
+*_netrc*, preferring the former. Older versions on Windows checked for *_netrc*
+only.
 
 A quick and simple example of how to setup a *.netrc* to allow curl to FTP to
 the machine host.domain.com with user name 'myself' and password 'secret'
index 8625b8ed7f80817773ec0266e1667e44c1e2a46f..6d60477779d7909c53a40db438a7477ef8776d8a 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -2719,7 +2719,9 @@ static CURLcode override_login(struct Curl_easy *data,
                           data->set.str[STRING_NETRC_FILE]);
     if(ret > 0) {
       infof(data, "Couldn't find host %s in the %s file; using defaults",
-            conn->host.name, data->set.str[STRING_NETRC_FILE]);
+            conn->host.name,
+            (data->set.str[STRING_NETRC_FILE] ?
+             data->set.str[STRING_NETRC_FILE] : ".netrc"));
     }
     else if(ret < 0) {
       failf(data, ".netrc parser error");