TT#76658 Use temp file to prepare ngcpcfg_perms file

Two parallel ngcpcfg processes corrupts this file as they try to write
into it simultaneously.

As a solution use temporary file to prepare the content of ngcpcfg_perms
file and then move it to /etc/ngcp-config/.ngcpcfg_perms.

Change-Id: I74baf3ac78a80d96a1b9dfba2be063b7128b1150
changes/38/38638/1
Mykola Malkov 6 years ago
parent 9a47a8adb4
commit 2344b9e59f

@ -99,13 +99,15 @@ generate_metadata() {
'
}
echo "# Generated by ngcpcfg. Do not edit." > .ngcpcfg_perms
echo >> .ngcpcfg_perms
ngcpcfg_perms=$(mktemp)
chown root:root "${ngcpcfg_perms}"
# Make sure the file is not readable by others, since it can leak
# information about contents of non-readable directories
chmod 700 .ngcpcfg_perms
chmod 700 "${ngcpcfg_perms}"
generate_metadata >> .ngcpcfg_perms
echo "# Generated by ngcpcfg. Do not edit." > "${ngcpcfg_perms}"
echo >> "${ngcpcfg_perms}"
generate_metadata >> "${ngcpcfg_perms}"
mv "${ngcpcfg_perms}" .ngcpcfg_perms
git add .ngcpcfg_perms

Loading…
Cancel
Save