16#include <zypp/base/Logger.h>
17#include <zypp/base/Gettext.h>
18#include <zypp/TmpPath.h>
19#include <zypp-core/KVMap>
20#include <zypp-media/Mount>
21#include <zypp-media/auth/AuthData>
22#include <zypp-media/auth/CredentialManager>
48 if ( spath_r.
empty() )
52 std::string::size_type sep = share.find(
"/", 1 );
53 if ( sep == std::string::npos )
54 share = share.erase( 0, 1 );
56 share = share.substr( 1, sep-1 );
59 while ( (sep = share.find(
"%2f" )) != std::string::npos ) {
60 share.replace( sep, 3,
"/" );
76 if ( spath_r.
empty() )
80 std::string::size_type sep = striped.find(
"/", 1 );
81 if ( sep == std::string::npos )
84 return striped.substr( sep );
102 const Pathname & attach_point_hint_r )
107 MIL <<
"MediaCIFS::MediaCIFS(" << url_r <<
", " << attach_point_hint_r <<
")" << endl;
136 std::string path =
"//";
146 DBG <<
"Using a shared media "
162 std::string mountpoint(
attachPoint().asString() );
171 if ( ! options.
has(
"rw" ) ) {
177 if ( workgroup.empty() )
179 if ( !workgroup.empty() )
180 options[
"domain"] = workgroup;
184 Mount::Options::iterator toEnv;
185 toEnv = options.find(
"username");
186 if ( toEnv != options.end() ) {
187 if ( username.empty() )
188 username = toEnv->second;
189 options.erase( toEnv );
192 toEnv = options.find(
"user");
193 if ( toEnv != options.end() ) {
194 if ( username.empty() )
195 username = toEnv->second;
196 options.erase( toEnv );
201 toEnv = options.find(
"password");
202 if ( toEnv != options.end() ) {
203 if ( password.empty() )
204 password = toEnv->second;
205 options.erase( toEnv );
208 toEnv = options.find(
"pass");
209 if ( toEnv != options.end() ) {
210 if ( password.empty() )
211 password = toEnv->second;
212 options.erase( toEnv );
215 if ( username.empty() || password.empty() )
220 username = c->username();
221 password = c->password();
225 bool firstTry =
true;
226 bool authRequired =
false;
239 if ( !username.empty() )
240 environment[
"USER"] = username;
241 if ( !password.empty() )
242 environment[
"PASSWD"] = password;
248 if ( !username.empty() || !password.empty() )
252 outs <<
"username=" << username << endl;
253 outs <<
"password=" << password << endl;
262 if ( options.
has(
"noguest" ) )
263 options.erase(
"noguest" );
275 mount.
mount( path, mountpoint,
"cifs",
292 while ( authRequired );
298 while( !(mountsucceeded=
isAttached()) && --limit)
301 if ( !mountsucceeded )
313 "Unable to verify that the media was mounted",
379 const Pathname & dirname,
bool dots )
const
393 const Pathname & dirname,
bool dots )
const
420 smbcred->setUsername(cmcred->username());
427 _(
"Authentication required for '%s'"),
_url.
asString().c_str());
430 if (auth_report->prompt(
_url, prompt_msg, *smbcred))
432 DBG <<
"callback answer: retry" << endl
433 <<
"AuthData: " << *smbcred << endl;
435 if (smbcred->valid())
450 DBG <<
"callback answer: cancel" << endl;
459 cmcred->setUrl(
_url);
std::string asString() const
Returns a default string representation of the Url object.
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
std::string getQueryParam(const std::string ¶m, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
std::string getHost(EEncoding eflag=zypp::url::E_DECODED) const
Returns the hostname or IP from the URL authority.
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.
static ZConfig & instance()
Singleton ctor.
const std::string & asString() const
String representation.
bool empty() const
Test for an empty path.
Pathname absolutename() const
Return this path, adding a leading '/' if relative.
Provide a new empty temporary file and delete it when no longer needed.
Automaticaly deletes files or directories when no longer needed.
std::list< DirEntry > DirContent
Returned by readdir.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Easy-to use interface to the ZYPP dependency resolver.
A map of (key,value) strings.
std::string asString() const
bool has(const std::string &key_r) const
Test whether key is set.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.