It's somewhat of a hack, but that's due to a combination of 
how the bug number is found and that pesky u before the bug number.
Didn't anybody test this before it was released?  

        I had to convert the bug number to a string to get the u out,
then concatenate the string.  Works fine.  The last problem 
had to do with calling 'sudo' from the root process if gksu was not
invoked with 'sudo mode'.  I patched that too (see #582284).

        Patch attached with some debug logging added for the next
time the changelog viewer breaks.  ;-)

--- ChangelogViewer.py	2009-12-28 06:06:51.000000000 -0500
+++ ChangelogViewer.py.new	2010-05-23 19:13:35.000000000 -0400
@@ -42,6 +42,9 @@
 import subprocess
 import os
 from gettext import gettext as _
+import logging
+
+LOG = logging.getLogger('UpdateManager.Util.procesinfo')
 
 from UpdateManager.Util.processinfo import find_nonroot_parent
 
@@ -107,6 +110,9 @@
             clipboard.store()
 
     def tag_link(self, start, end, url):
+    
+	LOG.debug('tag_link - passed url is %r', url)
+    
         """Apply the tag that marks links to the specified buffer selection"""
         tags = start.get_tags()
         for tag in tags:
@@ -173,9 +179,14 @@
                     match_end = match_tmp.copy()
 
                 # call the tagging method for the complete URL
-                url = url_prefix + match_suffix.get_text(match_end)
-
+                tmp_bugnum = str(match_suffix.get_text(match_end))
+                LOG.debug('tmp_bugnum is %s', tmp_bugnum)
+                                
+                # url = url_prefix + match_suffix.get_text(match_end)
+                url = url_prefix + tmp_bugnum
+                
                 self.tag_link(match_start, match_end, url)
+                
                 # set the starting point for the next search
                 iterator = match_end
 
@@ -214,6 +225,10 @@
     
     @classmethod
     def open_url(cls, url):
+    
+	LOG.debug('cls = %r', cls)
+	LOG.debug('url = %r', url)
+	
         """Open the specified URL in a browser"""
         # Find an appropiate browser
         if os.path.exists("/usr/bin/exo-open"):
@@ -227,10 +242,13 @@
         if os.getuid() == 0:
             pi = find_nonroot_parent()
             if pi:
-                command = ['sudo', '-u#' + pi.owner_ui, command]
+            	struid = str(pi.owner_uid)
+                command = ['sudo', '-u#' + struid] + command
             else:
                 LOG.fatal('Could not detect original user.')
                 return
+        
+        LOG.debug('command = %r', command)
             
         subprocess.Popen(command)
 

Reply via email to