1 | Sat Feb 20 22:25:27 MST 2010 zooko@zooko.com |
---|
2 | * minor code clean-up in dirnode.py |
---|
3 | Impose micro-POLA by passing only the writekey instead of the whole node object to {{{_encrypt_rw_uri()}}}. Remove DummyImmutableFileNode in nodemaker.py, which is obviated by this. Add micro-optimization by precomputing the netstring of the empty string and branching on whether the writekey is present or not outside of {{{_encrypt_rw_uri()}}}. Add doc about writekey to docstring. |
---|
4 | |
---|
5 | New patches: |
---|
6 | |
---|
7 | [minor code clean-up in dirnode.py |
---|
8 | zooko@zooko.com**20100221052527 |
---|
9 | Ignore-this: b01bfb47638f5a64256bb306e0022066 |
---|
10 | Impose micro-POLA by passing only the writekey instead of the whole node object to {{{_encrypt_rw_uri()}}}. Remove DummyImmutableFileNode in nodemaker.py, which is obviated by this. Add micro-optimization by precomputing the netstring of the empty string and branching on whether the writekey is present or not outside of {{{_encrypt_rw_uri()}}}. Add doc about writekey to docstring. |
---|
11 | ] { |
---|
12 | hunk ./src/allmydata/dirnode.py 137 |
---|
13 | new_contents = self.node._pack_contents(children) |
---|
14 | return new_contents |
---|
15 | |
---|
16 | -def _encrypt_rw_uri(filenode, rw_uri): |
---|
17 | - assert isinstance(rw_uri, str) |
---|
18 | - writekey = filenode.get_writekey() |
---|
19 | - if not writekey: |
---|
20 | - return "" |
---|
21 | +def _encrypt_rw_uri(writekey, rw_uri): |
---|
22 | + precondition(isinstance(rw_uri, str), rw_uri) |
---|
23 | + precondition(isinstance(writekey, str), writekey) |
---|
24 | + |
---|
25 | salt = hashutil.mutable_rwcap_salt_hash(rw_uri) |
---|
26 | key = hashutil.mutable_rwcap_key_hash(salt, writekey) |
---|
27 | cryptor = AES(key) |
---|
28 | hunk ./src/allmydata/dirnode.py 151 |
---|
29 | # The MAC is not checked by readers in Tahoe >= 1.3.0, but we still |
---|
30 | # produce it for the sake of older readers. |
---|
31 | |
---|
32 | -def pack_children(filenode, children, deep_immutable=False): |
---|
33 | +ZERO_LEN_NETSTR=netstring('') |
---|
34 | + |
---|
35 | +def pack_children(children, writekey=None, deep_immutable=False): |
---|
36 | """Take a dict that maps: |
---|
37 | children[unicode_name] = (IFileSystemNode, metadata_dict) |
---|
38 | and pack it into a single string, for use as the contents of the backing |
---|
39 | hunk ./src/allmydata/dirnode.py 162 |
---|
40 | as the pre-packed entry, which is faster than re-packing everything each |
---|
41 | time. |
---|
42 | |
---|
43 | + If writekey is provided then I will superencrypt the child's writecap with |
---|
44 | + writekey. |
---|
45 | + |
---|
46 | If deep_immutable is True, I will require that all my children are deeply |
---|
47 | immutable, and will raise a MustBeDeepImmutableError if not. |
---|
48 | """ |
---|
49 | hunk ./src/allmydata/dirnode.py 168 |
---|
50 | + precondition((writekey is None) or isinstance(writekey, str), writekey) |
---|
51 | |
---|
52 | has_aux = isinstance(children, AuxValueDict) |
---|
53 | entries = [] |
---|
54 | hunk ./src/allmydata/dirnode.py 196 |
---|
55 | if ro_uri is None: |
---|
56 | ro_uri = "" |
---|
57 | assert isinstance(ro_uri, str), ro_uri |
---|
58 | + if writekey is not None: |
---|
59 | + writecap = netstring(_encrypt_rw_uri(writekey, rw_uri)) |
---|
60 | + else: |
---|
61 | + writecap = ZERO_LEN_NETSTR |
---|
62 | entry = "".join([netstring(name.encode("utf-8")), |
---|
63 | netstring(strip_prefix_for_ro(ro_uri, deep_immutable)), |
---|
64 | hunk ./src/allmydata/dirnode.py 202 |
---|
65 | - netstring(_encrypt_rw_uri(filenode, rw_uri)), |
---|
66 | + writecap, |
---|
67 | netstring(simplejson.dumps(metadata))]) |
---|
68 | entries.append(netstring(entry)) |
---|
69 | return "".join(entries) |
---|
70 | hunk ./src/allmydata/dirnode.py 315 |
---|
71 | |
---|
72 | def _pack_contents(self, children): |
---|
73 | # expects children in the same format as _unpack_contents |
---|
74 | - return pack_children(self._node, children) |
---|
75 | + return pack_children(children, self._node.get_writekey()) |
---|
76 | |
---|
77 | def is_readonly(self): |
---|
78 | return self._node.is_readonly() |
---|
79 | hunk ./src/allmydata/nodemaker.py 106 |
---|
80 | "create_new_mutable_directory requires metadata to be a dict, not None", metadata) |
---|
81 | node.raise_error() |
---|
82 | d = self.create_mutable_file(lambda n: |
---|
83 | - pack_children(n, initial_children)) |
---|
84 | + pack_children(initial_children, n.get_writekey())) |
---|
85 | d.addCallback(self._create_dirnode) |
---|
86 | return d |
---|
87 | |
---|
88 | hunk ./src/allmydata/nodemaker.py 119 |
---|
89 | node.raise_error() |
---|
90 | if not node.is_allowed_in_immutable_directory(): |
---|
91 | raise MustBeDeepImmutableError("%s is not immutable" % (node,), name) |
---|
92 | - n = DummyImmutableFileNode() # writekey=None |
---|
93 | - packed = pack_children(n, children) |
---|
94 | + packed = pack_children(children) |
---|
95 | uploadable = Data(packed, convergence) |
---|
96 | d = self.uploader.upload(uploadable, history=self.history) |
---|
97 | d.addCallback(lambda results: self.create_from_cap(None, results.uri)) |
---|
98 | hunk ./src/allmydata/test/test_dirnode.py 1123 |
---|
99 | |
---|
100 | kids = self._make_kids(nm, ["imm", "lit", "write", "read", |
---|
101 | "dirwrite", "dirread"]) |
---|
102 | - packed = dirnode.pack_children(fn, kids, deep_immutable=False) |
---|
103 | + packed = dirnode.pack_children(kids, fn.get_writekey(), deep_immutable=False) |
---|
104 | self.failUnlessIn("lit", packed) |
---|
105 | |
---|
106 | kids = self._make_kids(nm, ["imm", "lit"]) |
---|
107 | hunk ./src/allmydata/test/test_dirnode.py 1127 |
---|
108 | - packed = dirnode.pack_children(fn, kids, deep_immutable=True) |
---|
109 | + packed = dirnode.pack_children(kids, fn.get_writekey(), deep_immutable=True) |
---|
110 | self.failUnlessIn("lit", packed) |
---|
111 | |
---|
112 | kids = self._make_kids(nm, ["imm", "lit", "write"]) |
---|
113 | hunk ./src/allmydata/test/test_dirnode.py 1133 |
---|
114 | self.failUnlessRaises(dirnode.MustBeDeepImmutableError, |
---|
115 | dirnode.pack_children, |
---|
116 | - fn, kids, deep_immutable=True) |
---|
117 | + kids, fn.get_writekey(), deep_immutable=True) |
---|
118 | |
---|
119 | # read-only is not enough: all children must be immutable |
---|
120 | kids = self._make_kids(nm, ["imm", "lit", "read"]) |
---|
121 | hunk ./src/allmydata/test/test_dirnode.py 1139 |
---|
122 | self.failUnlessRaises(dirnode.MustBeDeepImmutableError, |
---|
123 | dirnode.pack_children, |
---|
124 | - fn, kids, deep_immutable=True) |
---|
125 | + kids, fn.get_writekey(), deep_immutable=True) |
---|
126 | |
---|
127 | kids = self._make_kids(nm, ["imm", "lit", "dirwrite"]) |
---|
128 | self.failUnlessRaises(dirnode.MustBeDeepImmutableError, |
---|
129 | hunk ./src/allmydata/test/test_dirnode.py 1144 |
---|
130 | dirnode.pack_children, |
---|
131 | - fn, kids, deep_immutable=True) |
---|
132 | + kids, fn.get_writekey(), deep_immutable=True) |
---|
133 | |
---|
134 | kids = self._make_kids(nm, ["imm", "lit", "dirread"]) |
---|
135 | self.failUnlessRaises(dirnode.MustBeDeepImmutableError, |
---|
136 | hunk ./src/allmydata/test/test_dirnode.py 1149 |
---|
137 | dirnode.pack_children, |
---|
138 | - fn, kids, deep_immutable=True) |
---|
139 | + kids, fn.get_writekey(), deep_immutable=True) |
---|
140 | |
---|
141 | class FakeMutableFile: |
---|
142 | implements(IMutableFileNode) |
---|
143 | } |
---|
144 | |
---|
145 | Context: |
---|
146 | |
---|
147 | [setup: comment-out the dependency on pycrypto, see #953 |
---|
148 | zooko@zooko.com**20100215050844 |
---|
149 | Ignore-this: 2751120921ff35b8189d8fcd896da149 |
---|
150 | ] |
---|
151 | [Add tests for #939 |
---|
152 | Kevan Carstensen <kevan@isnotajoke.com>**20100212062137 |
---|
153 | Ignore-this: 5459e8c64ba76cca70aa720e68549637 |
---|
154 | ] |
---|
155 | [Alter CLI utilities to handle nonexistent aliases better |
---|
156 | Kevan Carstensen <kevan@isnotajoke.com>**20100211024318 |
---|
157 | Ignore-this: e698ea4a57f5fe27c24336581ca0cf65 |
---|
158 | ] |
---|
159 | [adding pycrypto to the auto dependencies |
---|
160 | secorp@allmydata.com**20100206054314 |
---|
161 | Ignore-this: b873fc00a6a5b001d30d479e6053cf2f |
---|
162 | ] |
---|
163 | [docs running.html - "tahoe run ." does not work with the current installation, replaced with "tahoe start ." |
---|
164 | secorp@allmydata.com**20100206165320 |
---|
165 | Ignore-this: fdb2dcb0e417d303cd43b1951a4f8c03 |
---|
166 | ] |
---|
167 | [web/storage.py: display total-seen on the last-complete-cycle line. For #940. |
---|
168 | Brian Warner <warner@lothar.com>**20100208002010 |
---|
169 | Ignore-this: c0ed860f3e9628d3171d2b055d96c5aa |
---|
170 | ] |
---|
171 | [code coverage: replace figleaf with coverage.py, should work on py2.6 now. |
---|
172 | Brian Warner <warner@lothar.com>**20100203165421 |
---|
173 | Ignore-this: 46ab590360be6a385cb4fc4e68b6b42c |
---|
174 | |
---|
175 | It still lacks the right HTML report (the builtin report is very pretty, but |
---|
176 | lacks the "lines uncovered" numbers that I want), and the half-finished |
---|
177 | delta-from-last-run measurements. |
---|
178 | ] |
---|
179 | [More comprehensive changes and ticket references for NEWS |
---|
180 | david-sarah@jacaranda.org**20100202061256 |
---|
181 | Ignore-this: 696cf0106e8a7fd388afc5b55fba8a1b |
---|
182 | ] |
---|
183 | [docs: install.html: link into Python 2.5.5 download page |
---|
184 | zooko@zooko.com**20100202065852 |
---|
185 | Ignore-this: 1a9471b8175b7de5741d8445a7ede29d |
---|
186 | ] |
---|
187 | [TAG allmydata-tahoe-1.6.0 |
---|
188 | zooko@zooko.com**20100202061125 |
---|
189 | Ignore-this: dee6ade7ac1452cf5d1d9c69a8146d84 |
---|
190 | ] |
---|
191 | Patch bundle hash: |
---|
192 | 77b4d4157ad48fdc10c05c2bf979c0f8b8220402 |
---|