libzypp 17.36.7

curlhelper.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include "private/curlhelper_p.h"
13
14#include <zypp-core/Globals.h>
15
16#include <zypp-core/fs/PathInfo.h>
17#include <zypp-core/Pathname.h>
18#include <zypp-core/base/LogTools.h>
19#include <zypp-core/base/String.h>
20#include <zypp-core/base/StringV.h>
21#include <zypp-curl/ProxyInfo>
22#include <zypp-curl/auth/CurlAuthData>
23#include <zypp-media/MediaException>
24#include <string>
25#include <glib.h>
26
27#define TRANSFER_TIMEOUT_MAX 60 * 60
28
29 using std::endl;
30 using namespace zypp;
31
32 namespace zypp
33{
34 namespace env
35 {
36 const long & ZYPP_MEDIA_CURL_DEBUG()
37 {
38 static const long ret = [](){
39 const char * env = getenv("ZYPP_MEDIA_CURL_DEBUG");
40 return env && *env ? str::strtonum<ulong>( env ) : 0;
41 }();
42 return ret;
43 }
44
45 int ZYPP_MEDIA_CURL_IPRESOLVE()
46 {
47 static int _v = [](){
48 int ret = 0;
49 if ( const char * envp = getenv( "ZYPP_MEDIA_CURL_IPRESOLVE" ) ) {
50 WAR << "env set: $ZYPP_MEDIA_CURL_IPRESOLVE='" << envp << "'" << std::endl;
51 if ( strcmp( envp, "4" ) == 0 ) ret = 4;
52 else if ( strcmp( envp, "6" ) == 0 ) ret = 6;
53 }
54 return ret;
55 }();
56 return _v;
57 }
58 } // namespace env
59} // namespace zypp
60
61 namespace internal
62{
63
64 void globalInitCurlOnce()
65{
66 // function-level static <=> std::call_once
67 static bool once __attribute__ ((__unused__)) = ( [] {
68 MIL << "global_init libcurl: build version: (" << LIBCURL_VERSION << "), runtime version: (" << curl_version_info(CURLVERSION_NOW)->version << ") " << endl;
69 if ( curl_global_init( CURL_GLOBAL_ALL ) != 0 )
70 WAR << "curl global init failed" << std::endl;
71 } (), true );
72}
73
74uint curlVersion()
75{
76 auto curlV = curl_version_info ( CURLVERSION_NOW );
77 return curlV->version_num;
78}
79
80 int log_curl( CURL * curl, curl_infotype info, char * ptr, size_t len, void * max_lvl )
81{
82 if ( max_lvl == nullptr )
83 return 0;
84
85 long maxlvl = *(static_cast<long*>(max_lvl));
86 const char * pfx = "";
87 bool isContent = true; // otherwise it's data
88 switch( info )
89 {
90 case CURLINFO_TEXT: if ( maxlvl < 1 ) return 0; pfx = "*"; break;
91 case CURLINFO_HEADER_IN: if ( maxlvl < 2 ) return 0; pfx = "<"; break;
92 case CURLINFO_HEADER_OUT: if ( maxlvl < 2 ) return 0; pfx = ">"; break;
93 case CURLINFO_SSL_DATA_IN: if ( maxlvl < 3 ) return 0; isContent = false; pfx = "<[SSL]"; break;
94 case CURLINFO_SSL_DATA_OUT: if ( maxlvl < 3 ) return 0; isContent = false; pfx = ">[SSL]"; break;
95 case CURLINFO_DATA_IN: if ( maxlvl < 3 ) return 0; isContent = false; pfx = "<[DTA]"; break;
96 case CURLINFO_DATA_OUT: if ( maxlvl < 3 ) return 0; isContent = false; pfx = ">[DTA]"; break;
97
98 default:
99 return 0;
100 }
101
102 // We'd like to keep all log messages within function `log_curl`
103 // because this tag to grep for is known and communicate to users.
104 if ( isContent ) {
105 std::vector<std::string_view> lines; // don't want log from within the lambda
106 strv::split( std::string_view( ptr, len ), "\n", [&lines]( std::string_view line, unsigned, bool last ) {
107 if ( last ) return; // empty word after final \n
108 line = strv::rtrim( line, "\r" );
109 lines.push_back( line );
110 });
111 for ( const auto & line : lines ) {
112 if ( str::hasPrefix( line, "Authorization:" ) ) {
113 std::string_view::size_type pos { line.find( " ", 15 ) }; // Authorization: <type> <credentials>
114 if ( pos == std::string::npos )
115 pos = 15;
116 DBG << curl << " " << pfx << " " << line.substr( 0, pos ) << " <credentials removed>" << endl;
117 }
118 else
119 DBG << curl << " " << pfx << " " << line << endl;
120 }
121 } else {
122 if ( maxlvl < 4 )
123 DBG << curl << " " << pfx << " " << len << " byte" << endl;
124 else
125 hexdumpOn( DBG << curl << " " << pfx << " ", ptr, len );
126 }
127 return 0;
128}
129
130 void setupZYPP_MEDIA_CURL_DEBUG( CURL *curl )
131{
132 if ( not curl ) {
133 INT << "Got a NULL curl handle" << endl;
134 return;
135 }
136 if ( env::ZYPP_MEDIA_CURL_DEBUG() > 0 ) {
137 curl_easy_setopt( curl, CURLOPT_VERBOSE, 1L );
138 curl_easy_setopt( curl, CURLOPT_DEBUGFUNCTION, log_curl );
139 curl_easy_setopt( curl, CURLOPT_DEBUGDATA, &env::ZYPP_MEDIA_CURL_DEBUG() );
140 }
141}
142
143 size_t log_redirects_curl( char *ptr, size_t size, size_t nmemb, void *userdata)
144{
145 //INT << "got header: " << std::string(ptr, ptr + size*nmemb) << endl;
146
147 char * lstart = ptr, * lend = ptr;
148 size_t pos = 0;
149 size_t max = size * nmemb;
150 while (pos + 1 < max)
151 {
152 // get line
153 for (lstart = lend; *lend != '\n' && pos < max; ++lend, ++pos);
154
155 // look for "Location"
156 if ( strncasecmp( lstart, "Location:", 9 ) == 0 )
157 {
158 std::string line { lstart, *(lend-1)=='\r' ? lend-1 : lend };
159 DBG << "redirecting to " << line << std::endl;
160 if ( userdata ) {
161 *reinterpret_cast<std::string *>( userdata ) = line;
162 }
163 return max;
164 }
165
166 // continue with the next line
167 if (pos + 1 < max)
168 {
169 ++lend;
170 ++pos;
171 }
172 else
173 break;
174 }
175
176 return max;
177}
178
183 void fillSettingsFromUrl( const Url &url, media::TransferSettings &s )
184{
185 {
186 const std::string & param { url.getQueryParam("timeout") };
187 if( ! param.empty() )
188 {
189 long num = str::strtonum<long>(param);
190 if( num >= 0 && num <= TRANSFER_TIMEOUT_MAX )
191 s.setTimeout( num );
192 }
193 }
194 {
195 std::string param { url.getUsername() };
196 if ( ! param.empty() )
197 {
198 s.setUsername( std::move(param) );
199 param = url.getPassword();
200 if ( ! param.empty() )
201 s.setPassword( std::move(param) );
202 }
203 else
204 {
205 // if there is no username, set anonymous auth
206 if ( ( url.getScheme() == "ftp" || url.getScheme() == "tftp" ) && s.username().empty() )
207 s.setAnonymousAuth();
208 }
209 }
210 if ( url.getScheme() == "https" )
211 {
212 s.setVerifyPeerEnabled( false );
213 s.setVerifyHostEnabled( false );
214
215 const std::string & verify { url.getQueryParam("ssl_verify") };
216 if( verify.empty() || verify == "yes" )
217 {
218 s.setVerifyPeerEnabled( true );
219 s.setVerifyHostEnabled( true );
220 }
221 else if ( verify == "no" )
222 {
223 s.setVerifyPeerEnabled( false );
224 s.setVerifyHostEnabled( false );
225 }
226 else
227 {
228 std::vector<std::string> flags;
229 str::split( verify, std::back_inserter(flags), "," );
230 for ( const auto & flag : flags )
231 {
232 if ( flag == "host" )
233 s.setVerifyHostEnabled( true );
234 else if ( flag == "peer" )
235 s.setVerifyPeerEnabled( true );
236 else
237 ZYPP_THROW( media::MediaBadUrlException(url, "Unknown ssl_verify flag "+flag) );
238 }
239 }
240 }
241 {
242 Pathname ca_path { url.getQueryParam("ssl_capath") };
243 if( ! ca_path.empty() )
244 {
245 if( ! PathInfo(ca_path).isDir() || ! ca_path.absolute() )
246 ZYPP_THROW(media::MediaBadUrlException(url, "Invalid ssl_capath path"));
247 else
248 s.setCertificateAuthoritiesPath( std::move(ca_path) );
249 }
250 }
251 {
252 Pathname client_cert { url.getQueryParam("ssl_clientcert") };
253 if( ! client_cert.empty() )
254 {
255 if( ! PathInfo(client_cert).isFile() || ! client_cert.absolute() )
256 ZYPP_THROW(media::MediaBadUrlException(url, "Invalid ssl_clientcert file"));
257 else
258 s.setClientCertificatePath( std::move(client_cert) );
259 }
260 }
261 {
262 Pathname client_key { url.getQueryParam("ssl_clientkey") };
263 if( ! client_key.empty() )
264 {
265 if( ! PathInfo(client_key).isFile() || ! client_key.absolute() )
266 ZYPP_THROW(media::MediaBadUrlException(url, "Invalid ssl_clientkey file"));
267 else
268 s.setClientKeyPath( std::move(client_key) );
269 }
270 }
271 {
272 std::string param { url.getQueryParam( "proxy" ) };
273 if ( ! param.empty() )
274 {
275 if ( param == EXPLICITLY_NO_PROXY ) {
276 // Workaround TransferSettings shortcoming: With an
277 // empty proxy string, code will continue to look for
278 // valid proxy settings. So set proxy to some non-empty
279 // string, to indicate it has been explicitly disabled.
280 s.setProxy(EXPLICITLY_NO_PROXY);
281 s.setProxyEnabled(false);
282 }
283 else {
284 const std::string & proxyport { url.getQueryParam( "proxyport" ) };
285 if ( ! proxyport.empty() ) {
286 param += ":";
287 param += proxyport;
288 }
289 s.setProxy( std::move(param) );
290 s.setProxyEnabled( true );
291 }
292 }
293 }
294 {
295 std::string param { url.getQueryParam( "proxyuser" ) };
296 if ( ! param.empty() )
297 {
298 s.setProxyUsername( std::move(param) );
299 s.setProxyPassword( url.getQueryParam( "proxypass" ) );
300 }
301 }
302 {
303 // HTTP authentication type
304 std::string param { url.getQueryParam("auth") };
305 if ( ! param.empty() && (url.getScheme() == "http" || url.getScheme() == "https") )
306 {
307 try
308 {
309 media::CurlAuthData::auth_type_str2long (param ); // check if we know it
310 }
311 catch ( const media::MediaException & ex_r )
312 {
313 DBG << "Rethrowing as MediaUnauthorizedException.";
314 ZYPP_THROW(media::MediaUnauthorizedException(url, ex_r.msg(), "", ""));
315 }
316 s.setAuthType( std::move(param) );
317 }
318 }
319 {
320 // workarounds
321 const std::string & param { url.getQueryParam("head_requests") };
322 if( ! param.empty() && param == "no" )
323 s.setHeadRequestsAllowed( false );
324 }
325 {
326 const auto &cookieFileParam = url.getQueryParam( "cookies" );
327 if ( !cookieFileParam.empty() && str::strToBool( cookieFileParam, true ) )
328 s.setEnableCookieFile ( true );
329 else
330 s.setEnableCookieFile ( false );
331 }
332}
333
338 void fillSettingsSystemProxy( const Url& url, media::TransferSettings &s )
339{
340 media::ProxyInfo proxy_info;
341 if ( proxy_info.useProxyFor( url ) )
342 {
343 // We must extract any 'user:pass' from the proxy url
344 // otherwise they won't make it into curl (.curlrc wins).
345 try {
346 Url u( proxy_info.proxy( url ) );
347 s.setProxy( u.asString( url::ViewOption::WITH_SCHEME + url::ViewOption::WITH_HOST + url::ViewOption::WITH_PORT ) );
348 // don't overwrite explicit auth settings
349 if ( s.proxyUsername().empty() )
350 {
351 s.setProxyUsername( u.getUsername( url::E_ENCODED ) );
352 s.setProxyPassword( u.getPassword( url::E_ENCODED ) );
353 }
354 s.setProxyEnabled( true );
355 }
356 catch (...) {} // no proxy if URL is malformed
357 }
358}
359
360 void curlEscape( std::string & str_r,
361 const char char_r, const std::string & escaped_r ) {
362 for ( std::string::size_type pos = str_r.find( char_r );
363 pos != std::string::npos; pos = str_r.find( char_r, pos ) ) {
364 str_r.replace( pos, 1, escaped_r );
365 }
366}
367
368std::string curlEscapedPath( std::string path_r ) {
369 curlEscape( path_r, ' ', "%20" );
370 return path_r;
371}
372
373std::string curlUnEscape( const std::string& text_r ) {
374 char * tmp = curl_unescape( text_r.c_str(), 0 );
375 std::string ret( tmp );
376 curl_free( tmp );
377 return ret;
378}
379
380 Url clearQueryString(const Url &url)
381{
382 Url curlUrl (url);
383 curlUrl.setUsername( "" );
384 curlUrl.setPassword( "" );
385 curlUrl.setPathParams( "" );
386 curlUrl.setFragment( "" );
387 curlUrl.delQueryParams( {
388 "cookies",
389 "proxy",
390 "proxyport",
391 "proxyuser",
392 "proxypass",
393 "ssl_capath",
394 "ssl_verify",
395 "ssl_clientcert",
396 "ssl_clientkey",
397 "timeout",
398 "auth",
399 "username",
400 "password",
401 "mediahandler",
402 "credentials",
403 "head_requests",
404 "mediahandler",
405 } );
406 return curlUrl;
407}
408
409// bsc#933839: propagate proxy settings passed in the repo URL
410// boo#1127591: propagate ssl settings passed in the repo URL
411 zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r )
412{
413 using namespace std::literals::string_literals;
414 for ( const std::string &param : { "proxy"s, "proxyport"s, "proxyuser"s, "proxypass"s, "ssl_capath"s, "ssl_verify"s } )
415 {
416 const std::string & value( template_r.getQueryParam( param ) );
417 if ( ! value.empty() )
418 url_r.setQueryParam( param, value );
419 }
420 return url_r;
421}
422
423 CurlPollHelper::CurlPollHelper(CurlPoll &p) : _parent(p) {
424 curl_multi_setopt( _parent._multi, CURLMOPT_SOCKETFUNCTION, socketcb );
425 curl_multi_setopt( _parent._multi, CURLMOPT_SOCKETDATA, this );
426 curl_multi_setopt( _parent._multi, CURLMOPT_TIMERFUNCTION, timercb );
427 curl_multi_setopt( _parent._multi, CURLMOPT_TIMERDATA, this );
428}
429
430 CurlPollHelper::~CurlPollHelper() {
431 curl_multi_setopt( _parent._multi, CURLMOPT_SOCKETFUNCTION, nullptr );
432 curl_multi_setopt( _parent._multi, CURLMOPT_SOCKETDATA, nullptr );
433 curl_multi_setopt( _parent._multi, CURLMOPT_TIMERFUNCTION, nullptr );
434 curl_multi_setopt( _parent._multi, CURLMOPT_TIMERDATA, nullptr );
435}
436
437 int CurlPollHelper::socketcb(CURL *easy, curl_socket_t s, int what, CurlPollHelper *userp, void *sockp) {
438 auto it = std::find_if( userp->socks.begin(), userp->socks.end(), [&]( const GPollFD &fd){ return fd.fd == s; });
439 gushort events = 0;
440 if ( what == CURL_POLL_REMOVE ) {
441 if ( it == userp->socks.end() ) {
442 WAR << "Ignoring unknown socket in static_socketcb" << std::endl;
443 return 0;
444 }
445 userp->socks.erase(it);
446 return 0;
447 } else if ( what == CURL_POLL_IN ) {
448 events = G_IO_IN | G_IO_HUP | G_IO_ERR;
449 } else if ( what == CURL_POLL_OUT ) {
450 events = G_IO_OUT | G_IO_ERR;
451 } else if ( what == CURL_POLL_INOUT ) {
452 events = G_IO_IN | G_IO_OUT | G_IO_HUP | G_IO_ERR;
453 }
454
455 if ( it != userp->socks.end() ) {
456 it->events = events;
457 it->revents = 0;
458 } else {
459 userp->socks.push_back(
460 GPollFD{
461 .fd = s,
462 .events = events,
463 .revents = 0
464 }
465 );
466 }
467 return 0;
468}
469
470 int CurlPollHelper::timercb(CURLM *, long timeout_ms, CurlPollHelper *thatPtr) {
471 if ( !thatPtr )
472 return 0;
473 if ( timeout_ms == -1 )
474 thatPtr->timeout_ms.reset(); // curl wants to delete its timer
475 else
476 thatPtr->timeout_ms = timeout_ms; // maximum time curl wants us to sleep
477 return 0;
478}
479
480CURLMcode internal::CurlPollHelper::handleSocketActions( const std::vector<GPollFD> &actionsFds , int first )
481{
482 for ( size_t sock = first; sock < actionsFds.size(); sock++ ) {
483 const auto &waitFd = actionsFds[sock];
484 if ( waitFd.revents == 0 )
485 continue;
486
487 int ev = 0;
488 if ( (waitFd.revents & G_IO_HUP) == G_IO_HUP
489 || (waitFd.revents & G_IO_IN) == G_IO_IN ) {
490 ev = CURL_CSELECT_IN;
491 }
492 if ( (waitFd.revents & G_IO_OUT) == G_IO_OUT ) {
493 ev |= CURL_CSELECT_OUT;
494 }
495 if ( (waitFd.revents & G_IO_ERR) == G_IO_ERR ) {
496 ev |= CURL_CSELECT_ERR;
497 }
498
499 int runn = 0;
500 CURLMcode mcode = curl_multi_socket_action( _parent._multi, waitFd.fd, ev, &runn );
501 if (mcode != CURLM_OK)
502 return mcode;
503 }
504 return CURLM_OK;
505}
506
507CURLMcode internal::CurlPollHelper::handleTimout()
508{
509 int handles = 0;
510 return curl_multi_socket_action( _parent._multi, CURL_SOCKET_TIMEOUT, 0, &handles );
511}
512
523CURLcode setCurlRedirProtocols(CURL *curl)
524{
525#if CURLVERSION_AT_LEAST(7,19,4)
526#if CURLVERSION_AT_LEAST(7,85,0)
527 // runtime version might be different from build version
528 if( ::internal::curlVersion() >= CURL_VERSION_BITS(7,85,0) ) {
529 return curl_easy_setopt ( curl, CURLOPT_REDIR_PROTOCOLS_STR, "https" );
530 } else {
531 return curl_easy_setopt ( curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS );
532 }
533#else
534 return curl_easy_setopt ( curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS );
535#endif
536#endif // #if CURLVERSION_AT_LEAST(7,19,4)
537 return CURLE_OK;
538}
539
540}
GPollFD
struct _GPollFD GPollFD
Definition ZYppImpl.h:26
zypp::Exception::msg
const std::string & msg() const
Return the message string provided to the ctor.
Definition Exception.h:196
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::Url::delQueryParams
void delQueryParams(const std::set< std::string > &params)
remove multiple query parameters at once
Definition Url.cc:891
zypp::Url::asString
std::string asString() const
Returns a default string representation of the Url object.
Definition Url.cc:515
zypp::Url::getUsername
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
Definition Url.cc:590
zypp::Url::setFragment
void setFragment(const std::string &fragment, EEncoding eflag=zypp::url::E_DECODED)
Set the fragment string in the URL.
Definition Url.cc:740
zypp::Url::getQueryParam
std::string getQueryParam(const std::string &param, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
Definition Url.cc:678
zypp::Url::setPassword
void setPassword(const std::string &pass, EEncoding eflag=zypp::url::E_DECODED)
Set the password in the URL authority.
Definition Url.cc:757
zypp::Url::setPathParams
void setPathParams(const std::string &params)
Set the path parameters.
Definition Url.cc:831
zypp::Url::setQueryParam
void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition Url.cc:878
zypp::Url::setUsername
void setUsername(const std::string &user, EEncoding eflag=zypp::url::E_DECODED)
Set the username in the URL authority.
Definition Url.cc:748
zypp::Url::getPassword
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.
Definition Url.cc:598
zypp::filesystem::PathInfo
Wrapper class for stat/lstat.
Definition PathInfo.h:226
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::media::CurlAuthData::auth_type_str2long
static long auth_type_str2long(std::string &auth_type_str)
Converts a string of comma separated list of authetication type names into a long of ORed CURLAUTH_* ...
Definition curlauthdata.cc:50
zypp::media::MediaBadUrlException
Definition mediaexception.h:288
zypp::media::MediaException
Just inherits Exception to separate media exceptions.
Definition mediaexception.h:37
zypp::media::MediaUnauthorizedException
Definition mediaexception.h:446
zypp::media::ProxyInfo
Definition proxyinfo.h:30
zypp::media::ProxyInfo::useProxyFor
bool useProxyFor(const Url &url_r) const
Return true if enabled and url_r does not match noProxy.
Definition proxyinfo.cc:56
zypp::media::ProxyInfo::proxy
std::string proxy(const Url &url) const
Definition proxyinfo.cc:44
zypp::media::TransferSettings
Holds transfer setting.
Definition transfersettings.h:34
zypp::media::TransferSettings::setProxy
void setProxy(const std::string &val_r)
proxy to use if it is enabled
Definition transfersettings.cc:184
zypp::media::TransferSettings::setProxyEnabled
void setProxyEnabled(bool enabled)
whether the proxy is used or not
Definition transfersettings.cc:177
zypp::media::TransferSettings::setUsername
void setUsername(const std::string &val_r)
sets the auth username
Definition transfersettings.cc:143
zypp::media::TransferSettings::setProxyUsername
void setProxyUsername(const std::string &val_r)
sets the proxy user
Definition transfersettings.cc:194
zypp::media::TransferSettings::setHeadRequestsAllowed
void setHeadRequestsAllowed(bool allowed)
set whether HEAD requests are allowed
Definition transfersettings.cc:322
zypp::media::TransferSettings::setVerifyHostEnabled
void setVerifyHostEnabled(bool enabled)
Sets whether to verify host for ssl.
Definition transfersettings.cc:264
zypp::media::TransferSettings::setClientKeyPath
void setClientKeyPath(const Pathname &val_r)
Sets the SSL client key file.
Definition transfersettings.cc:287
zypp::media::TransferSettings::setClientCertificatePath
void setClientCertificatePath(const Pathname &val_r)
Sets the SSL client certificate file.
Definition transfersettings.cc:277
zypp::media::TransferSettings::setPassword
void setPassword(const std::string &val_r)
sets the auth password
Definition transfersettings.cc:152
zypp::media::TransferSettings::setVerifyPeerEnabled
void setVerifyPeerEnabled(bool enabled)
Sets whether to verify host for ssl.
Definition transfersettings.cc:271
zypp::media::TransferSettings::setAnonymousAuth
void setAnonymousAuth()
sets anonymous authentication (ie: for ftp)
Definition transfersettings.cc:170
zypp::media::TransferSettings::username
const std::string & username() const
auth username
Definition transfersettings.cc:149
zypp::media::TransferSettings::setEnableCookieFile
void setEnableCookieFile(bool enable=true)
Enable or disable the use of the cookie file.
Definition transfersettings.cc:296
zypp::media::TransferSettings::proxyUsername
const std::string & proxyUsername() const
proxy auth username
Definition transfersettings.cc:200
zypp::media::TransferSettings::setAuthType
void setAuthType(const std::string &val_r)
set the allowed authentication types
Definition transfersettings.cc:312
zypp::media::TransferSettings::setCertificateAuthoritiesPath
void setCertificateAuthoritiesPath(const Pathname &val_r)
Sets the SSL certificate authorities path.
Definition transfersettings.cc:302
zypp::media::TransferSettings::setProxyPassword
void setProxyPassword(const std::string &val_r)
sets the proxy password
Definition transfersettings.cc:203
zypp::media::TransferSettings::setTimeout
void setTimeout(long t)
set the transfer timeout
Definition transfersettings.cc:222
TRANSFER_TIMEOUT_MAX
#define TRANSFER_TIMEOUT_MAX
Definition curlhelper.cc:27
curlhelper_p.h
EXPLICITLY_NO_PROXY
#define EXPLICITLY_NO_PROXY
Definition curlhelper_p.h:23
internal
Definition OptionalDownloadProgressReport.cc:12
internal::fillSettingsFromUrl
void fillSettingsFromUrl(const Url &url, media::TransferSettings &s)
Fills the settings structure using options passed on the url for example ?timeout=x&proxy=foo.
Definition curlhelper.cc:183
internal::log_redirects_curl
size_t log_redirects_curl(char *ptr, size_t size, size_t nmemb, void *userdata)
Definition curlhelper.cc:143
internal::globalInitCurlOnce
void globalInitCurlOnce()
Definition curlhelper.cc:64
internal::curlVersion
uint curlVersion()
Definition curlhelper.cc:74
internal::propagateQueryParams
zypp::Url propagateQueryParams(zypp::Url url_r, const zypp::Url &template_r)
Definition curlhelper.cc:411
internal::curlUnEscape
std::string curlUnEscape(const std::string &text_r)
Definition curlhelper.cc:373
internal::setupZYPP_MEDIA_CURL_DEBUG
void setupZYPP_MEDIA_CURL_DEBUG(CURL *curl)
Setup CURLOPT_VERBOSE and CURLOPT_DEBUGFUNCTION according to env::ZYPP_MEDIA_CURL_DEBUG.
Definition curlhelper.cc:130
internal::curlEscapedPath
std::string curlEscapedPath(std::string path_r)
Definition curlhelper.cc:368
internal::setCurlRedirProtocols
CURLcode setCurlRedirProtocols(CURL *curl)
Definition curlhelper.cc:523
internal::fillSettingsSystemProxy
void fillSettingsSystemProxy(const Url &url, media::TransferSettings &s)
Reads the system proxy configuration and fills the settings structure proxy information.
Definition curlhelper.cc:338
internal::clearQueryString
Url clearQueryString(const Url &url)
Definition curlhelper.cc:380
internal::curlEscape
void curlEscape(std::string &str_r, const char char_r, const std::string &escaped_r)
Definition curlhelper.cc:360
internal::log_curl
int log_curl(CURL *curl, curl_infotype info, char *ptr, size_t len, void *max_lvl)
Definition curlhelper.cc:80
zypp::env
Namespace intended to collect all environment variables we use.
Definition Env.h:23
zypp::env::ZYPP_MEDIA_CURL_DEBUG
const long & ZYPP_MEDIA_CURL_DEBUG()
const long& for setting CURLOPT_DEBUGDATA Returns a reference to a static variable,...
Definition curlhelper.cc:36
zypp::env::ZYPP_MEDIA_CURL_IPRESOLVE
int ZYPP_MEDIA_CURL_IPRESOLVE()
4/6 to force IPv4/v6
Definition curlhelper.cc:45
zypp::str::hasPrefix
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition String.h:1026
zypp::str::strToBool
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Definition String.h:429
zypp::str::split
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", const Trim trim_r=NO_TRIM)
Split line_r into words.
Definition String.h:531
zypp::str::strtonum
TInt strtonum(const C_Str &str)
Parsing numbers from string.
zypp::url
Url details namespace.
Definition UrlBase.cc:58
zypp::url::E_ENCODED
@ E_ENCODED
Flag to request encoded string(s).
Definition UrlUtils.h:53
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::hexdumpOn
std::ostream & hexdumpOn(std::ostream &outs, const unsigned char *ptr, size_t size)
hexdump data on stream
Definition LogTools.h:472
internal::CurlPollHelper::CurlPoll
Definition curlhelper_p.h:74
internal::CurlPollHelper::socketcb
static int socketcb(CURL *easy, curl_socket_t s, int what, CurlPollHelper *userp, void *sockp)
Definition curlhelper.cc:437
internal::CurlPollHelper::CurlPollHelper
CurlPollHelper(CurlPoll &p)
Definition curlhelper.cc:423
internal::CurlPollHelper::handleSocketActions
CURLMcode handleSocketActions(const std::vector< GPollFD > &actionsFds, int first=0)
Definition curlhelper.cc:480
internal::CurlPollHelper::handleTimout
CURLMcode handleTimout()
Definition curlhelper.cc:507
internal::CurlPollHelper::~CurlPollHelper
~CurlPollHelper()
Definition curlhelper.cc:430
internal::CurlPollHelper::socks
std::vector< GPollFD > socks
Definition curlhelper_p.h:103
internal::CurlPollHelper::_parent
CurlPoll & _parent
Definition curlhelper_p.h:102
internal::CurlPollHelper::timeout_ms
std::optional< long > timeout_ms
Definition curlhelper_p.h:104
internal::CurlPollHelper::timercb
static int timercb(CURLM *, long timeout_ms, CurlPollHelper *thatPtr)
Definition curlhelper.cc:470
Globals.h
Provides API related macros.
Pathname.h
ZYPP_THROW
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:424
LogTools.h
DBG
#define DBG
Definition Logger.h:99
MIL
#define MIL
Definition Logger.h:100
WAR
#define WAR
Definition Logger.h:101
INT
#define INT
Definition Logger.h:104
StringV.h
String.h
PathInfo.h