Bug #35814
closedsave_to_file does not work as expected when a shell variable needs to be part of the saved file name
Description
The shell variable is escaped with a \
save_to_file is used in
kickstart_networking_setup
like this....
<%= save_to_file('/etc/sysconfig/network-scripts/ifcfg-$sanitized_real', ifcfg) %>
Where $sanitized_real is supposed to be a variable name that is evaluated on the target host (set in kickstart_ifcfg_generic_interface) as the properly escaped name of the discovered interface with the specified mac address.
The problem is that the code is rendered as:
cat << EOF-cd4e31fd > /etc/sysconfig/network-scripts/ifcfg-\$sanitized_real
The \ is added to the path by the code path somewhere. This ends up being evaluated to a literal and the file "ifcfg-$sanitzed_real" is written, which doesn't point to an actual interface.
Workaround:
Clone template and replace with something like
cat << EOF >/etc/sysconfig/network-scripts/ifcfg-$sanitized_real
<%= ifcfg %>
EOF
Updated by Ewoud Kohl van Wijngaarden about 2 years ago
Did you test this on 3.5.0-rc1? 3.5.0-rc2 should contain a fix for this.
Updated by Ewoud Kohl van Wijngaarden about 2 years ago
- Related to Bug #35530: save_to_file macro does not work if the thing being saved contains a heredoc terminated with EOF added
Updated by Ewoud Kohl van Wijngaarden about 2 years ago
- Is duplicate of Bug #35792: save_to_file function should not use shellescape on the filename added