From 54cb77f737e1d829a32c6e2aaa3ff20556d746bb Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Thu, 16 May 2019 15:35:25 -0600 Subject: [PATCH] Mount backup shares using tech's uid/gid * Allows read-write access without root/sudo --- .bin/Scripts/functions/data.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.bin/Scripts/functions/data.py b/.bin/Scripts/functions/data.py index 8173a634..c359ab6c 100644 --- a/.bin/Scripts/functions/data.py +++ b/.bin/Scripts/functions/data.py @@ -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: