notify-updates: ignore chown error

If running as normal user, chown will fail. This isn't a problem,
because the file is probably already owned by the correct user. The
whole point about this chown is to give access to the file for normal
user, so if the write succeeded, it isn't needed.
This commit is contained in:
Marek Marczykowski-Górecki 2015-10-09 20:22:22 +02:00
parent 88b4a84cce
commit 063b436b03
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -61,7 +61,10 @@ def main():
update_f = open(source_vm.dir_path + '/' + vm_files["updates_stat_file"], "w")
update_f.write(update_count)
update_f.close()
os.chown(source_vm.dir_path + '/' + vm_files["updates_stat_file"], -1, qubes_gid)
try:
os.chown(source_vm.dir_path + '/' + vm_files["updates_stat_file"], -1, qubes_gid)
except OSError:
pass
elif source_vm.template is not None:
# Hint about updates availability in template
# If template is running - it will notify about updates itself
@ -79,7 +82,10 @@ def main():
update_f = open(stat_file, "w")
update_f.write(update_count)
update_f.close()
os.chown(stat_file, -1, qubes_gid)
try:
os.chown(stat_file, -1, qubes_gid)
except OSError:
pass
else:
print >> sys.stderr, 'Ignoring notification of no updates'