Как установить разрешения для будущих файлов?

Используйте ассоциативный массив для хранения имен сертификатов для каждой роли и среды.

#! /bin/bash

unset -v envs
declare -A envs

while IFS='| ' read -r certname role env; do
    envs["$role.$env"]+="$certname"$'\n' 
done < /tmp/inventory.list

for e in "${!envs[@]}" ; do
    printf '%s\n' "[$e]" "${envs[$e]}"
done

Чтобы отсортировать разделы, вы можете распечатать ключи, отсортировать их, а затем прочитать их и вывести связанные значения:

for e in "${!envs[@]}" ; do
    printf '%s\n' "$e"
done | sort | while read -r e ; do
    printf '%s\n' "[$e]" "${envs[$e]}"
done
0
15.10.2018, 20:50
1 ответ

Несколько советов, которые помогут вам выбрать правильное направление:

  • ACL справочная страница в разделе говорится об ACL по умолчанию:

    The access ACL of a file object is initialized when the object is created with any of the creat(), mkdir(), mknod(), mkfifo(), or open() functions. If a default ACL is associated with a directory, the mode parameter to the functions creating file objects and the default ACL of the directory are used to determine the ACL of the new object:

    1. The new object inherits the default ACL of the containing directory as its access ACL.

    2. The access ACL entries corresponding to the file permission bits are modified so that they contain no permissions that are not contained in the permissions specified by the mode parameter.

  • Используя sticky bit для каталогов, вы можете изменить владельца/группу новых файлов, созданных в каталоге. Файлы, созданные в каталоге, будут иметь владельца/группу закрепленного каталога вместо группы по умолчанию. Подробнее см. вопрос :. Как работает sticky bit?

1
28.01.2020, 04:12

Теги

Похожие вопросы