25 #define USER_CREDENTIALS_FILE ".zypp/credentials.cat"
45 - url::ViewOption::WITH_USERNAME
46 - url::ViewOption::WITH_PASSWORD
47 - url::ViewOption::WITH_QUERY_STR;
49 int cmp = lhs->url().asString(vopt).compare( rhs->url().asString(vopt) );
51 cmp = lhs->username().compare( rhs->username() );
61 CredManagerOptions::CredManagerOptions(
const Pathname & rootdir)
62 : globalCredFilePath(rootdir /
ZConfig::instance().credentialsGlobalFile())
63 , customCredFileDir(rootdir /
ZConfig::instance().credentialsGlobalDir())
65 char * homedir = getenv(
"HOME");
113 , _globalDirty(false)
123 if (_options.globalCredFilePath.empty())
124 DBG <<
"global cred file not known";
125 else if (PathInfo(_options.globalCredFilePath).isExist())
137 DBG <<
"global cred file does not exist";
139 _credsGlobal = _credsTmp; _credsTmp.clear();
140 DBG <<
"Got " << _credsGlobal.size() <<
" global records." << endl;
146 if (_options.userCredFilePath.empty())
147 DBG <<
"user cred file not known";
148 else if (PathInfo(_options.userCredFilePath).isExist())
159 DBG <<
"user cred file does not exist" << endl;
161 _credsUser = _credsTmp; _credsTmp.clear();
162 DBG <<
"Got " << _credsUser.size() <<
" user records." << endl;
168 _credsTmp.insert(cred);
181 if (url.
asString(vopt).find((*it)->url().asString(vopt)) == 0)
183 if (username.empty() || username == (*it)->username())
207 result =
findIn(_credsGlobal, url, vopt);
211 result =
findIn(_credsUser, url, vopt);
214 DBG <<
"Found credentials for '" << url <<
"':" << endl << *result;
216 DBG <<
"No credentials for '" << url <<
"'" << endl;
232 credfile = _options.customCredFileDir / file.basename();
235 if (_credsTmp.empty())
236 WAR << file <<
" does not contain valid credentials or is not readable." << endl;
239 result = *_credsTmp.begin();
248 const Pathname & file,
254 std::ofstream fs(file.c_str());
258 for_(it, creds.begin(), creds.end())
260 (*it)->dumpAsIniOn(fs);
295 if (credfile.empty())
308 if (credfile.empty())
323 else if ((*ret.first)->password() != cred.
password())
339 else if ((*ret.first)->password() != cred.
password())
377 c_ptr->setUrl(
Url());
382 if (credFile.absolute())
391 ERR <<
"error saving the credentials" << endl;
401 ERR <<
"could not delete user credentials file "
408 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