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";
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";
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);
177 const string & username =
url.getUsername();
181 if (
url.asString(vopt).find((*it)->url().asString(vopt)) == 0)
183 if (username.empty() || username == (*it)->username())
207 result =
findIn(_credsGlobal,
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();
254 std::ofstream fs(file.
c_str());
258 for_(it, creds.begin(), creds.end())
260 (*it)->dumpAsIniOn(fs);
294 string credfile =
url.getQueryParam(
"credentials");
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());
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'.
const char * c_str() const
String representation.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
std::string basename() const
Return the last component of this path.
Url::asString() view options.
bool empty() const
Test for an empty path.
std::string getQueryParam(const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
int unlink(const Pathname &path)
Like 'unlink'.
bool isExist() const
Return whether valid stat info exists.
Pathname dirname() const
Return all but the last component od this path.
Interim helper class to collect global options and settings.
bool absolute() const
Test for an absolute path.
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.
Wrapper class for ::stat/::lstat.
#define USER_CREDENTIALS_FILE
Easy-to use interface to the ZYPP dependency resolver.