kata-manager: Fix symlink handling

The `configure_kata()` function modifies the configuration file to
enable debug. But it was doing this by calling `sed -i` which, by
default, creates a new _file_ from the `configuration.toml` symbolic
link. This defeated the point of the symbolic link which is supposed to
resolve to the local copy of the pristine config file, so we now use
the GNU sed(1) specific `---follow-symlinks` option to retain the
sym-link.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2024-02-07 15:30:07 +00:00
parent 455637b30a
commit 0bb558c0b9

View File

@ -736,7 +736,18 @@ configure_kata()
sudo install -o root -g root -m 0644 "$cfg_from" "$cfg_to"
# Note that '--follow-symlinks' is essential: without it,
# sed(1) will break the sym-link and convert it into a file,
# which is not desirable behaviour as the whole point of the
# "well known" config file name is that it is a sym-link to
# the actual config file.
#
# However, this option is GNU sed(1) specific so if this
# script is run on a non-Linux system, it may be necessary
# to install GNU sed, or find an equivalent option for the
# local version of sed.
sudo sed -i \
--follow-symlinks \
-e 's/^# *\(enable_debug\).*=.*$/\1 = true/g' \
-e 's/^kernel_params = "\(.*\)"/kernel_params = "\1 agent.log=debug"/g' \
"$cfg_to"