tags 338230 +patch
thanks

Well, I just hacked up something myself. It does currently rely on the
user to set up non-console-interaction-authentication, i.e. ssh-agent.

I'm not very experienced with python, though, so please test.

Thanks,
Joachim

Am Dienstag, den 08.11.2005, 14:18 -0800 schrieb Debian Bug Tracking
System:
> Thank you for the problem report you have sent regarding Debian.
> This is an automatically generated reply, to let you know your message has
> been received.  It is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
> 
> Your message has been sent to the package maintainer(s):
>  David Watson <[EMAIL PROTECTED]>
> 
> If you wish to submit further information on your problem, please send
> it to [EMAIL PROTECTED] (and *not* to
> [EMAIL PROTECTED]).
> 
> Please do not reply to the address at the top of this message,
> unless you wish to report a problem with the Bug-tracking system.
> 
> Debian bug tracking system administrator
> (administrator, Debian Bugs database)
> 
-- 
Joachim "nomeata" Breitner
Debian Developer
  [EMAIL PROTECTED] | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: [EMAIL PROTECTED] | http://people.debian.org/~nomeata

diff -ur geximon-0.7.1/debian/changelog geximon-0.7.1-my/debian/changelog
--- geximon-0.7.1/debian/changelog	2005-11-09 12:03:43.000000000 +0100
+++ geximon-0.7.1-my/debian/changelog	2005-11-09 08:50:00.000000000 +0100
@@ -1,3 +1,9 @@
+geximon (0.7.1-1.1) unstable; urgency=low
+
+  * log file via sudo
+
+ -- Joachim Breitner <[EMAIL PROTECTED]>  Wed,  9 Nov 2005 08:49:52 +0100
+
 geximon (0.7.1-1) unstable; urgency=low
 
   * Geximon adopted by David Watson <[EMAIL PROTECTED]>
diff -ur geximon-0.7.1/geximon/exim.py geximon-0.7.1-my/geximon/exim.py
--- geximon-0.7.1/geximon/exim.py	2005-09-22 20:56:35.000000000 +0200
+++ geximon-0.7.1-my/geximon/exim.py	2005-11-09 12:05:16.000000000 +0100
@@ -1,33 +1,42 @@
 """Interfacing with exim processes."""
 
-import os
+import os,fcntl,select
 import threading
 
 __metaclass__ = type
 
 
-def get_output(path='', filename='', args='', use_sudo=False):
+def get_output(path='', filename='', args='', use_sudo=False, use_ssh=False, hostname=''):
     """Run a command and return its output."""
-    cmd = (use_sudo and 'sudo ' or '') + os.path.join(path, filename)
-    if args:
-        cmd += ' ' + args
-    stdin, stdouterr = os.popen4(cmd)
-    stdin.close()
+    stdouterr = get_pipe(path,filename,args,use_sudo,use_ssh,hostname)
     try:
         return stdouterr.read().strip()
     finally:
         stdouterr.close()
 
+def get_pipe(path='', filename='', args='', use_sudo=False, use_ssh=False, hostname=''):
+    """Run a command and return its handle."""
+    cmd = (use_ssh and 'ssh %s '%hostname or '') + \
+          (use_sudo and 'sudo ' or '') + \
+	  os.path.join(path, filename)
+    if args:
+        cmd += ' ' + args
+    stdin, stdouterr = os.popen4(cmd)
+    stdin.close()
+    return stdouterr
+
 
 class LogWatcher:
     """Watch exim logs."""
 
-    def __init__(self, log_dir, mainlog_name, bin_dir, sudo, line_limit=500):
+    def __init__(self, log_dir, mainlog_name, bin_dir, sudo, ssh, hostname, line_limit=500):
         self.line_limit = line_limit
         self.for_processing = []
         self._valid = True
         self.bin_dir = bin_dir
         self.use_sudo = sudo
+	self.use_ssh = ssh
+	self.hostname = hostname
         self.open(log_dir, mainlog_name)
 
     def open(self, log_dir, mainlog_name):
@@ -35,9 +44,14 @@
         self.mainlog_name = mainlog_name
         mainlog_path = os.path.join(log_dir, mainlog_name)
         try:
-            self.mainlog = open(mainlog_path)
-            self.mainlog_inode = os.fstat(self.mainlog.fileno()).st_ino
-            self._valid = True
+#            self.mainlog = open(mainlog_path)
+#            self.mainlog_inode = os.fstat(self.mainlog.fileno()).st_ino
+#            self._valid = True
+             self.mainlog = get_pipe('/usr/bin','tail','-f %s'%mainlog_path,self.use_sudo, self.use_ssh, self.hostname)
+	     self.mainlog_fd = self.mainlog.fileno()
+	     fl = fcntl.fcntl(self.mainlog_fd, fcntl.F_GETFL)
+	     fcntl.fcntl(self.mainlog_fd, fcntl.F_SETFL, fl|os.O_NONBLOCK)
+	     self._valid = True
         except IOError:
             if self._valid:
                 # XXX should show a popup
@@ -47,27 +61,30 @@
                 self._valid = False
             self.mainlog = None
         else:
-            self.unseen = self.mainlog.readlines()[-self.line_limit:]
-            self.unseen = [s[:-1] for s in self.unseen]
+            self.unseen = []
 
     def update(self):
         """Read the log file for new entries."""
         mainlog_path = os.path.join(self.log_dir, self.mainlog_name)
         if self.mainlog:
-            new_entries = self.mainlog.readlines()
-            new_entries = [s[:-1] for s in new_entries]
+            new_entries = []
+	    if (select.select([self.mainlog_fd],[],[],0))[0]:
+	       buffer = os.read(self.mainlog_fd, 2000)
+	       for line in buffer.split("\n"):
+	           if line:
+	               new_entries.append(line)
         else:
             new_entries = []
             self.open(self.log_dir, self.mainlog_name)
             return
 
-        try:
-            new_ino = os.stat(mainlog_path).st_ino
-        except OSError:
-            pass
-        else:
-            if self.mainlog_inode != new_ino:
-                self.open(self.log_dir, self.mainlog_name)
+#        try:
+#            new_ino = os.stat(mainlog_path).st_ino
+#        except OSError:
+#            pass
+#        else:
+#            if self.mainlog_inode != new_ino:
+#                self.open(self.log_dir, self.mainlog_name)
 
         self.unseen += new_entries
         self.for_processing += new_entries
@@ -95,7 +112,8 @@
                                               or self.mainlog_name)
         pattern = "'" + pattern + "'"
         return get_output(self.bin_dir, 'exigrep',
-                (literal and '-l' or '') + pattern + ' ' + filename)
+                (literal and '-l' or '') + pattern + ' ' + filename,
+		self.use_sudo, self.use_ssh, self.hostname)
 
     def runEximstats(self, args, all_logs):
         """Run eximstats.
@@ -105,7 +123,8 @@
         """
         filename = os.path.join(self.log_dir, all_logs and '*'
                                               or self.mainlog_name)
-        return get_output(self.bin_dir, 'eximstats', args + ' ' + filename)
+        return get_output(self.bin_dir, 'eximstats', args + ' ' + filename,
+	         self.use_sudo, self.use_ssh, self.hostname)
 
     def getRejectlog(self):
         """Get the contents of the rejectlog."""
@@ -177,7 +196,7 @@
     manager calls the registered callback.
     """
 
-    def __init__(self, callback, bin_dir, exim_binary, use_sudo):
+    def __init__(self, callback, bin_dir, exim_binary, sudo, ssh, hostname):
         """Initialize and start the background thread.
 
         callback is a callable that takes one argument -- a mapping from
@@ -191,7 +210,9 @@
         self.callback = callback
         self.bin_dir = bin_dir
         self.exim_binary = exim_binary
-        self.use_sudo = use_sudo
+        self.use_sudo = sudo
+	self.use_ssh = ssh
+	self.hostname = hostname
         self.queue_length = 0
 
     def do_update(self):
@@ -237,7 +258,7 @@
         args is a list of strings (the parameters to be passed).
         """
         return get_output(self.bin_dir, self.exim_binary,
-                " ".join(args), self.use_sudo)
+                " ".join(args), self.use_sudo, self.use_ssh, self.hostname)
 
     def checkOutput(self, output, expected, msg_count, action_name):
         """Check if a string has `expected` as a substring on each line.
@@ -259,9 +280,9 @@
     def runQueue(self):
         """Run the queue now."""
         # XXX a little dirty, but will do for now
-        cmd = os.path.join(self.bin_dir, self.exim_binary) + ' -q &'
-        if self.use_sudo:
-            cmd = 'sudo ' + cmd
+        cmd = (self.use_ssh and 'ssh %s ' % self.hostname) +\
+              (self.use_sudo and 'sudo ' or '') +\
+	      os.path.join(self.bin_dir, self.exim_binary) + ' -q &'
         os.system(cmd)
         return _("Spawning a queue runner in the background.")
 
@@ -376,7 +397,7 @@
     the process manager calls the registered callback.
     """
 
-    def __init__(self, callback, bin_dir, use_sudo):
+    def __init__(self, callback, bin_dir, use_sudo, use_ssh, hostname):
         """Start the background thread.
 
         callback is a callable that takes one argument -- a mapping from
@@ -390,10 +411,13 @@
         self.callback = callback
         self.bin_dir = bin_dir
         self.use_sudo = use_sudo
+	self.use_ssh = use_ssh
+	self.hostname = hostname
 
     def do_update(self):
         """Collect data from exiwhat in a separate thread."""
-        data = get_output(self.bin_dir, 'exiwhat', use_sudo=self.use_sudo)
+        data = get_output(self.bin_dir, 'exiwhat',
+	        use_sudo=self.use_sudo, use_ssh=self.use_ssh, hostname=self.hostname)
 
         processes = {}
         if (data.find('Permission denied') != -1 or
diff -ur geximon-0.7.1/geximon/geximon.py geximon-0.7.1-my/geximon/geximon.py
--- geximon-0.7.1/geximon/geximon.py	2005-10-03 20:23:46.000000000 +0200
+++ geximon-0.7.1-my/geximon/geximon.py	2005-11-09 11:43:53.000000000 +0100
@@ -48,11 +48,11 @@
         prefs.subscribe(self.apply_prefs)
 
         self.logwatcher = LogWatcher(prefs.log_dir, prefs.mainlog_name,
-                prefs.bin_dir, prefs.use_sudo)
+                prefs.bin_dir, prefs.use_sudo, prefs.use_ssh, prefs.hostname)
 
         # callback is None, it will be specified by QueueWidget
         self.queue_mgr = QueueManager(None,
-                prefs.bin_dir, prefs.exim_binary, prefs.use_sudo)
+                prefs.bin_dir, prefs.exim_binary, prefs.use_sudo, prefs.use_ssh, prefs.hostname)
 
         self._setUpIcons()
 
diff -ur geximon-0.7.1/geximon/preferences.py geximon-0.7.1-my/geximon/preferences.py
--- geximon-0.7.1/geximon/preferences.py	2005-10-03 20:23:46.000000000 +0200
+++ geximon-0.7.1-my/geximon/preferences.py	2005-11-09 11:38:09.000000000 +0100
@@ -22,6 +22,8 @@
     exim_binary = 'exim'
     mainlog_name = 'mainlog'
     use_sudo = False
+    use_ssh = False
+    hostname = ''
 
     log_interval = 200 # this is not accessible in GUI
     queue_interval = 2000
@@ -86,6 +88,8 @@
         load_str('paths', 'exim_binary')
         load_str('paths', 'mainlog_name')
         load_bool('paths', 'use_sudo')
+	load_bool('paths', 'use_ssh')
+	load_str('paths', 'hostname')
 
         load_int('timers', 'log_interval')
         load_int('timers', 'queue_interval')
@@ -118,6 +122,8 @@
         parser.set('paths', 'exim_binary', self.exim_binary)
         parser.set('paths', 'mainlog_name', self.mainlog_name)
         parser.set('paths', 'use_sudo', self.use_sudo)
+        parser.set('paths', 'use_ssh', self.use_ssh)
+	parser.set('paths', 'hostname', self.hostname)
 
         parser.add_section('timers')
         parser.set('timers', 'log_interval', self.log_interval)
@@ -208,6 +214,13 @@
         if prefs.use_sudo:
             self._use_sudo.set_active(1)
         paths.pack_start(self._use_sudo)
+        self._use_ssh = gtk.CheckButton(_("Use _ssh"))
+        if prefs.use_ssh:
+            self._use_ssh.set_active(1)
+        paths.pack_start(self._use_ssh)
+
+	self._hostname = packedPathEntry(
+		_("Remote Hostname"), prefs.hostname)
 
     def _setup_timer_settings(self, prefs):
         timers = self.newStyleFrame(_("Update intervals"))
@@ -303,6 +316,8 @@
         prefs.bin_dir = self._bin_dir.get_text()
         prefs.exim_binary = self._exim_binary.get_text()
         prefs.use_sudo = self._use_sudo.get_active()
+	prefs.use_ssh = self._use_ssh.get_active()
+	prefs.hostname = self._hostname.get_text()
         prefs.log_dir = self._log_dir.get_text()
         prefs.mainlog_name = self._mainlog_name.get_text()
 
diff -ur geximon-0.7.1/geximon/widgets.py geximon-0.7.1-my/geximon/widgets.py
--- geximon-0.7.1/geximon/widgets.py	2005-09-22 20:56:35.000000000 +0200
+++ geximon-0.7.1-my/geximon/widgets.py	2005-11-09 12:02:35.000000000 +0100
@@ -90,6 +90,8 @@
         self.set_wrap_mode(prefs.wrap_log)
         self.timer.update_interval(prefs.log_interval)
         self._logwatcher.use_sudo = prefs.use_sudo
+        self._logwatcher.use_ssh = prefs.use_ssh
+        self._logwatcher.hostname = prefs.hostname
         if (self._logwatcher.log_dir != prefs.log_dir
            or self._logwatcher.mainlog_name != prefs.mainlog_name):
             self._logwatcher._valid = True
@@ -104,7 +106,7 @@
         self._statusbar = statusbar
         self._old_processes = {}
         self.process_mgr = ProcessManager(self.do_update,
-                prefs.bin_dir, prefs.use_sudo)
+                prefs.bin_dir, prefs.use_sudo, prefs.use_ssh, prefs.hostname)
 
         self.model = gtk.ListStore(gobject.TYPE_INT,      # 0 pid
                                    gobject.TYPE_STRING)   # 1 status
@@ -188,6 +190,8 @@
     def apply_prefs(self, prefs):
         self.process_mgr.bin_dir = prefs.bin_dir
         self.process_mgr.use_sudo = prefs.use_sudo
+        self.process_mgr.use_ssh = prefs.use_ssh
+        self.process_mgr.hostname = prefs.hostname
         self.timer.set_paused(not prefs.show_process_list)
         self.timer.update_interval(prefs.process_interval)
 
@@ -483,6 +487,8 @@
     def apply_prefs(self, prefs):
         self.queue_mgr.bin_dir = prefs.bin_dir
         self.queue_mgr.use_sudo = prefs.use_sudo
+        self.queue_mgr.use_ssh = prefs.use_ssh
+        self.queue_mgr.hostname = prefs.hostname
         self.confirm_actions = prefs.confirm_actions
         self.report_success = prefs.report_success
         self.timer.update_interval(prefs.queue_interval)

Reply via email to