2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-07-31 18:19:40 +00:00

fix(xcatserver): keep the server-provided cfgloc before rewriting host=

The postscript rewrites host= in the freshly fetched /etc/xcat/cfgloc to point
at MASTER, discarding the database location the credentials came with. That is
the only record of it when the database does not live on the management node.

Keep it as cfgloc.orig; the existing chmod 600 /etc/xcat/cfgloc* covers it.

Recovered from the unmerged lenovobuild branch (10090a9d). The original also
replaced the atomic write with mv-then-sed, which leaves cfgloc truncated if
sed fails, so the write itself is left alone.

Co-authored-by: Jarrod Johnson <10814490+jjohnson42@users.noreply.github.com>
This commit is contained in:
Vinícius Ferrão
2026-07-25 16:53:26 -03:00
parent 3191b874a3
commit 415ed2cb76
+4
View File
@@ -169,6 +169,10 @@ if [ $? -ne 0 ]; then
# if not DB2
grep "DB2" /etc/xcat/cfgloc 2>&1 1> /dev/null
if [ $? -ne 0 ]; then
# keep the server-provided copy: rewriting host= to $MASTER discards the
# database location the credentials came with, which is the only record
# of it when the database does not live on the management node
cp -p /etc/xcat/cfgloc /etc/xcat/cfgloc.orig
sed s/host=[^\|]*/host=$MASTER/ /etc/xcat/cfgloc > /etc/xcat/cfgloc.new
mv /etc/xcat/cfgloc.new /etc/xcat/cfgloc
else # DB2 cfgloc has different format