File: bash.template

package info (click to toggle)
scap-security-guide 0.1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 110,644 kB
  • sloc: xml: 241,883; sh: 73,777; python: 32,527; makefile: 27
file content (50 lines) | stat: -rw-r--r-- 1,521 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# platform = multi_platform_all
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low

declare -a VALUES=()
declare -a VALUE_NAMES=()
declare -a ARGS=()
declare -a NEW_ARGS=()
declare -a DEL_ARGS=()

{{% for arg in ARGUMENTS -%}}
{{% if arg['variable'] | length -%}}
{{{ bash_instantiate_variables("var_password_pam_" + arg['variable']) }}}
VALUES+=("${{{ "var_password_pam_" + arg['variable'] }}}")
VALUE_NAMES+=("{{{ arg['variable'] }}}")
{{%- else %}}
VALUES+=("")
VALUE_NAMES+=("")
{{%- endif %}}
{{% if arg['argument'] | length -%}}
ARGS+=("{{{ arg['argument'] }}}")
{{%- else -%}}
ARGS+=("")
{{%- endif %}}
{{% if arg['new_argument'] | length -%}}
NEW_ARGS+=("{{{ arg['new_argument'] }}}")
{{%- else -%}}
NEW_ARGS+=("")
{{%- endif %}}
{{% if arg['remove_argument'] | length -%}}
DEL_ARGS+=("{{{ arg['remove_argument'] }}}")
{{%- endif %}}
{{%- endfor %}}

for idx in "${!VALUES[@]}"
do
    {{{ bash_provide_pam_module_options(PATH, TYPE, CONTROL_FLAG, MODULE, "${VALUE_NAMES[$idx]}", "${VALUES[$idx]}", "${VALUES[$idx]}") | indent(4) }}}
done

for idx in "${!ARGS[@]}"
do
    if ! grep -q -P "^\s*{{{ TYPE }}}\s+{{{ CONTROL_FLAG }}}\s+{{{ MODULE }}}.*\s+${ARGS[$idx]}\s*$" {{{ PATH }}} ; then
        sed --follow-symlinks -i -E -e "s/^\\s*{{{ TYPE }}}\\s+{{{ CONTROL_FLAG }}}\\s+{{{ MODULE }}}.*\$/& ${NEW_ARGS[$idx]}/" {{{ PATH }}}
        if [ -n "${DEL_ARGS[$idx]}" ]; then
            sed --follow-symlinks -i -E -e "s/\s+${DEL_ARGS[$idx]}\S+\s+/ /g" {{{ PATH }}}
        fi
    fi
done