From 4e2aae5159579ce6ad405014f92b07e9a20806b9 Mon Sep 17 00:00:00 2001 From: Geoff Paul Date: Wed, 26 Dec 2012 19:58:53 -0600 Subject: [PATCH 1/2] Always run with root permissions when updating the APT cache. --- etc/sudoers.d/mintupdate | 6 ++++++ usr/lib/linuxmint/mintUpdate/mintUpdate.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 etc/sudoers.d/mintupdate diff --git a/etc/sudoers.d/mintupdate b/etc/sudoers.d/mintupdate new file mode 100644 index 00000000..24196f47 --- /dev/null +++ b/etc/sudoers.d/mintupdate @@ -0,0 +1,6 @@ +# Allow any user to check for new system updates without +# requiring user authentication. + +Cmnd_Alias UPDATE = /usr/lib/linuxmint/mintUpdate/checkAPT.py + +ALL ALL = NOPASSWD:UPDATE diff --git a/usr/lib/linuxmint/mintUpdate/mintUpdate.py b/usr/lib/linuxmint/mintUpdate/mintUpdate.py index 1badcbd8..5071aba1 100755 --- a/usr/lib/linuxmint/mintUpdate/mintUpdate.py +++ b/usr/lib/linuxmint/mintUpdate/mintUpdate.py @@ -463,9 +463,9 @@ def run(self): wTree.get_widget("vpaned1").set_position(vpaned_position) gtk.gdk.threads_leave() if app_hidden: - updates = commands.getoutput("/usr/lib/linuxmint/mintUpdate/checkAPT.py | grep \"###\"") + updates = commands.getoutput("sudo /usr/lib/linuxmint/mintUpdate/checkAPT.py | grep \"###\"") else: - updates = commands.getoutput("/usr/lib/linuxmint/mintUpdate/checkAPT.py --use-synaptic %s | grep \"###\"" % self.wTree.get_widget("window1").window.xid) + updates = commands.getoutput("sudo /usr/lib/linuxmint/mintUpdate/checkAPT.py --use-synaptic %s | grep \"###\"" % self.wTree.get_widget("window1").window.xid) # Look for mintupdate if ("UPDATE###mintupdate###" in updates): From 959f11c987eb21dd212cc6b90f59be99b65fde79 Mon Sep 17 00:00:00 2001 From: Geoff Paul Date: Wed, 26 Dec 2012 20:41:24 -0600 Subject: [PATCH 2/2] Modify checkAPT.py to properly detect latest cache updates. --- usr/lib/linuxmint/mintUpdate/checkAPT.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/usr/lib/linuxmint/mintUpdate/checkAPT.py b/usr/lib/linuxmint/mintUpdate/checkAPT.py index 87ba2609..c9651ff7 100755 --- a/usr/lib/linuxmint/mintUpdate/checkAPT.py +++ b/usr/lib/linuxmint/mintUpdate/checkAPT.py @@ -26,7 +26,7 @@ # return changes try: - cache = None + cache = apt.Cache() if os.getuid() == 0 : use_synaptic = False @@ -44,7 +44,6 @@ returnCode = comnd.wait() #sts = os.waitpid(comnd.pid, 0) else: - cache = apt.Cache() cache.update() sys.path.append('/usr/lib/linuxmint/common') @@ -58,8 +57,8 @@ except: dist_upgrade = True - if cache is None: - cache = apt.Cache() + # Reopen the cache to reflect any updates + cache.open(None) cache.upgrade(dist_upgrade) changes = cache.get_changes()