Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147405369
D9678.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D9678.diff
View Options
Index: head/lib/libfetch/common.c
===================================================================
--- head/lib/libfetch/common.c
+++ head/lib/libfetch/common.c
@@ -1339,16 +1339,11 @@
return (word);
}
-/*
- * Get authentication data for a URL from .netrc
- */
-int
-fetch_netrc_auth(struct url *url)
+static int
+fetch_netrc_open(void)
{
+ const char *p;
char fn[PATH_MAX];
- const char *word;
- char *p;
- FILE *f;
if ((p = getenv("NETRC")) != NULL) {
if (snprintf(fn, sizeof(fn), "%s", p) >= (int)sizeof(fn)) {
@@ -1368,8 +1363,25 @@
return (-1);
}
- if ((f = fopen(fn, "r")) == NULL)
+ return (open(fn, O_RDONLY));
+}
+
+/*
+ * Get authentication data for a URL from .netrc
+ */
+int
+fetch_netrc_auth(struct url *url)
+{
+ const char *word;
+ FILE *f;
+
+ if (url->netrcfd == -2)
+ url->netrcfd = fetch_netrc_open();
+ if (url->netrcfd < 0)
+ return (-1);
+ if ((f = fdopen(url->netrcfd, "r")) == NULL)
return (-1);
+ rewind(f);
while ((word = fetch_read_word(f)) != NULL) {
if (strcmp(word, "default") == 0) {
DEBUG(fetch_info("Using default .netrc settings"));
Index: head/lib/libfetch/fetch.h
===================================================================
--- head/lib/libfetch/fetch.h
+++ head/lib/libfetch/fetch.h
@@ -47,6 +47,7 @@
off_t offset;
size_t length;
time_t ims_time;
+ int netrcfd;
};
struct url_stat {
Index: head/lib/libfetch/fetch.c
===================================================================
--- head/lib/libfetch/fetch.c
+++ head/lib/libfetch/fetch.c
@@ -284,6 +284,7 @@
seturl(pwd);
#undef seturl
u->port = port;
+ u->netrcfd = -2;
return (u);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 11, 5:31 PM (14 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29545270
Default Alt Text
D9678.diff (1 KB)
Attached To
Mode
D9678: Allow to setting a fd for netrc in advance to allow dropping privileges
Attached
Detach File
Event Timeline
Log In to Comment