Mount backup shares using tech's uid/gid
* Allows read-write access without root/sudo
This commit is contained in:
parent
eb4e9914d4
commit
54cb77f737
1 changed files with 13 additions and 1 deletions
|
|
@ -293,6 +293,14 @@ def mount_backup_shares(read_write=False):
|
||||||
|
|
||||||
def mount_network_share(server, read_write=False):
|
def mount_network_share(server, read_write=False):
|
||||||
"""Mount a network share defined by server."""
|
"""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:
|
if read_write:
|
||||||
username = server['RW-User']
|
username = server['RW-User']
|
||||||
password = server['RW-Pass']
|
password = server['RW-Pass']
|
||||||
|
|
@ -315,7 +323,11 @@ def mount_network_share(server, read_write=False):
|
||||||
run_program(cmd)
|
run_program(cmd)
|
||||||
|
|
||||||
# Set mount options
|
# 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('rw' if read_write else 'ro')
|
||||||
cmd_options.append('username={}'.format(username))
|
cmd_options.append('username={}'.format(username))
|
||||||
if password:
|
if password:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue