1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
diff -ru apt-0.7.25.3/apt-pkg/contrib/netrc.cc apt-0.7.25.3+iPhone/apt-pkg/contrib/netrc.cc
--- apt-0.7.25.3/apt-pkg/contrib/netrc.cc 2010-02-01 19:44:40.000000000 +0000
+++ apt-0.7.25.3+iPhone/apt-pkg/contrib/netrc.cc 2010-02-22 18:26:01.000000000 +0000
@@ -40,13 +40,13 @@
#define NETRC DOT_CHAR "netrc"
/* returns -1 on failure, 0 if the host is found, 1 is the host isn't found */
-int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL)
+int parsenetrc (const char *host, char *login, char *password, const char *netrcfile = NULL)
{
FILE *file;
int retcode = 1;
int specific_login = (login[0] != 0);
char *home = NULL;
- bool netrc_alloc = false;
+ char *netrc_alloc = NULL;
int state = NOTHING;
char state_login = 0; /* Found a login keyword */
@@ -67,11 +67,11 @@
if (!home)
return -1;
- asprintf (&netrcfile, "%s%s%s", home, DIR_CHAR, NETRC);
- if(!netrcfile)
+ asprintf (&netrc_alloc, "%s%s%s", home, DIR_CHAR, NETRC);
+ if(!netrc_alloc)
return -1;
else
- netrc_alloc = true;
+ netrcfile = netrc_alloc;
}
file = fopen (netrcfile, "r");
@@ -144,7 +144,7 @@
}
if (netrc_alloc)
- free(netrcfile);
+ free(netrc_alloc);
return retcode;
}
@@ -160,11 +160,11 @@
{
char login[64] = "";
char password[64] = "";
- char *netrcfile = strdupa (NetRCFile.c_str ());
+ const char *netrcfile = NetRCFile.c_str ();
// first check for a generic host based netrc entry
- char *host = strdupa (Uri.Host.c_str ());
- if (host && parsenetrc (host, login, password, netrcfile) == 0)
+ const char *host = Uri.Host.c_str ();
+ if (parsenetrc (host, login, password, netrcfile) == 0)
{
if (_config->FindB("Debug::Acquire::netrc", false) == true)
std::clog << "host: " << host
@@ -179,7 +179,8 @@
// 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 ());
+ std::string temp(Uri.Host+Uri.Path);
+ const char *hostpath = temp.c_str ();
if (hostpath && parsenetrc (hostpath, login, password, netrcfile) == 0)
{
if (_config->FindB("Debug::Acquire::netrc", false) == true)
diff -ru apt-0.7.25.3/apt-pkg/contrib/netrc.h apt-0.7.25.3+iPhone/apt-pkg/contrib/netrc.h
--- apt-0.7.25.3/apt-pkg/contrib/netrc.h 2010-02-01 19:44:40.000000000 +0000
+++ apt-0.7.25.3+iPhone/apt-pkg/contrib/netrc.h 2010-02-22 18:23:20.000000000 +0000
@@ -23,7 +23,7 @@
// If login[0] = 0, search for login and password within a machine section
// in the netrc.
// If login[0] != 0, search for password within machine and login.
-int parsenetrc (char *host, char *login, char *password, char *filename);
+int parsenetrc (const char *host, char *login, char *password, const char *filename);
void maybe_add_auth (URI &Uri, string NetRCFile);
#endif
|