[packagekit] [PATCH 1/5] zypp: Handle and report network authentication failures
Thomas Perl
thomas.perl at jolla.com
Wed Jan 22 02:31:48 PST 2014
This will properly abort a repository refresh if access is denied
due to an authentication failure in libzypp. The MediaException is
caught inside libzypp and transformed into an error for PackageKit.
---
backends/zypp/pk-backend-zypp.cpp | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 33520a2..3f2290b 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -5,6 +5,9 @@
* Copyright (c) 2007-2008 Stefan Haas <shaas at suse.de>
* Copyright (c) 2007-2008 Scott Reeves <sreeves at novell.com>
*
+ * Copyright (c) 2013, 2014 Jolla Ltd.
+ * Contact: Thomas Perl <thomas.perl at jolla.com>
+ *
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
@@ -78,6 +81,7 @@
#include <zypp/base/Logger.h>
#include <zypp/base/String.h>
#include <zypp/media/MediaManager.h>
+#include <zypp/media/MediaException.h>
#include <zypp/parser/IniDict.h>
#include <zypp/parser/ParseException.h>
#include <zypp/parser/ProductFileReader.h>
@@ -395,6 +399,16 @@ struct MediaChangeReportReceiver : public zypp::callback::ReceiveReport<zypp::me
}
};
+struct AuthenticationReportReceiver : public zypp::callback::ReceiveReport<zypp::media::AuthenticationReport>, ZyppBackendReceiver
+{
+ virtual bool prompt (const zypp::Url &url, const std::string &description, zypp::media::AuthData &auth_data)
+ {
+ /* No interactive authentication supported - admit failure */
+ ZYPP_THROW(zypp::media::MediaException("Authentication failed"));
+ return false; // Not reached
+ }
+};
+
struct ProgressReportReceiver : public zypp::callback::ReceiveReport<zypp::ProgressReport>, ZyppBackendReceiver
{
virtual void start (const zypp::ProgressData &progress)
@@ -478,6 +492,7 @@ class EventDirector
ZyppBackend::KeyRingReportReceiver _keyRingReport;
ZyppBackend::DigestReportReceiver _digestReport;
ZyppBackend::MediaChangeReportReceiver _mediaChangeReport;
+ ZyppBackend::AuthenticationReportReceiver _authenticationReport;
ZyppBackend::ProgressReportReceiver _progressReport;
public:
@@ -491,6 +506,7 @@ class EventDirector
_keyRingReport.connect ();
_digestReport.connect ();
_mediaChangeReport.connect ();
+ _authenticationReport.connect ();
_progressReport.connect ();
}
@@ -504,6 +520,7 @@ class EventDirector
_keyRingReport._job = job;
_digestReport._job = job;
_mediaChangeReport._job = job;
+ _authenticationReport._job = job;
_progressReport._job = job;
}
@@ -517,6 +534,7 @@ class EventDirector
_keyRingReport.disconnect ();
_digestReport.disconnect ();
_mediaChangeReport.disconnect ();
+ _authenticationReport.disconnect ();
_progressReport.disconnect ();
}
};
--
1.8.5.2
More information about the PackageKit
mailing list