Skip to content

Commit 5ad5880

Browse files
committed
Restrict access to local storlet/dependency files
Now swift and storlet daemon inside containers run with consistent uid so we don't need group/other permissions. Also chown should be executed before actual file content is written, so that the content is not read by a different user. Closes-Bug: #2047723 Change-Id: I7790e51556875be1fc6438d1e2c599b693ca3b5b
1 parent 9aa8ab2 commit 5ad5880

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

storlets/gateway/gateways/docker/gateway.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def bring_from_cache(self, obj_name, sreq, is_storlet):
279279
get_func = sreq.file_manager.get_dependency
280280

281281
if not os.path.exists(cache_dir):
282-
os.makedirs(cache_dir, 0o755)
282+
os.makedirs(cache_dir, 0o700)
283283

284284
# cache_target_path is the actual object we need to deal with
285285
# e.g. a concrete storlet or dependency we need to bring/update
@@ -312,16 +312,17 @@ def bring_from_cache(self, obj_name, sreq, is_storlet):
312312
# bring the object from storge
313313
data_iter, perm = get_func(obj_name)
314314

315+
if perm:
316+
perm = int(perm, 8) & 0o700
317+
else:
318+
perm = 0o600
319+
315320
# TODO(takashi): Do not directly write to target path
316321
with open(cache_target_path, 'wb') as fn:
322+
os.chmod(cache_target_path, perm)
317323
for data in data_iter:
318324
fn.write(data)
319325

320-
if not is_storlet:
321-
if not perm:
322-
perm = '0600'
323-
os.chmod(cache_target_path, int(perm, 8))
324-
325326
# The node's local cache is now updated.
326327
# We now verify if we need to update the
327328
# Docker container itself.
@@ -334,7 +335,7 @@ def bring_from_cache(self, obj_name, sreq, is_storlet):
334335
docker_target_path = os.path.join(docker_storlet_path, obj_name)
335336

336337
if not os.path.exists(docker_storlet_path):
337-
os.makedirs(docker_storlet_path, 0o755)
338+
os.makedirs(docker_storlet_path, 0o700)
338339
update_docker = True
339340
elif not os.path.isfile(docker_target_path):
340341
update_docker = True

0 commit comments

Comments
 (0)