47
50
import gnutls.library.functions
48
51
import gnutls.library.constants
49
52
import gnutls.library.types
50
import ConfigParser as configparser
54
import ConfigParser as configparser
1098
1111
interface_names.add(alt_interface)
1099
1112
# Is this a D-Bus signal?
1100
1113
if getattr(attribute, "_dbus_is_signal", False):
1101
# Extract the original non-method undecorated
1102
# function by black magic
1103
nonmethod_func = (dict(
1104
zip(attribute.func_code.co_freevars,
1105
attribute.__closure__))
1106
["func"].cell_contents)
1114
if sys.version == 2:
1115
# Extract the original non-method undecorated
1116
# function by black magic
1117
nonmethod_func = (dict(
1118
zip(attribute.func_code.co_freevars,
1119
attribute.__closure__))
1120
["func"].cell_contents)
1122
nonmethod_func = attribute
1107
1123
# Create a new, but exactly alike, function
1108
1124
# object, and decorate it to be a new D-Bus signal
1109
1125
# with the alternate D-Bus interface name
1126
if sys.version == 2:
1127
new_function = types.FunctionType(
1128
nonmethod_func.func_code,
1129
nonmethod_func.func_globals,
1130
nonmethod_func.func_name,
1131
nonmethod_func.func_defaults,
1132
nonmethod_func.func_closure)
1134
new_function = types.FunctionType(
1135
nonmethod_func.__code__,
1136
nonmethod_func.__globals__,
1137
nonmethod_func.__name__,
1138
nonmethod_func.__defaults__,
1139
nonmethod_func.__closure__)
1110
1140
new_function = (dbus.service.signal(
1111
alt_interface, attribute._dbus_signature)
1112
(types.FunctionType(
1113
nonmethod_func.func_code,
1114
nonmethod_func.func_globals,
1115
nonmethod_func.func_name,
1116
nonmethod_func.func_defaults,
1117
nonmethod_func.func_closure)))
1142
attribute._dbus_signature)(new_function))
1118
1143
# Copy annotations, if any
1120
1145
new_function._dbus_annotations = dict(
2169
2194
# avoid excessive use of external libraries.
2171
2196
# New type for defining tokens, syntax, and semantics all-in-one
2172
Token = collections.namedtuple("Token",
2173
("regexp", # To match token; if
2174
# "value" is not None,
2175
# must have a "group"
2177
"value", # datetime.timedelta or
2179
"followers")) # Tokens valid after
2181
2197
Token = collections.namedtuple("Token", (
2182
2198
"regexp", # To match token; if "value" is not None, must have
2183
2199
# a "group" containing digits
2218
2234
# Define starting values
2219
2235
value = datetime.timedelta() # Value so far
2220
2236
found_token = None
2221
followers = frozenset((token_duration,)) # Following valid tokens
2237
followers = frozenset((token_duration, )) # Following valid tokens
2222
2238
s = duration # String left to parse
2223
2239
# Loop until end token is found
2224
2240
while found_token is not token_end:
2498
2515
pidfilename = "/var/run/mandos.pid"
2501
pidfile = open(pidfilename, "w")
2518
pidfile = codecs.open(pidfilename, "w", encoding="utf-8")
2502
2519
except IOError as e:
2503
2520
logger.error("Could not open file %r", pidfilename,
2563
2580
old_bus_name = dbus.service.BusName(
2564
2581
"se.bsnet.fukt.Mandos", bus,
2565
2582
do_not_queue=True)
2566
except dbus.exceptions.NameExistsException as e:
2583
except dbus.exceptions.DBusException as e:
2567
2584
logger.error("Disabling D-Bus:", exc_info=e)
2568
2585
use_dbus = False
2569
2586
server_settings["use_dbus"] = False