Skip to content

Commit

Permalink
Call fs_hash.sh tool using root_command wrapper
Browse files Browse the repository at this point in the history
Currently, this hashing function needs to run as root. Sudo was
hard coded into the subprocess call, which causes it to fail if the
user running fs_hash was root, as is the case with Docker containers

Fixes #153

Signed-off-by: Nisha K <[email protected]>
  • Loading branch information
Nisha K committed Jan 25, 2019
1 parent 389bafd commit 6e75f82
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/rootfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ def calc_fs_hash(fs_path):
directory.
Note that this file will be deleted if the -k flag is not given'''
try:
hash_contents = subprocess.check_output(
['sudo', './tools/fs_hash.sh', os.path.abspath(fs_path)])
hash_contents = root_command(
['./tools/fs_hash.sh'], os.path.abspath(fs_path))
file_name = hashlib.sha256(hash_contents).hexdigest()
# write file to an appropriate location
hash_file = os.path.join(os.path.dirname(fs_path), file_name) + '.txt'
Expand Down

0 comments on commit 6e75f82

Please sign in to comment.