Fix race in svc-map

The construction of the combined svc-map-services file uses the host's
/tmp directory to store a work-in-progress file. That file's left behind
after it's done with.

There's a potential race here; together with problems that may arise
if two users attempt to run devtest on the same system.

This patch fixes this by creating the temporary file specifically under
$TMP_MOUNT_PATH.

Change-Id: Iecbdc583e37bed542249c316919c3712c28c7440
This commit is contained in:
Jan Grant 2014-12-04 13:34:17 +00:00 committed by Clint Byrum
parent f1c90ae72a
commit e88be20f1d
2 changed files with 4 additions and 2 deletions

View File

@ -81,7 +81,9 @@ def main():
" service name." % (err, element))
sys.exit(1)
write_data_to_file(service_names, os.path.join("/tmp", 'svc-map-services'))
write_data_to_file(
service_names,
os.path.join(os.environ['TMP_MOUNT_PATH'], 'tmp', 'svc-map-services'))
if __name__ == "__main__":

View File

@ -2,4 +2,4 @@
set -eux
set -o pipefail
sudo install -D -o root -g root -m 0644 /tmp/svc-map-services "$TMP_MOUNT_PATH/usr/share/svc-map/services"
sudo install -D -o root -g root -m 0644 "$TMP_MOUNT_PATH/tmp/svc-map-services" "$TMP_MOUNT_PATH/usr/share/svc-map/services"