Morantron / tmux-fingers

copy pasting in terminal with vimium/vimperator like hints.
MIT License
983 stars 45 forks source link

fix(Dirs): fix multi-user race #126 #127

Closed rudenkornk closed 1 month ago

rudenkornk commented 1 month ago

I am a total newbie in Crystal, but I did my best ¯\_(ツ)_/¯

126

Morantron commented 1 month ago

Thanks for the patch! Actually I have no idea how tmux behaves in a multiuser scenario, all the files there (except for the LOG one that you are fixing) are shared within a tmux server instance. Not sure if two different linux users can attach to the same tmux session or not 🤔.

If it's not possible then it's possible to just prefix with ROOT, which is unique per tmux server instance. Otherwise all other paths need to be scoped by user id.

rudenkornk commented 1 month ago

Nah, I am not trying for multiple users to attach to the same session, they use their own unique tmux sessions. The problem is not even in tmux. The problem is that the extension itself synchronizes on the same global files on the entire system: /tmp/fingers.log and /tmp/action-stderr. Two different users will try to use exactly same files with exactly same absolute paths and one of them will fail to do so, since ony the first user created the files will have correct access.

rudenkornk commented 1 month ago

I have simplified the patch, replaced USER_ID with tmux PID via the ROOT dir. Also removed TMP since it is unsafe to use it directly because of the problem above.

rudenkornk commented 1 month ago

@Morantron ping 😳👉👈

Morantron commented 1 month ago

Merging for the action-stderr fixes, I'm gonna use XDG folders which I think is the correct way to handle this (https://github.com/Morantron/tmux-fingers/tree/xdg-dirs)