/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-ctl

  • Committer: Teddy Hogeborn
  • Date: 2011-11-26 22:22:20 UTC
  • mto: (518.1.8 mandos-persistent)
  • mto: This revision was merged to the branch mainline in revision 524.
  • Revision ID: teddy@recompile.se-20111126222220-1ubwjpb5ugqnrhec
Directory with persistent state can now be changed with the "statedir"
option.  The state directory /var/lib/mandos now gets created on
installation.  Added documentation about "restore" and "statedir"
options.

* Makefile (USER, GROUP, STATEDIR): New.
  (maintainer-clean): Also remove "statedir".
  (run-server): Replaced "--no-restore" with "--statedir=statedir".
  (statedir): New.
  (install-server): Make $(STATEDIR) directory.
* debian/mandos.dirs (var/lib/mandos): Added.
* debian/mandos.postinst: Fix ownership of /var/lib/mandos.
* mandos: New --statedir option.
  (stored_state_path): Not global anymore.
  (stored_state_file): New global.
* mandos.conf: Fix whitespace.
  (restore, statedir): Added.
* mandos.conf.xml (OPTIONS, EXAMPLE): Added "restore" and "statedir".
  mandos.xml (SYNOPSIS, OPTIONS): Added "--statedir".
  (FILES): Added "/var/lib/mandos".

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
 
    value = datetime.timedelta(0)
97
 
    regexp = re.compile("(\d+)([dsmhw]?)")
 
96
    timevalue = datetime.timedelta(0)
 
97
    regexp = re.compile("\d+[dsmhw]")
98
98
    
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
 
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
113
119
 
114
120
def print_clients(clients, keywords):
115
121
    def valuetostring(value, keyword):
236
242
            #restore stderr
237
243
            os.dup2(stderrcopy, sys.stderr.fileno())
238
244
            os.close(stderrcopy)
239
 
    except dbus.exceptions.DBusException:
 
245
    except dbus.exceptions.DBusException, e:
240
246
        print("Access denied: Accessing mandos server through dbus.",
241
247
              file=sys.stderr)
242
248
        sys.exit(1)