/mandos/release

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

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: teddy at recompile
  • Date: 2011-12-31 13:25:58 UTC
  • mto: (237.7.89 trunk)
  • mto: This revision was merged to the branch mainline in revision 290.
  • Revision ID: teddy@recompile.se-20111231132558-z0dh7qgofgctmgri
* network-hooks.s/bridge: Don't use interface names directly; search
                          for interface names using their address.
  (addrtoif): New function.
* network-hooks.s/bridge.conf (PORTS): Removed.
  (PORT_ADDRESSES): New.
* network-hooks.s/wireless: Don't use interface names directly; search
                            for interface names using their address.
  (addrtoif): New function.
* network-hooks.s/wireless.conf: Specify address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
    >>> string_to_delta("5m 30s")
94
94
    datetime.timedelta(0, 330)
95
95
    """
96
 
    timevalue = datetime.timedelta(0)
97
 
    regexp = re.compile("\d+[dsmhw]")
 
96
    value = datetime.timedelta(0)
 
97
    regexp = re.compile("(\d+)([dsmhw]?)")
98
98
    
99
 
    for s in regexp.findall(interval):
100
 
        try:
101
 
            suffix = unicode(s[-1])
102
 
            value = int(s[:-1])
103
 
            if suffix == "d":
104
 
                delta = datetime.timedelta(value)
105
 
            elif suffix == "s":
106
 
                delta = datetime.timedelta(0, value)
107
 
            elif suffix == "m":
108
 
                delta = datetime.timedelta(0, 0, 0, 0, value)
109
 
            elif suffix == "h":
110
 
                delta = datetime.timedelta(0, 0, 0, 0, 0, value)
111
 
            elif suffix == "w":
112
 
                delta = datetime.timedelta(0, 0, 0, 0, 0, 0, value)
113
 
            else:
114
 
                raise ValueError
115
 
        except (ValueError, IndexError):
116
 
            raise ValueError
117
 
        timevalue += delta
118
 
    return timevalue
 
99
    for num, suffix in regexp.findall(interval):
 
100
        if suffix == "d":
 
101
            value += datetime.timedelta(int(num))
 
102
        elif suffix == "s":
 
103
            value += datetime.timedelta(0, int(num))
 
104
        elif suffix == "m":
 
105
            value += datetime.timedelta(0, 0, 0, 0, int(num))
 
106
        elif suffix == "h":
 
107
            value += datetime.timedelta(0, 0, 0, 0, 0, int(num))
 
108
        elif suffix == "w":
 
109
            value += datetime.timedelta(0, 0, 0, 0, 0, 0, int(num))
 
110
        elif suffix == "":
 
111
            value += datetime.timedelta(0, 0, 0, int(num))
 
112
    return value
119
113
 
120
114
def print_clients(clients, keywords):
121
115
    def valuetostring(value, keyword):
242
236
            #restore stderr
243
237
            os.dup2(stderrcopy, sys.stderr.fileno())
244
238
            os.close(stderrcopy)
245
 
    except dbus.exceptions.DBusException, e:
 
239
    except dbus.exceptions.DBusException:
246
240
        print("Access denied: Accessing mandos server through dbus.",
247
241
              file=sys.stderr)
248
242
        sys.exit(1)