wayland-server: fix socket ownership race condition
authorDylan Noblesmith <nobled@dreamwidth.org>
Sat, 30 Jun 2012 19:50:09 +0000 (19:50 +0000)
committerDylan Noblesmith <nobled@dreamwidth.org>
Sat, 30 Jun 2012 19:50:09 +0000 (19:50 +0000)
commit30ff420ca9707fbbde7e70e789a8698058b4cb4b
treea16f766cd720018c04b156db853f06db233a1c84
parent94752574592a59c74340816063ad12a18433a75d
wayland-server: fix socket ownership race condition

Always unlink() the lock file before closing the file
descriptor for it. Otherwise, there is a race like this:

Process A closes fd, releasing the lock
Process B opens the same file, taking the lock
Process A unlinks the lock file
Process C opens the same file, which now no longer exists,
and takes the lock on the newly created lock file

Process B and C both 'own' the same display socket.

unlink()ing while holding the lock is effectively a better
way to release the lock atomically.
src/wayland-server.c