=== modified file 'TODO' --- TODO 2010-09-23 20:14:08 +0000 +++ TODO 2010-09-25 19:55:17 +0000 @@ -3,8 +3,6 @@ * Use _attribute_((nonnull)) wherever possible. * Release critical -** mandos-ctl.xml -*** More examples ** mandos *** Do not write PID file if --debug is passed? Do other programs do this? @@ -91,6 +89,8 @@ ** TODO make clients to a dict! ** TODO [#A] Limit approval_delay to max gnutls/tls timeout value ** TODO [#B] break the wait on approval_delay if connection dies +** TODO Generate Client.runtime_expansions from client options + extra +** TODO Allow %%(checker)s as a runtime expansion * mandos.xml ** Add mandos contact info in manual pages === modified file 'mandos' --- mandos 2010-09-12 18:23:40 +0000 +++ mandos 2010-09-25 19:55:17 +0000 @@ -240,36 +240,42 @@ """A representation of a client host served by this server. Attributes: - name: string; from the config file, used in log messages and - D-Bus identifiers - fingerprint: string (40 or 32 hexadecimal digits); used to - uniquely identify the client - secret: bytestring; sent verbatim (over TLS) to client - host: string; available for use by the checker command - created: datetime.datetime(); (UTC) object creation - last_enabled: datetime.datetime(); (UTC) - enabled: bool() - last_checked_ok: datetime.datetime(); (UTC) or None - timeout: datetime.timedelta(); How long from last_checked_ok - until this client is disabled - interval: datetime.timedelta(); How often to start a new checker - disable_hook: If set, called by disable() as disable_hook(self) + _approved: bool(); 'None' if not yet approved/disapproved + approval_delay: datetime.timedelta(); Time to wait for approval + approval_duration: datetime.timedelta(); Duration of one approval checker: subprocess.Popen(); a running checker process used to see if the client lives. 'None' if no process is running. - checker_initiator_tag: a gobject event source tag, or None - disable_initiator_tag: - '' - checker_callback_tag: - '' - - checker_command: string; External command which is run to check if - client lives. %() expansions are done at + checker_command: string; External command which is run to check + if client lives. %() expansions are done at runtime with vars(self) as dict, so that for instance %(name)s can be used in the command. + checker_initiator_tag: a gobject event source tag, or None + created: datetime.datetime(); (UTC) object creation current_checker_command: string; current running checker_command - approval_delay: datetime.timedelta(); Time to wait for approval - _approved: bool(); 'None' if not yet approved/disapproved - approval_duration: datetime.timedelta(); Duration of one approval + disable_hook: If set, called by disable() as disable_hook(self) + disable_initiator_tag: - '' - + enabled: bool() + fingerprint: string (40 or 32 hexadecimal digits); used to + uniquely identify the client + host: string; available for use by the checker command + interval: datetime.timedelta(); How often to start a new checker + last_checked_ok: datetime.datetime(); (UTC) or None + last_enabled: datetime.datetime(); (UTC) + name: string; from the config file, used in log messages and + D-Bus identifiers + secret: bytestring; sent verbatim (over TLS) to client + timeout: datetime.timedelta(); How long from last_checked_ok + until this client is disabled + runtime_expansions: Allowed attributes for runtime expansion. """ + runtime_expansions = (u"approval_delay", u"approval_duration", + u"created", u"enabled", u"fingerprint", + u"host", u"interval", u"last_checked_ok", + u"last_enabled", u"name", u"timeout") + @staticmethod def _timedelta_to_milliseconds(td): "Convert a datetime.timedelta() to milliseconds" @@ -450,12 +456,14 @@ command = self.checker_command % self.host except TypeError: # Escape attributes for the shell - escaped_attrs = dict((key, - re.escape(unicode(str(val), - errors= - u'replace'))) - for key, val in - vars(self).iteritems()) + escaped_attrs = dict( + (attr, + re.escape(unicode(str(getattr(self, attr, u"")), + errors= + u'replace'))) + for attr in + self.runtime_expansions) + try: command = self.checker_command % escaped_attrs except TypeError, error: @@ -703,6 +711,10 @@ dbus_object_path: dbus.ObjectPath bus: dbus.SystemBus() """ + + runtime_expansions = (Client.runtime_expansions + + (u"dbus_object_path",)) + # dbus.service.Object doesn't use super(), so we can't either. def __init__(self, bus = None, *args, **kwargs): === modified file 'mandos-clients.conf.xml' --- mandos-clients.conf.xml 2010-09-12 03:00:40 +0000 +++ mandos-clients.conf.xml 2010-09-25 19:55:17 +0000 @@ -3,7 +3,7 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ /etc/mandos/clients.conf"> - + %common; ]> @@ -100,53 +100,53 @@ - - - - This option is optional. - - - The timeout is how long the server will wait (for either a - successful checker run or a client receiving its secret) - until a client is disabled and not allowed to get the data - this server holds. By default Mandos will use 1 hour. - - - The TIME is specified as a - space-separated number of values, each of which is a - number and a one-character suffix. The suffix must be one - of d, s, m, - h, and w for days, seconds, - minutes, hours, and weeks, respectively. The values are - added together to give the total time value, so all of - 330s, - 110s 110s 110s, and - 5m 30s will give a value - of five minutes and thirty seconds. - - - - - - - - - This option is optional. - - - How often to run the checker to confirm that a client is - still up. Note: a new checker will - not be started if an old one is still running. The server - will wait for a checker to complete until the above - timeout occurs, at which - time the client will be disabled, and any running checker - killed. The default interval is 5 minutes. - - - The format of TIME is the same - as for timeout above. + + + + This option is optional. + + + How long to wait for external approval before resorting to + use the value. The + default is 0s, i.e. not to wait. + + + The format of TIME is the same + as for timeout below. + + + + + + + + + This option is optional. + + + How long an external approval lasts. The default is 1 + second. + + + The format of TIME is the same + as for timeout below. + + + + + + + + + Whether to approve a client by default after + the . The default + is True. @@ -196,6 +196,70 @@ + + + + This option is optional, but highly + recommended unless the + option is modified to a + non-standard value without %%(host)s in it. + + + Host name for this client. This is not used by the server + directly, but can be, and is by default, used by the + checker. See the option. + + + + + + + + + This option is optional. + + + How often to run the checker to confirm that a client is + still up. Note: a new checker will + not be started if an old one is still running. The server + will wait for a checker to complete until the below + timeout occurs, at which + time the client will be disabled, and any running checker + killed. The default interval is 5 minutes. + + + The format of TIME is the same + as for timeout below. + + + + + + + + + This option is only used if is not + specified, in which case this option is + required. + + + Similar to the , except the secret + data is in an external file. The contents of the file + should not be base64-encoded, but + will be sent to clients verbatim. + + + File names of the form ~user/foo/bar + and $ENVVAR/foo/bar + are supported. + + + + + @@ -226,94 +290,30 @@ - - - - This option is only used if is not - specified, in which case this option is - required. - - - Similar to the , except the secret - data is in an external file. The contents of the file - should not be base64-encoded, but - will be sent to clients verbatim. - - - File names of the form ~user/foo/bar - and $ENVVAR/foo/bar - are supported. - - - - - - - - - This option is optional, but highly - recommended unless the - option is modified to a - non-standard value without %%(host)s in it. - - - Host name for this client. This is not used by the server - directly, but can be, and is by default, used by the - checker. See the option. - - - - - - - - - Whether to approve a client by default after - the . The default - is True. - - - - - - This option is optional. - How long to wait for external approval before resorting to - use the value. The - default is 0s, i.e. not to wait. - - - The format of TIME is the same - as for timeout above. - - - - - - - - - This option is optional. - - - How long an external approval lasts. The default is 1 - second. - - - The format of TIME is the same - as for timeout above. + The timeout is how long the server will wait (for either a + successful checker run or a client receiving its secret) + until a client is disabled and not allowed to get the data + this server holds. By default Mandos will use 1 hour. + + + The TIME is specified as a + space-separated number of values, each of which is a + number and a one-character suffix. The suffix must be one + of d, s, m, + h, and w for days, seconds, + minutes, hours, and weeks, respectively. The values are + added together to give the total time value, so all of + 330s, + 110s 110s 110s, and + 5m 30s will give a value + of five minutes and thirty seconds. === modified file 'mandos-ctl' --- mandos-ctl 2010-09-25 16:53:58 +0000 +++ mandos-ctl 2010-09-25 19:55:17 +0000 @@ -93,7 +93,7 @@ def valuetostring(value, keyword): if type(value) is dbus.Boolean: return u"Yes" if value else u"No" - if keyword in (u"timeout", u"interval"): + if keyword in (u"Timeout", u"Interval"): return milliseconds_to_string(value) return unicode(value) @@ -110,6 +110,7 @@ for client in clients: print format_string % tuple(valuetostring(client[key], key) for key in keywords) + def has_actions(options): return any((options.enable, options.disable, === modified file 'mandos-ctl.xml' --- mandos-ctl.xml 2010-09-21 19:16:41 +0000 +++ mandos-ctl.xml 2010-09-25 19:55:17 +0000 @@ -2,7 +2,7 @@ - + %common; ]> @@ -422,21 +422,58 @@ EXAMPLE - List all clients with some of their settings: + To list all clients: &COMMANDNAME; - - - Show all settings for the clients named foo and - bar: - - - - -&COMMANDNAME; --verbose foo bar + + + + To list all settings for the clients + named foo1.example.org and foo2.example.org: + + + + +&COMMANDNAME; --verbose foo1.example.org foo2.example.org + + + + + + + To enable all clients: + + + &COMMANDNAME; --enable --all + + + + + + To change timeout and interval value for the clients + named foo1.example.org and foo2.example.org: + + + + +&COMMANDNAME; --timeout="5m" --interval="1m" foo1.example.org foo2.example.org + + + + + + + To approve all clients currently waiting for it: + + + + +&COMMANDNAME; --approve --all