/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-monitor

  • Committer: Teddy Hogeborn
  • Date: 2014-03-28 22:32:21 UTC
  • Revision ID: teddy@recompile.se-20140328223221-w579qlvlex5if3dn
Fix location and format of signing key file.

* debian/upstream/signing-key.asc: Added.
* debian/upstream-signing-key.pgp: Removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
4
4
# Mandos Monitor - Control and monitor the Mandos server
5
5
6
 
# Copyright © 2009-2012 Teddy Hogeborn
7
 
# Copyright © 2009-2012 Björn Påhlsson
 
6
# Copyright © 2009-2014 Teddy Hogeborn
 
7
# Copyright © 2009-2014 Björn Påhlsson
8
8
9
9
# This program is free software: you can redistribute it and/or modify
10
10
# it under the terms of the GNU General Public License as published by
25
25
 
26
26
from __future__ import (division, absolute_import, print_function,
27
27
                        unicode_literals)
28
 
 
29
 
from future_builtins import *
 
28
try:
 
29
    from future_builtins import *
 
30
except ImportError:
 
31
    pass
30
32
 
31
33
import sys
32
34
import os
33
 
import signal
34
35
 
35
36
import datetime
36
37
 
38
39
import urwid
39
40
 
40
41
from dbus.mainloop.glib import DBusGMainLoop
41
 
import gobject
 
42
try:
 
43
    import gobject
 
44
except ImportError:
 
45
    from gi.repository import GObject as gobject
42
46
 
43
47
import dbus
44
48
 
45
 
import UserList
46
 
 
47
49
import locale
48
50
 
 
51
if sys.version_info[0] == 2:
 
52
    str = unicode
 
53
 
49
54
locale.setlocale(locale.LC_ALL, '')
50
55
 
51
56
import logging
55
60
domain = 'se.recompile'
56
61
server_interface = domain + '.Mandos'
57
62
client_interface = domain + '.Mandos.Client'
58
 
version = "1.5.3"
59
 
 
60
 
# Always run in monochrome mode
61
 
urwid.curses_display.curses.has_colors = lambda : False
62
 
 
63
 
# Urwid doesn't support blinking, but we want it.  Since we have no
64
 
# use for underline on its own, we make underline also always blink.
65
 
urwid.curses_display.curses.A_UNDERLINE |= (
66
 
    urwid.curses_display.curses.A_BLINK)
 
63
version = "1.6.4"
67
64
 
68
65
def isoformat_to_datetime(iso):
69
66
    "Parse an ISO 8601 date string to a datetime.datetime()"
210
207
           to log in the future. """
211
208
        #self.logger('Client {0} started checker "{1}"'
212
209
        #            .format(self.properties["Name"],
213
 
        #                    unicode(command)))
 
210
        #                    str(command)))
214
211
        pass
215
212
    
216
213
    def got_secret(self):
279
276
                message = "Approval in {0}. (d)eny?"
280
277
            else:
281
278
                message = "Denial in {0}. (a)pprove?"
282
 
            message = message.format(unicode(timer).rsplit(".", 1)[0])
 
279
            message = message.format(str(timer).rsplit(".", 1)[0])
283
280
            self.using_timer(True)
284
281
        elif self.properties["LastCheckerStatus"] != 0:
285
282
            # When checker has failed, show timer until client expires
293
290
                            datetime.timedelta())
294
291
            message = ('A checker has failed! Time until client'
295
292
                       ' gets disabled: {0}'
296
 
                       .format(unicode(timer).rsplit(".", 1)[0]))
 
293
                       .format(str(timer).rsplit(".", 1)[0]))
297
294
            self.using_timer(True)
298
295
        else:
299
296
            message = "enabled"
382
379
    def property_changed(self, property=None, **kwargs):
383
380
        """Call self.update() if old value is not new value.
384
381
        This overrides the method from MandosClientPropertyCache"""
385
 
        property_name = unicode(property)
 
382
        property_name = str(property)
386
383
        old_value = self.properties.get(property_name)
387
384
        super(MandosClientWidget, self).property_changed(
388
385
            property=property, **kwargs)
415
412
                ("normal",
416
413
                 "default", "default", None),
417
414
                ("bold",
418
 
                 "default", "default", "bold"),
 
415
                 "bold", "default", "bold"),
419
416
                ("underline-blink",
420
 
                 "default", "default", "underline"),
 
417
                 "underline,blink", "default", "underline,blink"),
421
418
                ("standout",
422
 
                 "default", "default", "standout"),
 
419
                 "standout", "default", "standout"),
423
420
                ("bold-underline-blink",
424
 
                 "default", "default", ("bold", "underline")),
 
421
                 "bold,underline,blink", "default", "bold,underline,blink"),
425
422
                ("bold-standout",
426
 
                 "default", "default", ("bold", "standout")),
 
423
                 "bold,standout", "default", "bold,standout"),
427
424
                ("underline-blink-standout",
428
 
                 "default", "default", ("underline", "standout")),
 
425
                 "underline,blink,standout", "default",
 
426
                 "underline,blink,standout"),
429
427
                ("bold-underline-blink-standout",
430
 
                 "default", "default", ("bold", "underline",
431
 
                                          "standout")),
 
428
                 "bold,underline,blink,standout", "default",
 
429
                 "bold,underline,blink,standout"),
432
430
                ))
433
431
        
434
432
        if urwid.supports_unicode():
489
487
        self.topwidget = urwid.Pile(self.uilist)
490
488
    
491
489
    def log_message(self, message):
 
490
        """Log message formatted with timestamp"""
492
491
        timestamp = datetime.datetime.now().isoformat()
493
492
        self.log_message_raw(timestamp + ": " + message)
494
493
    
507
506
        self.log_visible = not self.log_visible
508
507
        self.rebuild()
509
508
        #self.log_message("Log visibility changed to: "
510
 
        #                 + unicode(self.log_visible))
 
509
        #                 + str(self.log_visible))
511
510
    
512
511
    def change_log_display(self):
513
512
        """Change type of log display.
553
552
        if path is None:
554
553
            path = client.proxy.object_path
555
554
        self.clients_dict[path] = client
556
 
        self.clients.sort(None, lambda c: c.properties["Name"])
 
555
        self.clients.sort(key=lambda c: c.properties["Name"])
557
556
        self.refresh()
558
557
    
559
558
    def remove_client(self, client, path=None):
561
560
        if path is None:
562
561
            path = client.proxy.object_path
563
562
        del self.clients_dict[path]
564
 
        if not self.clients_dict:
565
 
            # Work around bug in Urwid 0.9.8.3 - if a SimpleListWalker
566
 
            # is completely emptied, we need to recreate it.
567
 
            self.clients = urwid.SimpleListWalker([])
568
 
            self.rebuild()
569
563
        self.refresh()
570
564
    
571
565
    def refresh(self):
584
578
        try:
585
579
            mandos_clients = (self.mandos_serv
586
580
                              .GetAllClientsWithProperties())
 
581
            if not mandos_clients:
 
582
                self.log_message_raw(("bold", "Note: Server has no clients."))
587
583
        except dbus.exceptions.DBusException:
 
584
            self.log_message_raw(("bold", "Note: No Mandos server running."))
588
585
            mandos_clients = dbus.Dictionary()
589
586
        
590
587
        (self.mandos_serv
602
599
                            self.client_not_found,
603
600
                            dbus_interface=server_interface,
604
601
                            byte_arrays=True))
605
 
        for path, client in mandos_clients.iteritems():
 
602
        for path, client in mandos_clients.items():
606
603
            client_proxy_object = self.bus.get_object(self.busname,
607
604
                                                      path)
608
605
            self.add_client(MandosClientWidget(server_proxy_object
720
717
    ui.run()
721
718
except KeyboardInterrupt:
722
719
    ui.screen.stop()
723
 
except Exception, e:
724
 
    ui.log_message(unicode(e))
 
720
except Exception as e:
 
721
    ui.log_message(str(e))
725
722
    ui.screen.stop()
726
723
    raise