#define NETRC DOT_CHAR "netrc"
/* returns -1 on failure, 0 if the host is found, 1 is the host isn't found */
#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)
+static int parsenetrc_string (char *host, std::string &login, std::string &password, char *netrcfile = NULL)
- asprintf (&netrcfile, "%s%s%s", home, DIR_CHAR, NETRC);
- if(!netrcfile)
+ if (asprintf (&netrcfile, "%s%s%s", home, DIR_CHAR, NETRC) == -1 || netrcfile == NULL)
int state = NOTHING;
char state_login = 0; /* Found a login keyword */
char state_password = 0; /* Found a password keyword */
int state = NOTHING;
char state_login = 0; /* Found a login keyword */
char state_password = 0; /* Found a password keyword */
char *netrcfile = strdup(NetRCFile.c_str());
// first check for a generic host based netrc entry
char *host = strdup(Uri.Host.c_str());
char *netrcfile = strdup(NetRCFile.c_str());
// first check for a generic host based netrc entry
char *host = strdup(Uri.Host.c_str());
- if (host && parsenetrc (host, login, password, netrcfile) == 0)
+ if (host && parsenetrc_string(host, login, password, netrcfile) == 0)
{
if (_config->FindB("Debug::Acquire::netrc", false) == true)
std::clog << "host: " << host
<< " user: " << login
{
if (_config->FindB("Debug::Acquire::netrc", false) == true)
std::clog << "host: " << host
<< " user: " << login
// a lookup uri.startswith(host) in the netrc file parser (because
// of the "/"
char *hostpath = strdup(string(Uri.Host+Uri.Path).c_str());
// a lookup uri.startswith(host) in the netrc file parser (because
// of the "/"
char *hostpath = strdup(string(Uri.Host+Uri.Path).c_str());
- if (hostpath && parsenetrc (hostpath, login, password, netrcfile) == 0)
+ if (hostpath && parsenetrc_string(hostpath, login, password, netrcfile) == 0)
{
if (_config->FindB("Debug::Acquire::netrc", false) == true)
std::clog << "hostpath: " << hostpath
<< " user: " << login
{
if (_config->FindB("Debug::Acquire::netrc", false) == true)
std::clog << "hostpath: " << hostpath
<< " user: " << login