summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-12-07 10:35:32 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2009-12-07 10:35:32 +0100
commit278835da0bbab11f57a9938d4193b66067c6eff1 (patch)
tree8309841dba28de7d94fbd63f8aa27fa56ecd2828
parent01fc89305c7b5fc52d719c6898a9fdf03abf3ce6 (diff)
if "/" is found in the machine, do a uri.startswith(host) substring match to support multiple user/passwds on the same host
-rw-r--r--apt-pkg/contrib/netrc.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc
index 91fc7dfd7..d8027fc24 100644
--- a/apt-pkg/contrib/netrc.cc
+++ b/apt-pkg/contrib/netrc.cc
@@ -100,7 +100,10 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL)
}
break;
case HOSTFOUND:
- if (!strcasecmp (host, tok)) {
+ /* extended definition of a "machine" if we have a "/"
+ we match the start of the string (host.startswith(token) */
+ if ((strchr(host, '/') && strstr(host, tok) == host) ||
+ (!strcasecmp (host, tok))) {
/* and yes, this is our host! */
state = HOSTVALID;
retcode = 0; /* we did find our host */
@@ -173,9 +176,10 @@ void maybe_add_auth (URI &Uri, string NetRCFile)
return;
}
- // if host did not work, try Host+Path next
- // FIXME: with host+path we need to match url.startswith(host+path)
- char *hostpath = strdupa (flNotFile(Uri.Host+Uri.Path).c_str ());
+ // if host did not work, try Host+Path next, this will trigger
+ // a lookup uri.startswith(host) in the netrc file parser (because
+ // of the "/"
+ char *hostpath = strdupa (string(Uri.Host+Uri.Path).c_str ());
if (hostpath && parsenetrc (hostpath, login, password, netrcfile) == 0)
{
if (_config->FindB("Debug::Acquire::netrc", false) == true)