Skip to content

Commit 7a882e2

Browse files
committed
fix: correctly modify PATH in install-proxy-rhcos.sh
The installer script wants to update the PATH variable to include $BIN_PATH in blobfuse-proxs's systemd unit by setting: Environment="PATH=<BIN_PATH>:$PATH" BIN_PATH is evaluated in the installer script, and $PATH is escaped, to be evaluated when the service unit runs. However, environment variables like "$PATH" are NOT evaluated by systemd in Environment="...". Quoting the documentation: " Variable expansion is not performed inside the strings and the "$" character has no special meaning. " https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#Environment This effectively removes all other paths and sets PATH to ONLY <BIN_PATH>. The resulting environment variable PATH contains the actual contents of BIN_PATH and a literal '$PATH'. This commit fixes that by wrapping ExecStart in bash -c '...' and updating PATH there.
1 parent bfcc417 commit 7a882e2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/blobfuse-proxy/install-proxy-rhcos.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ if [ "${INSTALL_BLOBFUSE_PROXY}" = "true" ];then
9393
echo "change from /usr/bin/blobfuse-proxy to ${BIN_PATH}/blobfuse-proxy in blobfuse-proxy.service"
9494
sed -i "s|/usr/bin/blobfuse-proxy|${BIN_PATH}/blobfuse-proxy|g" /blobfuse-proxy/blobfuse-proxy.service
9595
if [ "${BIN_PATH}" != "/usr/local/bin" ]; then
96-
echo "add Environment=\"PATH=${BIN_PATH}:$PATH\" in blobfuse-proxy.service"
97-
sed -i "/Delegate=yes/a Environment=\"PATH=${BIN_PATH}:\$PATH\"" /blobfuse-proxy/blobfuse-proxy.service
96+
echo "add \"PATH=${BIN_PATH}:\$PATH\" in blobfuse-proxy.service ExecStart."
97+
sed "s,^ExecStart[[:space:]]*=\\(.*\\)\$,ExecStart=/usr/bin/bash -c \"PATH=${BIN_PATH}:\$PATH \\1\"," \
98+
/blobfuse-proxy/blobfuse-proxy.service
9899
fi
99100
if [ -f "/host/etc/systemd/system/blobfuse-proxy.service" ];then
100101
old=$(sha256sum /host/etc/systemd/system/blobfuse-proxy.service | awk '{print $1}')

0 commit comments

Comments
 (0)