mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
samba: recursively set open share directory permissions
Signed-off-by: Veiko Aasa <veiko17@disroot.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
1df21bc090
commit
e1f9dfacaa
@ -114,10 +114,7 @@ def _create_share(mount_point, windows_filesystem=False):
|
||||
|
||||
# FAT and NTFS partitions don't support setting permissions
|
||||
if not windows_filesystem:
|
||||
shutil.chown(open_share_path, group='freedombox-share')
|
||||
os.chmod(open_share_path, 0o2775)
|
||||
subprocess.check_call(['setfacl', '-Rm', 'g::rwx', open_share_path])
|
||||
subprocess.check_call(['setfacl', '-Rdm', 'g::rwx', open_share_path])
|
||||
_set_open_share_permissions(open_share_path)
|
||||
|
||||
share_name = _create_share_name(mount_point)
|
||||
_define_open_share(share_name, open_share_path, windows_filesystem)
|
||||
@ -193,6 +190,23 @@ def _make_mounts_readable_by_others(mount_point):
|
||||
os.chmod(dirname, stats.st_mode | stat.S_IROTH | stat.S_IXOTH)
|
||||
|
||||
|
||||
def _set_open_share_permissions(directory):
|
||||
"""Set file and directory permissions for open share."""
|
||||
shutil.chown(directory, group='freedombox-share')
|
||||
os.chmod(directory, 0o2775)
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for subdir in dirs:
|
||||
subdir_path = os.path.join(root, subdir)
|
||||
shutil.chown(subdir_path, group='freedombox-share')
|
||||
os.chmod(subdir_path, 0o2775)
|
||||
for file in files:
|
||||
file_path = os.path.join(root, file)
|
||||
shutil.chown(file_path, group='freedombox-share')
|
||||
os.chmod(file_path, 0o0664)
|
||||
subprocess.check_call(['setfacl', '-Rm', 'g::rwX', directory])
|
||||
subprocess.check_call(['setfacl', '-Rdm', 'g::rwX', directory])
|
||||
|
||||
|
||||
def _use_config_file(conf_file):
|
||||
"""Set samba configuration file location."""
|
||||
aug = augeas.Augeas(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user