forked from timdiels/zeroinstall
/
0store-secure-add
executable file
·33 lines (24 loc) · 1000 Bytes
/
0store-secure-add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
from __future__ import print_function
import sys, os
from zeroinstall import zerostore, SafeException
from zeroinstall.zerostore import cli, manifest
# Make all system files world-readable, even if the default
# system umask is more strict.
os.umask(0o022)
# import logging; logging.getLogger().setLevel(logging.DEBUG)
try:
if 'ENV_NOT_CLEARED' in os.environ:
raise SafeException("Environment not cleared. Check your sudoers file.")
if os.environ['HOME'] == 'Unclean':
raise SafeException("$HOME not set. Check your sudoers file has 'always_set_home' turned on for zeroinst.")
if len(sys.argv) != 2:
raise cli.UsageError('Usage: %s DIGEST' % sys.argv[0])
required_digest = sys.argv[1]
manifest_data = open('.manifest', 'rb').read()
stores = zerostore.Stores()
manifest.copy_tree_with_verify('.', '/var/cache/0install.net/implementations',
manifest_data, required_digest)
except (IOError, SafeException) as ex:
print(ex, file=sys.stderr)
sys.exit(1)