diff --git a/acls.yml b/acls.yml index a579f99e1b9a18ce2a533b227182a5568fcc2417..ab21fe4856d12dfdfeb61a35b5b10c64d1e4b43f 100644 --- a/acls.yml +++ b/acls.yml @@ -36,6 +36,14 @@ # owner: 'strube1' # base: True +# Multiple users can be set as owners using a list. For example: +#software: +# - name: 'TensorFlow' +# owner: ['strube1', 'goebbert1'] +# base: True +# +# This does not apply to already installed software, as the ACLs are not applied recursively! + base: - name: 'GCCcore' version: '11.2.0' diff --git a/bin/setacls b/bin/setacls index 0eae3ea7b39b7c3c12762c5daab184bc4699e0ac..585e253f0fa49005fec5d010e14a443d79a2396c 100755 --- a/bin/setacls +++ b/bin/setacls @@ -117,8 +117,18 @@ def process_acls(sw, path, opts): else: LOGGER.debug(f'{bcolors.WARNING}{path} does not exist and will not be created {bcolors.ENDC}') if os.path.isdir(path) and not reset: - cmd = ['setfacl', '-m', f'u:{sw["owner"]}:rwx', path] - run_cmd(cmd, dry_run, force) + if isinstance(sw["owner"], str): + cmd = ['setfacl', '-m', f'u:{sw["owner"]}:rwx', path] + run_cmd(cmd, dry_run, force) + elif isinstance(sw["owner"], list): + for owner in sw["owner"]: + cmd = ['setfacl', '-m', f'u:{owner}:rwx', path] + run_cmd(cmd, dry_run, force) + else: + e_str = f'ERROR: The owner of {sw["name"]} is neither a string nor a list. Please double check it.' + print(f'{bcolors.FAIL}{e_str}{bcolors.ENDC}') + LOGGER.debug(e_str) + sys.exit() def locks(l_config, opts): """Checks/sets the $STAGES/$STAGE/.locks directory access rights""" @@ -160,15 +170,19 @@ def sw_loop(l_config, opts): print(f'{bcolors.WARNING}The following commands will be executed:{bcolors.ENDC}') sw_path = os.path.join(opts.stage_path, 'software') + eb_repo_path = os.path.join(opts.stage_path, 'eb_repo') # Loop over software for sw in l_config['software']: LOGGER.debug(f'Processing {sw["name"]}...') - # Adjust SW installation directory if at least one of the 4 levels in the hierarchy is - # correctly configured. Assume that the owner of the package is the owner for all levels + # Adjust SW installation directory and eb_repo directory if at least one of the 4 levels + # in the hierarchy is correctly configured. Assume that the owner of the package is the + # owner for all levels if sw.get('system') or sw.get('base') or sw.get('compiler') or sw.get('mpi'): LOGGER.debug(f'Adjusting the software installation directory for {sw["name"]}') process_acls(sw, os.path.join(sw_path, sw['name']), opts) + LOGGER.debug(f'Adjusting the eb_repo directory for {sw["name"]}') + process_acls(sw, os.path.join(eb_repo_path, sw['name']), opts) # Adjust ACLs on SYSTEM toolchain if sw.get('system'): LOGGER.debug(f'{sw["name"]} is part of the system toolchain')