File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ setup() {
101101 # # instance opens it but before that other instance locks it.
102102
103103 install --directory --mode=0700 --owner=root --group=root -- " ${root_xdg_runtime_dir} "
104- mkdir --parents -- " ${root_wayland_lock_dir} "
104+ install --directory --mode=0700 --owner=root --group=root -- " ${root_wayland_lock_dir} "
105105 touch -- " ${target_wayland_socket} "
106106 touch -- " ${target_wayland_read_lockfile} "
107107 touch -- " ${target_wayland_write_lockfile} "
@@ -127,12 +127,12 @@ teardown() {
127127
128128 if [ -n " ${read_lock_fd} " ]; then
129129 flock --unlock -- " ${read_lock_fd} " || true
130- fi
131- if [ -n " ${read_lock_fd} " ] ; then
132- if flock --nonblock --exclusive -- " ${read_lock_fd } " \
133- && flock --nonblock --exclusive -- " ${write_lock_fd} " \
134- && umount -- " ${target_wayland_socket} " ; then
135- safe-rm --force -- " ${target_wayland_socket} " || true
130+ if [ -n " ${write_lock_fd} " ] && [ -n " ${target_wayland_socket} " ] ; then
131+ if flock --nonblock --exclusive -- " ${read_lock_fd} " \
132+ && flock --nonblock --exclusive -- " ${write_lock_fd } " \
133+ && umount -- " ${target_wayland_socket} " ; then
134+ safe-rm --force -- " ${target_wayland_socket} " || true
135+ fi
136136 fi
137137 fi
138138
Original file line number Diff line number Diff line change @@ -77,8 +77,8 @@ setup() {
7777 # # opens it but before that other instance locks it.
7878
7979 install --directory --mode=0700 --owner=root --group=root -- " ${root_xdg_runtime_dir} "
80- mkdir --parents -- " ${root_x_lock_dir} "
81- # # $DISPLAY is unsafe to trust, as it may contain characters like `../`.
80+ install --directory --mode=0700 --owner=root --group=root -- " ${root_x_lock_dir} "
81+ # # $DISPLAY is unsafe to trust, as it may contain substrings like `../`.
8282 # # Hash it to get a stable ID we can use in the lockfile name.
8383 display_hash=" $( sha256sum <<< " ${DISPLAY}" | cut -d' ' -f1) "
8484 target_x_lockfile=" ${root_x_lock_dir} /${display_hash} .lock"
@@ -99,9 +99,11 @@ teardown() {
9999
100100 trap ' ' EXIT INT TERM
101101
102- flock --unlock -- " ${x_lock_fd} " || true
103- if flock --nonblock --exclusive -- " ${x_lock_fd} " ; then
104- sudo --user=" ${SUDO_USER} " -- xhost ' -si:localuser:root' > /dev/null
102+ if [ -n " ${x_lock_fd} " ]; then
103+ flock --unlock -- " ${x_lock_fd} " || true
104+ if flock --nonblock --exclusive -- " ${x_lock_fd} " ; then
105+ sudo --user=" ${SUDO_USER} " -- xhost ' -si:localuser:root' > /dev/null
106+ fi
105107 fi
106108
107109 exit " ${exit_code} "
You can’t perform that action at this time.
0 commit comments