From 1974b44e1c120753427b7bb0996ff87afa3bcf60 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Mon, 15 Sep 2008 10:31:17 +0000 Subject: [PATCH] - fixed --loose-auth and --loose-query for removeservice --- src/Zypper.cc | 2 ++ src/repos.cc | 53 +++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/Zypper.cc b/src/Zypper.cc index 54ddc9f..c9cf6a4 100644 --- a/src/Zypper.cc +++ b/src/Zypper.cc @@ -1013,6 +1013,8 @@ void Zypper::processCommandOptions() { static struct option options[] = { {"help", no_argument, 0, 'h'}, + {"loose-auth", no_argument, 0, 0}, + {"loose-query", no_argument, 0, 0}, {0, 0, 0, 0} }; specific_options = options; diff --git a/src/repos.cc b/src/repos.cc index 5cbfbbe..7841527 100644 --- a/src/repos.cc +++ b/src/repos.cc @@ -290,18 +290,17 @@ bool match_repo(Zypper & zypper, string str, RepoInfo *repo) try { - if (known_it->alias() == str || tmp == number) - found = true; + found = known_it->alias() == str || tmp == number; if (!found) { url::ViewOption urlview = url::ViewOption::DEFAULTS + url::ViewOption::WITH_PASSWORD; - if (copts.count("loose-auth")) + if (zypper.cOpts().count("loose-auth")) { urlview = urlview - url::ViewOptions::WITH_PASSWORD - url::ViewOptions::WITH_USERNAME; } - if (copts.count("loose-query")) + if (zypper.cOpts().count("loose-query")) urlview = urlview - url::ViewOptions::WITH_QUERY_STR; if (!(urlview.has(url::ViewOptions::WITH_PASSWORD) @@ -1787,18 +1786,52 @@ bool match_service(Zypper & zypper, string str, RepoInfoBase_Ptr & service_ptr) try { + // match by alias or number found = (*known_it)->alias() == str || tmp == number; + + // match by URL if (!found) { + url::ViewOption urlview = url::ViewOption::DEFAULTS + url::ViewOption::WITH_PASSWORD; + if (zypper.cOpts().count("loose-auth")) + { + urlview = urlview + - url::ViewOptions::WITH_PASSWORD + - url::ViewOptions::WITH_USERNAME; + } + if (zypper.cOpts().count("loose-query")) + urlview = urlview - url::ViewOptions::WITH_QUERY_STR; + ServiceInfo_Ptr s_ptr = dynamic_pointer_cast(*known_it); - if (s_ptr) - found = Url(str) == s_ptr->url(); + + if (!(urlview.has(url::ViewOptions::WITH_PASSWORD) + && urlview.has(url::ViewOptions::WITH_QUERY_STR))) + { + if (s_ptr) + found = + Url(str).asString(urlview) == s_ptr->url().asString(urlview); + else + { + RepoInfo_Ptr r_ptr = dynamic_pointer_cast(*known_it); + for_(urlit, r_ptr->baseUrlsBegin(), r_ptr->baseUrlsEnd()) + if (urlit->asString(urlview) == Url(str).asString(urlview)) + { + found = true; + break; + } + } + } else { - RepoInfo_Ptr r_ptr = dynamic_pointer_cast(*known_it); - found = - find(r_ptr->baseUrlsBegin(), r_ptr->baseUrlsEnd(), Url(str)) - != r_ptr->baseUrlsEnd(); + if (s_ptr) + found = Url(str) == s_ptr->url(); + else + { + RepoInfo_Ptr r_ptr = dynamic_pointer_cast(*known_it); + found = + find(r_ptr->baseUrlsBegin(), r_ptr->baseUrlsEnd(), Url(str)) + != r_ptr->baseUrlsEnd(); + } } } if (found) -- 2.7.4