From 5377a1a85ed917adbe4431ca3abed49d79cb50b7 Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Sat, 18 Sep 2021 11:06:54 -0400 Subject: [PATCH] Recover from situation where roles file is corrupted --- salt/common/tools/sbin/so-user | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/common/tools/sbin/so-user b/salt/common/tools/sbin/so-user index 5fc1db66a..180092333 100755 --- a/salt/common/tools/sbin/so-user +++ b/salt/common/tools/sbin/so-user @@ -158,7 +158,7 @@ function createFile() { } function ensureRoleFileExists() { - if [ ! -s "$socRolesFile" ]; then + if [[ ! -f "$socRolesFile" || ! -s "$socRolesFile" ]]; then if [[ -f "$databasePath" ]]; then echo "Migrating roles to new file: $socRolesFile" @@ -170,6 +170,7 @@ function ensureRoleFileExists() { >> "$rolesTmpFile" [[ $? != 0 ]] && fail "Unable to read identities from database" + rm -fr "$socRolesFile" mv "${rolesTmpFile}" "${socRolesFile}" else echo "Database file does not exist yet, installation is likely not yet complete."