def _save_rule(self, rule): """Modify rule to reflect dialog state.""" del rule.fields[:] if self.event_type_condition.get_active(): f = Field() f.var = audit.AUDIT_MSGTYPE f.op = self.op_store.get_value(self.event_type_op.get_active_iter(), 0) try: f.value = util.parse_msgtype(self.event_type_value.child.get_text()) except ParsingError: assert False, "Should have been validated" rule.fields.append(f)
def _update_row(self, it, rule): self._row_set_filter_key(it, 1, rule) for field in rule.fields: if field.var in (audit.AUDIT_DIR, audit.AUDIT_WATCH): text = field.value break else: text = '' self.store.set_value(it, 2, text) for field in rule.fields: if field.var == audit.AUDIT_PERM: perm = field.value break else: perm = (audit.AUDIT_PERM_READ | audit.AUDIT_PERM_WRITE | audit.AUDIT_PERM_EXEC | audit.AUDIT_PERM_ATTR) self.store.set_value(it, 3, Field.get_field_type(audit.AUDIT_PERM). value_text(perm))
def _save_rule(self, rule): '''Modify rule to reflect dialog state.''' assert rule.action == rule.ACTION_ALWAYS del rule.fields[:] if self.watch_keys_present.get_active(): for key in self.keys: f = Field() f.var = audit.AUDIT_FILTERKEY f.op = Field.OP_EQ f.value = key rule.fields.append(f) path = self.watch_path.get_text() f = Field() if os.path.isdir(path): f.var = audit.AUDIT_DIR else: f.var = audit.AUDIT_WATCH f.op = Field.OP_EQ f.value = path rule.fields.append(f) perm = 0 for (w, mask) in ((self.watch_read, audit.AUDIT_PERM_READ), (self.watch_write, audit.AUDIT_PERM_WRITE), (self.watch_exec, audit.AUDIT_PERM_EXEC), (self.watch_attr, audit.AUDIT_PERM_ATTR)): if w.get_active(): perm |= mask if mask != (audit.AUDIT_PERM_READ | audit.AUDIT_PERM_WRITE | audit.AUDIT_PERM_EXEC | audit.AUDIT_PERM_ATTR): f = Field() f.var = audit.AUDIT_PERM f.op = Field.OP_EQ f.value = perm rule.fields.append(f)