/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

  • Committer: Teddy Hogeborn
  • Date: 2019-11-23 22:27:35 UTC
  • Revision ID: teddy@recompile.se-20191123222735-wp6z91c2kau3o63u
Server: Fix bug when setting Secret property of clients via D-Bus

* mandos (DBusObjectWithProperties.Set): On byte arrays, simply cast
  the value to "bytes".

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
import collections
79
79
import codecs
80
80
import unittest
81
 
import random
82
 
import shlex
83
81
 
84
82
import dbus
85
83
import dbus.service
93
91
 
94
92
if sys.version_info.major == 2:
95
93
    __metaclass__ = type
96
 
    str = unicode
97
 
 
98
 
# Add collections.abc.Callable if it does not exist
99
 
try:
100
 
    collections.abc.Callable
101
 
except AttributeError:
102
 
    class abc:
103
 
        Callable = collections.Callable
104
 
    collections.abc = abc
105
 
    del abc
106
 
 
107
 
# Add shlex.quote if it does not exist
108
 
try:
109
 
    shlex.quote
110
 
except AttributeError:
111
 
    shlex.quote = re.escape
112
94
 
113
95
# Show warnings by default
114
96
if not sys.warnoptions:
140
122
            # No value found
141
123
            SO_BINDTODEVICE = None
142
124
 
 
125
if sys.version_info.major == 2:
 
126
    str = unicode
 
127
 
143
128
if sys.version_info < (3, 2):
144
129
    configparser.Configparser = configparser.SafeConfigParser
145
130
 
1052
1037
        if self.checker_initiator_tag is not None:
1053
1038
            GLib.source_remove(self.checker_initiator_tag)
1054
1039
        self.checker_initiator_tag = GLib.timeout_add(
1055
 
            random.randrange(int(self.interval.total_seconds() * 1000
1056
 
                                 + 1)),
 
1040
            int(self.interval.total_seconds() * 1000),
1057
1041
            self.start_checker)
1058
1042
        # Schedule a disable() when 'timeout' has passed
1059
1043
        if self.disable_initiator_tag is not None:
1134
1118
        if self.checker is None:
1135
1119
            # Escape attributes for the shell
1136
1120
            escaped_attrs = {
1137
 
                attr: shlex.quote(str(getattr(self, attr)))
 
1121
                attr: re.escape(str(getattr(self, attr)))
1138
1122
                for attr in self.runtime_expansions}
1139
1123
            try:
1140
1124
                command = self.checker_command % escaped_attrs
2764
2748
        if command == 'getattr':
2765
2749
            attrname = request[1]
2766
2750
            if isinstance(client_object.__getattribute__(attrname),
2767
 
                          collections.abc.Callable):
 
2751
                          collections.Callable):
2768
2752
                parent_pipe.send(('function', ))
2769
2753
            else:
2770
2754
                parent_pipe.send((