Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 12875f9

Browse files
committed
Merge remote-tracking branch 'origin/develop' into shhs
2 parents ed38141 + c1799b0 commit 12875f9

File tree

11 files changed

+101
-19
lines changed

11 files changed

+101
-19
lines changed

INSTALL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ sudo apt update
281281
sudo apt install matrix-synapse-py3
282282
```
283283

284+
The fingerprint of the repository signing key is AAF9AE843A7584B5A3E4CD2BCF45A512DE2DA058.
285+
284286
**Note**: if you followed a previous version of these instructions which
285287
recommended using `apt-key add` to add an old key from
286288
`https://matrix.org/packages/debian/`, you should note that this key has been

changelog.d/4867.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a default .m.rule.tombstone push rule.

changelog.d/5100.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve logging when event-signature checks fail.

changelog.d/5103.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug where presence updates were sent to all servers in a room when a new server joined, rather than to just the new server.

changelog.d/5116.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add time-based account expiration.

docs/admin_api/account_validity.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This API extends the validity of an account by as much time as configured in the
1313

1414
The API is::
1515

16-
POST /_matrix/client/unstable/account_validity/send_mail
16+
POST /_matrix/client/unstable/admin/account_validity/validity
1717

1818
with the following body:
1919

synapse/crypto/keyring.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,40 +114,54 @@ def verify_json_objects_for_server(self, server_and_json):
114114
server_name. The deferreds run their callbacks in the sentinel
115115
logcontext.
116116
"""
117+
# a list of VerifyKeyRequests
117118
verify_requests = []
119+
handle = preserve_fn(_handle_key_deferred)
118120

119-
for server_name, json_object in server_and_json:
121+
def process(server_name, json_object):
122+
"""Process an entry in the request list
120123
124+
Given a (server_name, json_object) pair from the request list,
125+
adds a key request to verify_requests, and returns a deferred which will
126+
complete or fail (in the sentinel context) when verification completes.
127+
"""
121128
key_ids = signature_ids(json_object, server_name)
129+
122130
if not key_ids:
123-
logger.warn("Request from %s: no supported signature keys",
124-
server_name)
125-
deferred = defer.fail(SynapseError(
126-
400,
127-
"Not signed with a supported algorithm",
128-
Codes.UNAUTHORIZED,
129-
))
130-
else:
131-
deferred = defer.Deferred()
131+
return defer.fail(
132+
SynapseError(
133+
400,
134+
"Not signed by %s" % (server_name,),
135+
Codes.UNAUTHORIZED,
136+
)
137+
)
132138

133139
logger.debug("Verifying for %s with key_ids %s",
134140
server_name, key_ids)
135141

142+
# add the key request to the queue, but don't start it off yet.
136143
verify_request = VerifyKeyRequest(
137-
server_name, key_ids, json_object, deferred
144+
server_name, key_ids, json_object, defer.Deferred(),
138145
)
139-
140146
verify_requests.append(verify_request)
141147

142-
run_in_background(self._start_key_lookups, verify_requests)
148+
# now run _handle_key_deferred, which will wait for the key request
149+
# to complete and then do the verification.
150+
#
151+
# We want _handle_key_request to log to the right context, so we
152+
# wrap it with preserve_fn (aka run_in_background)
153+
return handle(verify_request)
143154

144-
# Pass those keys to handle_key_deferred so that the json object
145-
# signatures can be verified
146-
handle = preserve_fn(_handle_key_deferred)
147-
return [
148-
handle(rq) for rq in verify_requests
155+
results = [
156+
process(server_name, json_object)
157+
for server_name, json_object in server_and_json
149158
]
150159

160+
if verify_requests:
161+
run_in_background(self._start_key_lookups, verify_requests)
162+
163+
return results
164+
151165
@defer.inlineCallbacks
152166
def _start_key_lookups(self, verify_requests):
153167
"""Sets off the key fetches for each verify request

synapse/federation/federation_base.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,18 @@ def _check_sigs_on_pdus(keyring, room_version, pdus):
269269
for p in pdus_to_check_sender
270270
])
271271

272+
def sender_err(e, pdu_to_check):
273+
errmsg = "event id %s: unable to verify signature for sender %s: %s" % (
274+
pdu_to_check.pdu.event_id,
275+
pdu_to_check.sender_domain,
276+
e.getErrorMessage(),
277+
)
278+
# XX not really sure if these are the right codes, but they are what
279+
# we've done for ages
280+
raise SynapseError(400, errmsg, Codes.UNAUTHORIZED)
281+
272282
for p, d in zip(pdus_to_check_sender, more_deferreds):
283+
d.addErrback(sender_err, p)
273284
p.deferreds.append(d)
274285

275286
# now let's look for events where the sender's domain is different to the
@@ -291,7 +302,18 @@ def _check_sigs_on_pdus(keyring, room_version, pdus):
291302
for p in pdus_to_check_event_id
292303
])
293304

305+
def event_err(e, pdu_to_check):
306+
errmsg = (
307+
"event id %s: unable to verify signature for event id domain: %s" % (
308+
pdu_to_check.pdu.event_id,
309+
e.getErrorMessage(),
310+
)
311+
)
312+
# XX as above: not really sure if these are the right codes
313+
raise SynapseError(400, errmsg, Codes.UNAUTHORIZED)
314+
294315
for p, d in zip(pdus_to_check_event_id, more_deferreds):
316+
d.addErrback(event_err, p)
295317
p.deferreds.append(d)
296318

297319
# replace lists of deferreds with single Deferreds

synapse/handlers/presence.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,11 @@ def _handle_state_delta(self, deltas):
828828
if typ != EventTypes.Member:
829829
continue
830830

831+
if event_id is None:
832+
# state has been deleted, so this is not a join. We only care about
833+
# joins.
834+
continue
835+
831836
event = yield self.store.get_event(event_id)
832837
if event.content.get("membership") != Membership.JOIN:
833838
# We only care about joins

synapse/push/baserules.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,23 @@ def make_base_prepend_rules(kind, modified_base_rules):
261261
'value': True,
262262
}
263263
]
264+
},
265+
{
266+
'rule_id': 'global/override/.m.rule.tombstone',
267+
'conditions': [
268+
{
269+
'kind': 'event_match',
270+
'key': 'type',
271+
'pattern': 'm.room.tombstone',
272+
'_id': '_tombstone',
273+
}
274+
],
275+
'actions': [
276+
'notify', {
277+
'set_tweak': 'highlight',
278+
'value': True,
279+
}
280+
]
264281
}
265282
]
266283

0 commit comments

Comments
 (0)