Mount backup shares using tech's uid/gid

* Allows read-write access without root/sudo
This commit is contained in:
2Shirt 2019-05-16 15:35:25 -06:00
parent eb4e9914d4
commit 54cb77f737
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -293,6 +293,14 @@ def mount_backup_shares(read_write=False):
def mount_network_share(server, read_write=False):
"""Mount a network share defined by server."""
uid = '1000'
# Get UID
cmd = ['id', '--user', 'tech']
result = run_program(cmd, check=False, encoding='utf-8', errors='ignore')
if result.stdout.strip().isnumeric():
uid = result.stdout.strip()
if read_write:
username = server['RW-User']
password = server['RW-Pass']
@ -315,7 +323,11 @@ def mount_network_share(server, read_write=False):
run_program(cmd)
# Set mount options
cmd_options = []
cmd_options = [
# Assuming GID matches UID
'gid={}'.format(uid),
'uid={}'.format(uid),
]
cmd_options.append('rw' if read_write else 'ro')
cmd_options.append('username={}'.format(username))
if password: