Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

/tmp/hypr is only accessible by one user

Open ManEnfu opened this issue 3 years ago • 5 comments
trafficstars

So I have two user on my system, let's say user1 and user2. I usually run Hyprland with user1, and recently I wanted to experiment with Hyprland with user2, which I use for gaming. I logged in into Hyprland as user2 and run hyprctl clients or whatever, and receives this error

Couldn't connect to /tmp/hypr/_1662993714/.socket.sock. (3)

Basically, the socket file didn't exist. Or rather, the directory that's supposed to contain the socket file didn't exist. no socket, no log file, nothing.

$ ls /tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE
ls: cannot access '/tmp/hypr/_1662993714/.socket.sock': No such file or directory

The symptom is similar to #642 , but most likely it was from another cause so I'm opening a new issue.

After investigating for a bit, I found out that /tmp/hypr is owned by user1, and user2 could not write into the folder, thus explaining why the socket in user2's session didn't exist.

Apparently Hyprland creates /tmp/hypr directory on behalf of user1 (which is the first to run Hyprland and own /tmp/hypr) and just assume that everyone can write to tmp/hypr`.

I can think of several solutions:

  • Append user identifier to /tmp/hypr directory name, such as /tmp/hypr-user1 or something. This way each user have their own directory that they can write into. One caveat is this will break compatibility with practically every script that connect to Hyprland socket.
  • Make /tmp/hypr writable by everyone. I don't think this is the best solution, security wise.

ManEnfu avatar Sep 12 '22 16:09 ManEnfu

It would be nice to move it to $XDG_RUNTIME_DIR instead

viperML avatar Sep 12 '22 16:09 viperML

no, because /tmp lives in the ram and is therefore much faster.

vaxerski avatar Sep 12 '22 16:09 vaxerski

$ findmnt $XDG_RUNTIME_DIR
TARGET         SOURCE FSTYPE OPTIONS
/run/user/1000 tmpfs  tmpfs  rw,nosuid,nodev,relatime,size=3269616k,nr_inodes=817404,mode=700,uid=1000,gid=100

viperML avatar Sep 12 '22 16:09 viperML

oh that changes things. At any rate, the issue of backwards compat is still there.

vaxerski avatar Sep 12 '22 16:09 vaxerski

Regarding backwards compatibility, I think a check can be performed on ownership of /tmp/hypr and if the current user owns it, create /tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE as symlink to the new location. Of course this is a temporary measure, and eventually /tmp/hypr should be deprecated.

ManEnfu avatar Sep 14 '22 14:09 ManEnfu

the problem with moving to /run/user/1000 is that you cannot symlink /tmp <-> /run/user/

vaxerski avatar Dec 21 '22 15:12 vaxerski

this issue should be solved in 96cb47fc64438c93e7663afa832a567120f82128

/tmp/hypr is now 777 and individual directories are 770

vaxerski avatar Dec 21 '22 15:12 vaxerski

Ran into the same issue apparently. Had hyprland installed for a while, but only now tried to start it on a new user. Version 0.21.0 (from AUR) Tried to start it with a wrapper script, hyprland tried to create directory in /tmp/hypr and crashed with Permission denied.

Had to do sudo chmod 777 /tmp/hypr - after that everything worked fine.

MilkyAomiki avatar Feb 20 '23 11:02 MilkyAomiki

it should do that on its own, and it does for me: image

make sure you don't manually create the directory.

vaxerski avatar Feb 20 '23 14:02 vaxerski