altdesktop / i3ipc-python

🐍 An improved Python library to control i3wm and sway.
http://i3ipc-python.readthedocs.io
BSD 3-Clause "New" or "Revised" License
851 stars 109 forks source link

examples/focus-last.py: handle multiple sessions and/or users safely #140

Closed cadadr closed 4 years ago

cadadr commented 4 years ago

Create the path to socket portably and such that when script is used with multiple sessions by the same user or various users each session gets its own socked which other users can not access.

This is achieved by using UID and DISPLAY in the path name, using the tempfile module from stdlib to get the path for /tmp, and creating the socket under a directory which was created with #o700 perms.

acrisci commented 4 years ago

:+1: