25 #define USER_CREDENTIALS_FILE ".zypp/credentials.cat"
43 AuthDataComparator::operator()(
47 url::ViewOption::DEFAULTS
48 - url::ViewOption::WITH_USERNAME
49 - url::ViewOption::WITH_PASSWORD
50 - url::ViewOption::WITH_QUERY_STR;
52 if (lhs->username() != rhs->username())
55 if (lhs->url().asString(vopt) != rhs->url().asString(vopt))
67 CredManagerOptions::CredManagerOptions(
const Pathname & rootdir)
68 : globalCredFilePath(rootdir /
ZConfig::instance().credentialsGlobalFile())
69 , customCredFileDir(rootdir /
ZConfig::instance().credentialsGlobalDir())
71 char * homedir = getenv(
"HOME");
119 , _globalDirty(false)
129 if (_options.globalCredFilePath.empty())
130 DBG <<
"global cred file not known";
131 else if (PathInfo(_options.globalCredFilePath).isExist())
143 DBG <<
"global cred file does not exist";
145 _credsGlobal = _credsTmp; _credsTmp.clear();
146 DBG <<
"Got " << _credsGlobal.size() <<
" global records." << endl;
152 if (_options.userCredFilePath.empty())
153 DBG <<
"user cred file not known";
154 else if (PathInfo(_options.userCredFilePath).isExist())
165 DBG <<
"user cred file does not exist" << endl;
167 _credsUser = _credsTmp; _credsTmp.clear();
168 DBG <<
"Got " << _credsUser.size() <<
" user records." << endl;
174 _credsTmp.insert(cred);
187 if (url.
asString(vopt).find((*it)->url().asString(vopt)) == 0)
189 if (username.empty() || username == (*it)->username())
213 result =
findIn(_credsGlobal, url, vopt);
217 result =
findIn(_credsUser, url, vopt);
220 DBG <<
"Found credentials for '" << url <<
"':" << endl << *result;
222 DBG <<
"No credentials for '" << url <<
"'" << endl;
238 credfile = _options.customCredFileDir / file.basename();
241 if (_credsTmp.empty())
242 WAR << file <<
" does not contain valid credentials or is not readable." << endl;
245 result = *_credsTmp.begin();
254 const Pathname & file,
260 std::ofstream fs(file.c_str());
264 for_(it, creds.begin(), creds.end())
266 (*it)->dumpAsIniOn(fs);
301 if (credfile.empty())
314 if (credfile.empty())
329 else if ((*ret.first)->password() != cred.
password())
345 else if ((*ret.first)->password() != cred.
password())
383 c_ptr->setUrl(
Url());
388 if (credFile.absolute())
397 ERR <<
"error saving the credentials" << endl;
407 ERR <<
"could not delete user credentials file "
414 ERR <<
"could not delete global credentials file"