Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] Do not crash when the repository URL is not defined (bsc#1043218) #78

Merged
merged 6 commits into from
Jun 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/yast2-pkg-bindings-devel-doc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-pkg-bindings-devel-doc
Version: 3.2.3
Version: 3.2.4
Release: 0
License: GPL-2.0
Group: Documentation/HTML
Expand Down
6 changes: 6 additions & 0 deletions package/yast2-pkg-bindings.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Jun 21 12:16:39 UTC 2017 - lslezak@suse.cz

- Do not crash when the repository URL is not defined (bsc#1043218)
- 3.2.4

-------------------------------------------------------------------
Fri Jun 2 08:42:12 UTC 2017 - igonzalezsosa@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-pkg-bindings.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-pkg-bindings
Version: 3.2.3
Version: 3.2.4
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
27 changes: 3 additions & 24 deletions src/Callbacks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1464,14 +1464,7 @@ namespace ZyppRecipients {
if (callback._set)
{
callback.addInt(_pkg_ref.logFindAlias(repo.alias()));

std::string url;
if (repo.baseUrlsBegin() != repo.baseUrlsEnd())
{
url = repo.baseUrlsBegin()->asString();
}

callback.addStr(url);
callback.addStr(repo.url().asString());
callback.addStr(task.name());

callback.evaluate();
Expand Down Expand Up @@ -1528,14 +1521,7 @@ namespace ZyppRecipients {
{
// search Yast source ID
callback.addInt(_pkg_ref.logFindAlias(source.info().alias()));

std::string url;
if (source.info().baseUrlsBegin() != source.info().baseUrlsEnd())
{
url = source.info().baseUrlsBegin()->asString();
}

callback.addStr(url);
callback.addStr(source.info().url().asString());
callback.addSymbol(SrcReportErrorAsString(error));
callback.addStr(description);

Expand Down Expand Up @@ -1564,14 +1550,7 @@ namespace ZyppRecipients {
{
// search Yast source ID
callback.addInt(_pkg_ref.logFindAlias(source.info().alias()));

std::string url;
if (source.info().baseUrlsBegin() != source.info().baseUrlsEnd())
{
url = source.info().baseUrlsBegin()->asString();
}
callback.addStr(url);

callback.addStr(source.info().url().asString());
callback.addStr(task);
callback.addSymbol(SrcReportErrorAsString(error));
callback.addStr(reason);
Expand Down
6 changes: 1 addition & 5 deletions src/Package.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,7 @@ PkgFunctions::PkgMediaNames ()
y2warning("Name of repository '%lld' is empty, using URL", index);

// use URL as the product name
std::string name;
if ((*repoit)->repoInfo().baseUrlsBegin() != (*repoit)->repoInfo().baseUrlsEnd())
{
name = (*repoit)->repoInfo().baseUrlsBegin()->asString();
}
std::string name((*repoit)->repoInfo().url().asString());

// use alias if url is unknown
if (name.empty())
Expand Down
2 changes: 1 addition & 1 deletion src/Source_Create.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ PkgFunctions::createManagedSource( const zypp::Url & url_r,

y2milestone("Added source '%s': '%s', enabled: %s, autorefresh: %s",
repo.alias().c_str(),
repo.baseUrlsBegin()->asString().c_str(),
repo.url().asString().c_str(),
repo.enabled() ? "true" : "false",
repo.autorefresh() ? "true" : "false"
);
Expand Down
4 changes: 2 additions & 2 deletions src/Source_Get.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ PkgFunctions::SourceMediaData (const YCPInteger& id)
y2warning("Pkg::SourceMediaData() doesn't return \"media_id\" and \"media_vendor\" values anymore.");

// SourceMediaData returns URLs without password
if (repo->repoInfo().baseUrlsBegin() != repo->repoInfo().baseUrlsEnd())
if (!repo->repoInfo().baseUrlsEmpty())
{
data->add( YCPString("url"), YCPString(repo->repoInfo().baseUrlsBegin()->asString()));
data->add( YCPString("url"), YCPString(repo->repoInfo().url().asString()));

// add all base URLs
YCPList base_urls;
Expand Down
22 changes: 17 additions & 5 deletions src/Source_Load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,14 @@ PkgFunctions::SourceLoadImpl(PkgProgress &progress)
// do not autorefresh remote repositories when the network is not running
if (!network_is_running)
{
zypp::Url url = *((*it)->repoInfo().baseUrlsBegin());

if ((*it)->repoInfo().baseUrlsEmpty())
{
y2warning("No URL defined, skipping repository '%s'", (*it)->repoInfo().alias().c_str());
continue;
}

zypp::Url url = (*it)->repoInfo().url();

if (remoteRepo(url))
{
y2warning("No network connection, skipping autorefresh of remote repository %s (%s)",
Expand All @@ -286,11 +292,17 @@ PkgFunctions::SourceLoadImpl(PkgProgress &progress)
refresh_started_called = true;
}

zypp::RepoManager::RefreshCheckStatus ref_stat = repomanager->checkIfToRefreshMetadata((*it)->repoInfo(), *((*it)->repoInfo().baseUrlsBegin()));
if ((*it)->repoInfo().baseUrlsEmpty())
{
y2milestone("Skipping repository '%s' - URL not defined", (*it)->repoInfo().alias().c_str());
continue;
}

zypp::RepoManager::RefreshCheckStatus ref_stat = repomanager->checkIfToRefreshMetadata((*it)->repoInfo(), (*it)->repoInfo().url());

if (ref_stat != zypp::RepoManager::REFRESH_NEEDED)
{
y2internal("Skipping repository '%s' - refresh is not needed", (*it)->repoInfo().alias().c_str());
y2milestone("Skipping repository '%s' - refresh is not needed", (*it)->repoInfo().alias().c_str());
continue;
}

Expand Down Expand Up @@ -478,7 +490,7 @@ PkgFunctions::SourceStartManager (const YCPBoolean& enable)
stages.push_back(_("Refresh Sources"));
stages.push_back(_("Rebuild Cache"));
stages.push_back(_("Load Data"));

// 3 steps per repository (download, cache rebuild, load resolvables)
pkgprogress.Start(_("Loading the Package Manager..."), stages, _(HelpTexts::load_resolvables));
}
Expand Down
28 changes: 18 additions & 10 deletions src/Source_Resolvables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool PkgFunctions::LoadResolvablesFrom(YRepo_Ptr repo, const zypp::ProgressData:
prog.sendTo(progressrcv);
zypp::CombinedProgressData load_subprogress(prog, 100);

try
try
{
zypp::RepoManager* repomanager = CreateRepoManager();
bool refresh = true;
Expand All @@ -84,15 +84,23 @@ bool PkgFunctions::LoadResolvablesFrom(YRepo_Ptr repo, const zypp::ProgressData:
{
if (network_check)
{
zypp::Url url = *(repoinfo.baseUrlsBegin());

if (remoteRepo(url) && !NetworkDetected())
{
y2warning("No network connection, skipping autorefresh of remote repository %s (%s)",
repoinfo.alias().c_str(), url.asString().c_str());

refresh = false;
}
if (repoinfo.baseUrlsEmpty())
{
y2milestone("No URL defined, skipping repository '%s'", repoinfo.alias().c_str());
refresh = false;
}
else
{
zypp::Url url = repoinfo.url();

if (remoteRepo(url) && !NetworkDetected())
{
y2warning("No network connection, skipping autorefresh of remote repository %s (%s)",
repoinfo.alias().c_str(), url.asString().c_str());

refresh = false;
}
}
}

if (refresh)
Expand Down
4 changes: 2 additions & 2 deletions src/YRepo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ zypp::MediaSetAccess_Ptr & YRepo::mediaAccess()
if (!_maccess)
{
y2milestone("Creating new MediaSetAccess for url %s",
(*_repo.baseUrlsBegin()).asString().c_str());
_maccess = new zypp::MediaSetAccess(_repo.name(), *_repo.baseUrlsBegin()); // FIXME handle multiple baseUrls
_repo.url().asString().c_str());
_maccess = new zypp::MediaSetAccess(_repo.name(), _repo.url()); // FIXME handle multiple baseUrls
}

return _maccess;
Expand Down