Skip to content

Commit

Permalink
rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtapolasek committed Sep 9, 2020
1 parent 57554f1 commit e5f3f2b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 24 deletions.
14 changes: 0 additions & 14 deletions linux_os/guide/services/obsolete/tftp/tftpd_secure_directory.var

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# strategy = configure
# disruption = low

{{{ ansible_instantiate_variables("tftpd_secure_directory") }}}
{{{ ansible_instantiate_variables("var_tftpd_secure_directory") }}}

- name: "Find out if the file exists and contains the line configuring server arguments"
find:
Expand All @@ -17,15 +17,15 @@
lineinfile:
path: "/etc/xinetd.d/tftp"
regexp: '^[\s]*(server_args[\s]+=[\s]+.*?)(-s[\s]+[/\.\w]+)*(.*)$'
line: '\1 -s {{ tftpd_secure_directory }} \3'
line: '\1 -s {{ var_tftpd_secure_directory }} \3'
state: present
backrefs: true
when: tftpd_secure_config_line is defined and tftpd_secure_config_line.matched > 0

- name: "Insert correct config line to start TFTP server with secure directory"
lineinfile:
path: "/etc/xinetd.d/tftp"
line: "server_args = -s {{ tftpd_secure_directory }}"
line: "server_args = -s {{ var_tftpd_secure_directory }}"
state: present
create: true
when: tftpd_secure_config_line is defined and tftpd_secure_config_line.matched == 0
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

. /usr/share/scap-security-guide/remediation_functions

{{{ bash_instantiate_variables ("tftpd_secure_directory") }}}
{{{ bash_instantiate_variables ("var_tftpd_secure_directory") }}}

if grep -q 'server_args' /etc/xinetd.d/tftp; then
sed -i -E "s;^([[:blank:]]*server_args[[:blank:]]+=[[:blank:]]+.*?)(-s[[:blank:]]+[[:graph:]]+)*(.*)$;\1 -s $tftpd_secure_directory \3;" /etc/xinetd.d/tftp
sed -i -E "s;^([[:blank:]]*server_args[[:blank:]]+=[[:blank:]]+.*?)(-s[[:blank:]]+[[:graph:]]+)*(.*)$;\1 -s $var_tftpd_secure_directory \3;" /etc/xinetd.d/tftp
else
echo "server_args = -s $tftpd_secure_directory" >> /etc/xinetd.d/tftp
echo "server_args = -s $var_tftpd_secure_directory" >> /etc/xinetd.d/tftp
fi


Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

<ind:textfilecontent54_state id="state_tftpd_uses_secure_mode" version="1">
<ind:subexpression datatype="int" operation="equals" var_check="all"
var_ref="tftpd_secure_directory" />
var_ref="var_tftpd_secure_directory" />
</ind:textfilecontent54_state>

<external_variable comment="TFTP server secure directory" datatype="string" id="tftpd_secure_directory" version="1" />
<external_variable comment="TFTP server secure directory" datatype="string" id="var_tftpd_secure_directory" version="1" />
</def-group>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: |-
to change its root directory at startup. To do so, ensure
<tt>/etc/xinetd.d/tftp</tt> includes <tt>-s</tt> as a command line argument, as shown in
the following example:
<pre>server_args = -s {{{ sub_var_value("tftpd_secure_directory") }}}</pre>
<pre>server_args = -s {{{ sub_var_value("var_tftpd_secure_directory") }}}</pre>
rationale: |-
Using the <tt>-s</tt> option causes the TFTP service to only serve files from the
Expand Down Expand Up @@ -55,4 +55,4 @@ ocil: |-
The output should indicate the <tt>server_args</tt> variable is configured
with the <tt>-s</tt> flag, matching the example below:
<pre>$ grep "server_args" /etc/xinetd.d/tftp
server_args = -s {{{ sub_var_value("tftpd_secure_directory") }}}</pre>
server_args = -s {{{ sub_var_value("var_tftpd_secure_directory") }}}</pre>

0 comments on commit e5f3f2b

Please sign in to comment.