1CURLOPT_NETRC(3) curl_easy_setopt options CURLOPT_NETRC(3)
2
3
4
6 CURLOPT_NETRC - request that .netrc is used
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NETRC, long level);
12
14 This parameter controls the preference level of libcurl between using
15 user names and passwords from your ~/.netrc file, relative to user
16 names and passwords in the URL supplied with CURLOPT_URL(3). On Win‐
17 dows, libcurl will use the file as %HOME%/_netrc, but you can also tell
18 libcurl a different file name to use with CURLOPT_NETRC_FILE(3).
19
20 libcurl uses a user name (and supplied or prompted password) supplied
21 with CURLOPT_USERPWD(3) or CURLOPT_USERNAME(3) in preference to any of
22 the options controlled by this parameter.
23
24 Only machine name, user name and password are taken into account (init
25 macros and similar things aren't supported).
26
27 libcurl does not verify that the file has the correct properties set
28 (as the standard Unix ftp client does). It should only be readable by
29 user.
30
31 level should be set to one of the values described below.
32
33
34 CURL_NETRC_OPTIONAL
35 The use of the ~/.netrc file is optional, and information in the
36 URL is to be preferred. The file will be scanned for the host
37 and user name (to find the password only) or for the host only,
38 to find the first user name and password after that machine,
39 which ever information is not specified.
40
41 Undefined values of the option will have this effect.
42
43 CURL_NETRC_IGNORED
44 The library will ignore the ~/.netrc file.
45
46 This is the default.
47
48 CURL_NETRC_REQUIRED
49 The use of the ~/.netrc file is required, and information in the
50 URL is to be ignored. The file will be scanned for the host and
51 user name (to find the password only) or for the host only, to
52 find the first user name and password after that machine, which
53 ever information is not specified.
54
56 CURL_NETRC_IGNORED
57
59 Most
60
62 CURL *curl = curl_easy_init();
63 if(curl) {
64 CURLcode ret;
65 curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/");
66 curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
67 ret = curl_easy_perform(curl);
68 }
69
71 Always
72
74 Returns CURLE_OK
75
77 CURLOPT_USERPWD(3), CURLOPT_USERNAME(3), CURLOPT_NETRC_FILE(3),
78
79
80
81libcurl 7.71.1 March 23, 2020 CURLOPT_NETRC(3)