Merge lp:~aptdaemon-developers/aptdaemon/fail-on-no-auth into lp:aptdaemon

Proposed by Sebastian Heinlein
Status: Needs review
Proposed branch: lp:~aptdaemon-developers/aptdaemon/fail-on-no-auth
Merge into: lp:aptdaemon
Diff against target: 119 lines (+48/-11)
3 files modified
aptdaemon/core.py (+30/-10)
aptdaemon/enums.py (+14/-1)
aptdaemon/pkcompat.py (+4/-0)
To merge this branch: bzr merge lp:~aptdaemon-developers/aptdaemon/fail-on-no-auth
Reviewer Review Type Date Requested Status
Aptdaemon Developers Pending
Review via email: mp+99882@code.launchpad.net

Description of the change

This introduces a string change (new error messages)

To post a comment you must log in.

Unmerged revisions

787. By Sebastian Heinlein

core: if the run call fails also let the transaction fail (fixes LP #892215)

If the authorization fails the transaction will now also fail. This helps clients which dont catch errors in the run method. Furthermore all connected transaction will also fail.

786. By Sebastian Heinlein

enums: Add new transaction error enums to handle a not authorized user and a failed authorization process

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'aptdaemon/core.py'
--- aptdaemon/core.py 2012-03-14 07:53:38 +0000
+++ aptdaemon/core.py 2012-03-29 06:58:18 +0000
@@ -47,6 +47,7 @@
47import signal47import signal
48import sys48import sys
49import time49import time
50import traceback
50import uuid51import uuid
5152
52from gi.repository import GObject53from gi.repository import GObject
@@ -890,16 +891,35 @@
890891
891 @inline_callbacks892 @inline_callbacks
892 def _run(self, sender):893 def _run(self, sender):
893 yield self._check_foreign_user(sender)894 trans = self
894 yield self._check_auth()895 while trans:
895 yield self.queue.put(self.tid)896 try:
896 self.status = enums.STATUS_WAITING897 yield self._check_foreign_user(sender)
897 next_trans = self.after898 yield self._check_auth()
898 while next_trans:899 yield self.queue.put(self.tid)
899 yield next_trans._check_auth()900 except errors.AuthorizationFailed as excep:
900 yield self.queue.put(next_trans.tid)901 error = errors.TransactionFailed(enums.ERROR_AUTH_FAILED,
901 next_trans.status = enums.STATUS_WAITING902 str(excep))
902 next_trans = next_trans.after903 except errors.NotAuthorizedError as excep:
904 error = errors.TransactionFailed(enums.ERROR_NOT_AUTHORIZED,
905 str(excep))
906 except Exception as excep:
907 tbk = traceback.format_exc(excep)
908 error = errors.TransactionFailed(enums.ERROR_UNKNOWN, tbk)
909 else:
910 self.status = enums.STATUS_WAITING
911 trans = self.after
912 continue
913 trans.error = error
914 trans.exit = enums.EXIT_FAILED
915 # Also let all connected transactions fail
916 next = self.after
917 while next:
918 next.error = error
919 next.exit = enums.EXIT_FAILED
920 next = next_trans.after
921 # Need to re-raise the error
922 raise error
903923
904 @inline_callbacks924 @inline_callbacks
905 def _check_auth(self):925 def _check_auth(self):
906926
=== modified file 'aptdaemon/enums.py'
--- aptdaemon/enums.py 2011-12-13 21:32:43 +0000
+++ aptdaemon/enums.py 2012-03-29 06:58:18 +0000
@@ -38,7 +38,7 @@
38 "ERROR_SYSTEM_ALREADY_UPTODATE", "ERROR_NOT_SUPPORTED",38 "ERROR_SYSTEM_ALREADY_UPTODATE", "ERROR_NOT_SUPPORTED",
39 "ERROR_LICENSE_KEY_INSTALL_FAILED",39 "ERROR_LICENSE_KEY_INSTALL_FAILED",
40 "ERROR_LICENSE_KEY_DOWNLOAD_FAILED",40 "ERROR_LICENSE_KEY_DOWNLOAD_FAILED",
41 "ERROR_UNKNOWN",41 "ERROR_NOT_AUTHORIZED", "ERROR_AUTH_FAILED", "ERROR_UNKNOWN",
42 "STATUS_SETTING_UP", "STATUS_WAITING", "STATUS_WAITING_MEDIUM",42 "STATUS_SETTING_UP", "STATUS_WAITING", "STATUS_WAITING_MEDIUM",
43 "STATUS_WAITING_CONFIG_FILE_PROMPT", "STATUS_WAITING_LOCK",43 "STATUS_WAITING_CONFIG_FILE_PROMPT", "STATUS_WAITING_LOCK",
44 "STATUS_RUNNING", "STATUS_LOADING_CACHE", "STATUS_DOWNLOADING",44 "STATUS_RUNNING", "STATUS_LOADING_CACHE", "STATUS_DOWNLOADING",
@@ -156,6 +156,11 @@
156ERROR_LICENSE_KEY_INSTALL_FAILED = "error-license-key-install-failed"156ERROR_LICENSE_KEY_INSTALL_FAILED = "error-license-key-install-failed"
157#: The system is already up-to-date and don't needs any upgrades157#: The system is already up-to-date and don't needs any upgrades
158ERROR_SYSTEM_ALREADY_UPTODATE = "error-system-already-uptodate"158ERROR_SYSTEM_ALREADY_UPTODATE = "error-system-already-uptodate"
159#: The user could not authenticate to run the transaction
160ERROR_NOT_AUTHORIZED = "error-not-authorized"
161#: The authorization system is broken (e.g. there isn't any session policykit
162#: agent running)
163ERROR_AUTH_FAILED = "error-auth-failed"
159#: An unknown error occured. In most cases these are programming ones.164#: An unknown error occured. In most cases these are programming ones.
160ERROR_UNKNOWN = "error-unknown"165ERROR_UNKNOWN = "error-unknown"
161166
@@ -547,6 +552,12 @@
547 "use this piece of software could not be "552 "use this piece of software could not be "
548 "downloaded. Please check your "553 "downloaded. Please check your "
549 "network connection."),554 "network connection."),
555 ERROR_NOT_AUTHORIZED: _("Please check that you have entered the correct "
556 "password and that you are allowed to perform "
557 "this action. Contact your system administrator."),
558 ERROR_AUTH_FAILED: _("The authorization system (PolicyKit) seems to be "
559 "not correctly installed. Please make sure that a "
560 "session agent is running."),
550 }561 }
551562
552def get_error_description_from_enum(enum):563def get_error_description_from_enum(enum):
@@ -586,6 +597,8 @@
586 ERROR_LICENSE_KEY_DOWNLOAD_FAILED: _("Failed to download the license key"),597 ERROR_LICENSE_KEY_DOWNLOAD_FAILED: _("Failed to download the license key"),
587 ERROR_LICENSE_KEY_INSTALL_FAILED: _("Failed to install the license key"),598 ERROR_LICENSE_KEY_INSTALL_FAILED: _("Failed to install the license key"),
588 ERROR_SYSTEM_ALREADY_UPTODATE: _("The system is already up to date"),599 ERROR_SYSTEM_ALREADY_UPTODATE: _("The system is already up to date"),
600 ERROR_NOT_AUTHORIZED: _("You are not allowed to perform this action"),
601 ERROR_AUTH_FAILED: _("Failed to authorize you"),
589 ERROR_UNKNOWN : _("An unhandlable error occured")602 ERROR_UNKNOWN : _("An unhandlable error occured")
590 }603 }
591604
592605
=== modified file 'aptdaemon/pkcompat.py'
--- aptdaemon/pkcompat.py 2012-03-13 18:35:32 +0000
+++ aptdaemon/pkcompat.py 2012-03-29 06:58:18 +0000
@@ -203,6 +203,10 @@
203 pk_enums.ERROR_INVALID_PACKAGE_FILE,203 pk_enums.ERROR_INVALID_PACKAGE_FILE,
204 aptd_enums.ERROR_SYSTEM_ALREADY_UPTODATE:204 aptd_enums.ERROR_SYSTEM_ALREADY_UPTODATE:
205 pk_enums.ERROR_NO_PACKAGES_TO_UPDATE,205 pk_enums.ERROR_NO_PACKAGES_TO_UPDATE,
206 aptd_enums.ERROR_AUTH_FAILED:
207 pk_enums.ERROR_NOT_AUTHORIZED,
208 aptd_enums.ERROR_NOT_AUTHORIZED:
209 pk_enums.ERROR_NOT_AUTHORIZED,
206 }210 }
207211
208MAP_PACKAGE_ENUM = {212MAP_PACKAGE_ENUM = {

Subscribers

People subscribed via source and target branches

to status/vote changes: