projects/guix·blob java-team · refs

432 lines · 13.9 KiB

1Shortend version of
2From 351ad5e5e2dd67f427b7eb2e4d5d0b35d90ffaf7 Mon Sep 17 00:00:00 2001
3From: Justus Winter <[email protected]>
4Date: Wed, 24 Nov 2021 15:09:34 +0100
5Subject: [PATCH] store: Drop crate.
6
7 - The store has never been really used, and never reached a maturity
8 where it was useful. And, we're on the verge of replacing it with
9 the Shared PGP Certificate Directory.
10---
11 Cargo.toml | 1 -
12 ffi/Cargo.toml | 4 +-
13 ffi/include/sequoia.h | 1 -
14 ffi/include/sequoia/store.h | 409 ------
15 ffi/lang/python/sequoia/__init__.py | 1 -
16 ffi/lang/python/sequoia/prelude.py | 1 -
17 ffi/lang/python/sequoia/sequoia_build.py | 3 +-
18 ffi/lang/python/sequoia/store.py | 246 ----
19 ffi/lang/python/tests/test_store.py | 47 -
20 ffi/src/lib.rs | 2 -
21 ffi/src/store.rs | 659 ----------
22 25 files changed, 3 insertions(+), 5064 deletions(-)
23 delete mode 100644 ffi/include/sequoia/store.h
24 delete mode 100644 ffi/lang/python/sequoia/store.py
25 delete mode 100644 ffi/lang/python/tests/test_store.py
26 delete mode 100644 ffi/src/store.rs
27
28diff --git a/Cargo.toml b/Cargo.toml
29index a4f48520..a573ddbf 100644
30--- a/Cargo.toml
31+++ b/Cargo.toml
32@@ -10,7 +10,6 @@ members = [
33 "openpgp",
34 "openpgp-ffi",
35 "sq",
36- "store",
37 ]
38
39 [profile.release]
40diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml
41index 53ddaf68..2ec84e6e 100644
42--- a/ffi/Cargo.toml
43+++ b/ffi/Cargo.toml
44@@ -24,7 +24,6 @@ maintenance = { status = "actively-developed" }
45 [dependencies]
46 sequoia-ffi-macros = { path = "../ffi-macros", version = "0.22" }
47 sequoia-openpgp = { path = "../openpgp", version = "1.0.0", default-features = false }
48-sequoia-store = { path = "../store", version = "0.22", default-features = false }
49 sequoia-net = { path = "../net", version = "0.23", default-features = false }
50 sequoia-ipc = { path = "../ipc", version = "0.26", default-features = false }
51 anyhow = "1.0.18"
52@@ -42,10 +41,9 @@ crate-type = ["cdylib", "staticlib"]
53 bench = false
54
55 [features]
56-default = ["sequoia-openpgp/default", "sequoia-store/default"]
57+default = ["sequoia-openpgp/default"]
58 crypto-nettle = ["sequoia-openpgp/crypto-nettle"]
59 crypto-cng = ["sequoia-openpgp/crypto-cng"]
60 compression = ["sequoia-openpgp/compression"]
61 compression-deflate = ["sequoia-openpgp/compression-deflate"]
62 compression-bzip2 = ["sequoia-openpgp/compression-bzip2"]
63-background-services = ["sequoia-store/background-services"]
64diff --git a/ffi/include/sequoia.h b/ffi/include/sequoia.h
65index 8c62ba8f..c32a2f3e 100644
66--- a/ffi/include/sequoia.h
67+++ b/ffi/include/sequoia.h
68@@ -5,6 +5,5 @@
69 #include <sequoia/core.h>
70 #include <sequoia/openpgp.h>
71 #include <sequoia/net.h>
72-#include <sequoia/store.h>
73
74 #endif
75diff --git a/ffi/lang/python/sequoia/__init__.py b/ffi/lang/python/sequoia/__init__.py
76index 4f84346e..fc170e20 100644
77--- a/ffi/lang/python/sequoia/__init__.py
78+++ b/ffi/lang/python/sequoia/__init__.py
79@@ -4,5 +4,4 @@ from . import (
80 openpgp,
81 core,
82 net,
83- store,
84 )
85diff --git a/ffi/lang/python/sequoia/prelude.py b/ffi/lang/python/sequoia/prelude.py
86index 42b0156a..61efbab0 100644
87--- a/ffi/lang/python/sequoia/prelude.py
88+++ b/ffi/lang/python/sequoia/prelude.py
89@@ -3,4 +3,3 @@ from .error import *
90 from .openpgp import *
91 from .core import *
92 from .net import *
93-from .store import *
94diff --git a/ffi/lang/python/sequoia/sequoia_build.py b/ffi/lang/python/sequoia/sequoia_build.py
95index a3ce2786..058f1380 100644
96--- a/ffi/lang/python/sequoia/sequoia_build.py
97+++ b/ffi/lang/python/sequoia/sequoia_build.py
98@@ -14,8 +14,7 @@ defs = "".join(l
99 open(join(pgp_inc, "openpgp/serialize.h")).readlines(),
100 open(join(pgp_inc, "openpgp.h")).readlines(),
101 open(join(sq_inc, "core.h")).readlines(),
102- open(join(sq_inc, "net.h")).readlines(),
103- open(join(sq_inc, "store.h")).readlines())
104+ open(join(sq_inc, "net.h")).readlines())
105 if not l.startswith('#'))
106
107 defs = defs.replace("INT_MAX", "{}".format(1<<31))
108diff --git a/ffi/lang/python/sequoia/store.py b/ffi/lang/python/sequoia/store.py
109deleted file mode 100644
110index 57d1b18f..00000000
111--- a/ffi/lang/python/sequoia/store.py
112+++ /dev/null
113@@ -1,246 +0,0 @@
114-from _sequoia import ffi, lib
115-
116-from .error import Error
117-from .glue import _str, _static_str, SQObject, sq_iterator, sq_time
118-from .net import NetworkPolicy
119-from .openpgp import Fingerprint, Cert
120-
121-class Store(object):
122- @classmethod
123- def log(cls, ctx):
124- yield from sq_iterator(
125- ffi.gc(
126- lib.sq_store_server_log(ctx.ref()),
127- lib.sq_log_iter_free),
128- lib.sq_log_iter_next,
129- lambda x: Log(x, context=ctx))
130-
131- @classmethod
132- def list_keys(cls, ctx):
133- def next_fn(i):
134- fpp = ffi.new("pgp_fingerprint_t[1]")
135- key = lib.sq_key_iter_next(i, fpp)
136- if key == ffi.NULL:
137- return ffi.NULL
138- else:
139- return (Fingerprint(fpp[0], ctx),
140- Key(key, ctx))
141-
142- yield from sq_iterator(
143- ffi.gc(
144- lib.sq_store_list_keys(ctx.ref()),
145- lib.sq_key_iter_free),
146- next_fn)
147-
148-class Mapping(SQObject):
149- _del = lib.sq_mapping_free
150-
151- # Keys used for communications.
152- REALM_CONTACTS = _static_str(lib.SQ_REALM_CONTACTS)
153-
154- # Keys used for signing software updates.
155- REALM_SOFTWARE_UPDATES = _static_str(lib.SQ_REALM_SOFTWARE_UPDATES)
156-
157- @classmethod
158- def open(cls, ctx, network_policy=NetworkPolicy.Encrypted, realm=REALM_CONTACTS, name="default"):
159- return Mapping(lib.sq_mapping_open(ctx.ref(), network_policy.value,
160- realm.encode(), name.encode()),
161- context=ctx)
162-
163-
164- def add(self, label, fingerprint):
165- return Binding(lib.sq_mapping_add(self.context().ref(), self.ref(),
166- label.encode(), fingerprint.ref()),
167- context=self.context())
168-
169- def import_(self, label, cert):
170- return Cert(lib.sq_mapping_import(self.context().ref(), self.ref(),
171- label.encode(), cert.ref()),
172- context=self.context())
173-
174- def lookup(self, label):
175- return Binding(lib.sq_mapping_lookup(self.context().ref(), self.ref(),
176- label.encode()),
177- self.context())
178-
179- def delete(self):
180- if lib.sq_mapping_delete(self.ref()):
181- raise Error._last(self.context())
182- super(Mapping, self)._delete(skip_free=True)
183-
184- def iter(self):
185- def next_fn(i):
186- labelp = ffi.new("char *[1]")
187- fpp = ffi.new("pgp_fingerprint_t[1]")
188- binding = lib.sq_binding_iter_next(i, labelp, fpp)
189- if binding == ffi.NULL:
190- return ffi.NULL
191- else:
192- return (_str(labelp[0]),
193- Fingerprint(fpp[0], self.context()),
194- Binding(binding, self.context()))
195-
196- yield from sq_iterator(
197- ffi.gc(
198- lib.sq_mapping_iter(self.context().ref(), self.ref()),
199- lib.sq_binding_iter_free),
200- next_fn)
201-
202- def log(self):
203- yield from sq_iterator(
204- ffi.gc(
205- lib.sq_mapping_log(self.context().ref(), self.ref()),
206- lib.sq_log_iter_free),
207- lib.sq_log_iter_next,
208- lambda x: Log(x, context=self.context()))
209-
210-class Binding(SQObject):
211- _del = lib.sq_binding_free
212-
213- def stats(self):
214- return Stats(lib.sq_binding_stats(self.context().ref(), self.ref()),
215- self.context())
216-
217- def key(self):
218- return Key(lib.sq_binding_key(self.context().ref(), self.ref()),
219- self.context())
220-
221- def cert(self):
222- return Cert(lib.sq_binding_cert(self.context().ref(), self.ref()),
223- self.context())
224-
225- def import_(self, cert):
226- return Cert(lib.sq_binding_import(self.context().ref(), self.ref(), cert),
227- self.context())
228-
229- def rotate(self, cert):
230- return Cert(lib.sq_binding_rotate(self.context().ref(), self.ref(), cert),
231- self.context())
232-
233- def delete(self):
234- if lib.sq_binding_delete(self.ref()):
235- raise Error._last(self.context())
236- super(Binding, self)._delete(skip_free=True)
237-
238- def log(self):
239- yield from sq_iterator(
240- ffi.gc(
241- lib.sq_binding_log(self.context().ref(), self.ref()),
242- lib.sq_log_iter_free),
243- lib.sq_log_iter_next,
244- lambda x: Log(x, context=self.context()))
245-
246-class Key(SQObject):
247- _del = lib.sq_key_free
248-
249- def stats(self):
250- return Stats(lib.sq_key_stats(self.context().ref(), self.ref()),
251- self.context())
252-
253- def cert(self):
254- return Cert(lib.sq_key_cert(self.context().ref(), self.ref()),
255- self.context())
256-
257- def import_(self, cert):
258- return Cert(lib.sq_key_import(self.context().ref(), self.ref(), cert),
259- self.context())
260-
261- def log(self):
262- yield from sq_iterator(
263- ffi.gc(
264- lib.sq_key_log(self.context().ref(), self.ref()),
265- lib.sq_log_iter_free),
266- lib.sq_log_iter_next)
267-
268-
269-class Stats(SQObject):
270- _del = lib.sq_stats_free
271- def __init__(self, o, context=None):
272- super(Stats, self).__init__(o, context=context)
273- self.encryption = Stamps(ffi.addressof(o, "encryption"))
274- self.verification = Stamps(ffi.addressof(o, "verification"))
275-
276- @property
277- def created(self):
278- return sq_time(self.ref().created)
279-
280- @property
281- def updated(self):
282- return sq_time(self.ref().updated)
283-
284- def __str__(self):
285- return \
286- "Stats{{created={}, updated={}, encryption={}, verification={}}}" \
287- .format(self.created, self.updated, self.encryption,
288- self.verification)
289-
290-class Stamps(SQObject):
291- @property
292- def count(self):
293- return self.ref().count
294-
295- @property
296- def first(self):
297- return sq_time(self.ref().first)
298-
299- @property
300- def last(self):
301- return sq_time(self.ref().last)
302-
303- def __str__(self):
304- return "Stamps{{count={}, first={}, last={}}}".format(
305- self.count, self.first, self.last)
306-
307-class Log(SQObject):
308- _del = lib.sq_log_free
309-
310- @property
311- def timestamp(self):
312- return sq_time(self.ref().timestamp)
313-
314- @property
315- def store(self):
316- if self.ref().store == ffi.NULL:
317- return None
318- else:
319- return Store(self.ref().store, context=self.context(),
320- owner=self)
321-
322- @property
323- def binding(self):
324- if self.ref().binding == ffi.NULL:
325- return None
326- else:
327- return Binding(self.ref().binding, context=self.context(),
328- owner=self)
329-
330- @property
331- def key(self):
332- if self.ref().key == ffi.NULL:
333- return None
334- else:
335- return Key(self.ref().key, context=self.context(),
336- owner=self)
337-
338- @property
339- def slug(self):
340- return ffi.string(self.ref().slug).decode()
341-
342- @property
343- def status(self):
344- return ffi.string(self.ref().status).decode()
345-
346- @property
347- def error(self):
348- if self.ref().error == ffi.NULL:
349- return None
350- else:
351- return ffi.string(self.ref().error).decode()
352-
353- def __str__(self):
354- if self.error:
355- return "{}: {}: {}: {}".format(
356- self.timestamp, self.slug, self.status, self.error)
357- else:
358- return "{}: {}: {}".format(
359- self.timestamp, self.slug, self.status)
360diff --git a/ffi/lang/python/tests/test_store.py b/ffi/lang/python/tests/test_store.py
361deleted file mode 100644
362index 7b06cc1a..00000000
363--- a/ffi/lang/python/tests/test_store.py
364+++ /dev/null
365@@ -1,47 +0,0 @@
366-from sequoia.prelude import Context, Store, Mapping, Fingerprint
367-
368-def test_open():
369- c = Context(ephemeral=True)
370- Mapping.open(c)
371-
372-def test_add():
373- c = Context(ephemeral=True)
374- s = Mapping.open(c)
375- fp = Fingerprint.from_hex("7DCA58B54EB143169DDEE15F247F6DABC84914FE")
376- s.add("Ἀριστοτέλης", fp)
377-
378-def test_iterate():
379- c = Context(ephemeral=True)
380- s = Mapping.open(c)
381- fp = Fingerprint.from_hex("7DCA58B54EB143169DDEE15F247F6DABC84914FE")
382- s.add("Ἀριστοτέλης", fp)
383- l = list(s.iter())
384- assert len(l) == 1
385- l = list(Store.list_keys(c))
386- assert len(l) == 1
387- fpi, key = l[0]
388- assert fpi == fp
389-
390-def test_logs():
391- c = Context(ephemeral=True)
392- s = Mapping.open(c)
393- fp = Fingerprint.from_hex("7DCA58B54EB143169DDEE15F247F6DABC84914FE")
394- b = s.add("Ἀριστοτέλης", fp)
395- l = list(s.iter())
396- assert len(l) == 1
397-
398- # global logs
399- logs = list(Store.log(c))
400- assert len(logs) > 0
401-
402- # per store logs
403- logs = list(s.log())
404- assert len(logs) > 0
405-
406- # per binding logs
407- logs = list(b.log())
408- assert len(logs) > 0
409-
410- # per key logs
411- logs = list(b.key().log())
412- assert len(logs) > 0
413diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs
414index 40e3672e..9b4577eb 100644
415--- a/ffi/src/lib.rs
416+++ b/ffi/src/lib.rs
417@@ -130,7 +130,6 @@ pub(crate) use crate::openpgp::{
418 MoveResultIntoRaw,
419 Maybe,
420 maybe_time,
421- to_time_t,
422 };
423
424 /* Error handling with implicit context. */
425@@ -146,5 +145,4 @@ macro_rules! ffi_make_fry_from_ctx {
426 pub mod core;
427 pub mod error;
428 pub mod net;
429-pub mod store;
430
431GitLab
432