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"
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
static const ViewOption WITH_USERNAME
Option to include username in the URL string.
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Url::asString() view options.
std::string asString() const
Returns a default string representation of the Url object.
int unlink(const Pathname &path)
Like 'unlink'.
Interim helper class to collect global options and settings.
std::string getQueryParam(const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
static const ViewOption WITH_QUERY_STR
Option to include query string in the URL string.
static const ViewOption WITH_PASSWORD
Option to include password in the URL string.
#define USER_CREDENTIALS_FILE