qfile-daemon-dvm: lock around possible savefile recreate

This commit is contained in:
Rafal Wojtczuk 2011-03-28 17:39:21 +02:00
parent df9549a7db
commit 50af4bd8a0

View File

@ -23,6 +23,7 @@ import os
import dbus import dbus
import subprocess import subprocess
import sys import sys
import fcntl
from qubes.qubes import QubesVmCollection from qubes.qubes import QubesVmCollection
from qubes.qubes import QubesException from qubes.qubes import QubesException
@ -123,7 +124,10 @@ def main():
global notify_object global notify_object
notify_object = dbus.SessionBus().get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") notify_object = dbus.SessionBus().get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
qfile = QfileDaemonDvm(os.getenv("QREXEC_REMOTE_DOMAIN")) qfile = QfileDaemonDvm(os.getenv("QREXEC_REMOTE_DOMAIN"))
lockf = open("/var/run/qubes/qfile-daemon-dvm.lock", 'a')
fcntl.flock(lockf, fcntl.LOCK_EX)
dispname = qfile.get_dvm() dispname = qfile.get_dvm()
lockf.close()
if dispname is not None: if dispname is not None:
subprocess.call(['/usr/lib/qubes/qrexec_client', '-d', dispname, 'directly:user:/usr/lib/qubes/dvm_file_editor']) subprocess.call(['/usr/lib/qubes/qrexec_client', '-d', dispname, 'directly:user:/usr/lib/qubes/dvm_file_editor'])
subprocess.call(['/usr/sbin/xm', 'destroy', dispname]) subprocess.call(['/usr/sbin/xm', 'destroy', dispname])