Project

General

Profile

Actions

Bug #35814

closed

save_to_file does not work as expected when a shell variable needs to be part of the saved file name

Added by Paul Armstrong over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

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


Related issues 2 (0 open2 closed)

Related to Foreman - Bug #35530: save_to_file macro does not work if the thing being saved contains a heredoc terminated with EOFClosedAdam RuzickaActions
Is duplicate of Foreman - Bug #35792: save_to_file function should not use shellescape on the filenameClosedSayan DasActions
Actions #1

Updated by Ewoud Kohl van Wijngaarden over 1 year ago

Did you test this on 3.5.0-rc1? 3.5.0-rc2 should contain a fix for this.

Actions #2

Updated by Ewoud Kohl van Wijngaarden over 1 year ago

  • Related to Bug #35530: save_to_file macro does not work if the thing being saved contains a heredoc terminated with EOF added
Actions #3

Updated by Ewoud Kohl van Wijngaarden over 1 year ago

  • Is duplicate of Bug #35792: save_to_file function should not use shellescape on the filename added
Actions #4

Updated by Leos Stejskal over 1 year ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF