Code Monkey home page Code Monkey logo

Comments (3)

Flowdalic avatar Flowdalic commented on August 19, 2024 1

I run into the same issue when preparing atuin daemon support on Gentoo.

When this variable is available, Atuin should locate its daemon socket at $XDG_RUNTIME_DIR/atuin/atuin.sock by default.

Not only when this variable (XDG_RUNTIME_DIR) is available. Even in the absence of XDG_RUNTIME_DIR from the processes' environment, atuin should default to that. The "XDG Base Directory Specification" is states that

If $XDG_RUNTIME_DIR is not set applications should fall back to a replacement directory with similar capabilities and print a warning message. Applications should use this directory for communication and synchronization purposes and should not place larger files in it, since it might reside in runtime memory and cannot necessarily be swapped out to disk.

Source: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables

So atuin's default for socket_path should be, in bash variable default-value notation, ${XDG_RUNTIME_DIR:-/run/user/${UID}}/atuin.socket.

from atuin.

akinomyoga avatar akinomyoga commented on August 19, 2024 1

When it falls back to /run/user/$UID, one should check if that directory exists and has the correct owner and permission. Then, one can use that directory.

If the directory doesn't exist, one can next attempt to create a temporary directory in /tmp using mkdtemp(3), but special care would be needed to share the directory with the other calls of Atuin. Another possibility is to manually create a directory in /tmp, but it has pitfalls that may allow attackers to intercept, so one needs to be careful doing it.

Another thing to care is a known bug of WSL. In WSL systems, one should avoid using /run/user/... (even when XDG_RUNTIME_DIR specifies /run/usr/...). These problems started to happen around the last September, but I don't see any movements to solve the issue in WSL.

from atuin.

ellie avatar ellie commented on August 19, 2024 1

When it falls back to /run/user/$UID, one should check if that directory exists and has the correct owner and permission. Then, one can use that directory.

Due to this additional complication in following that part of the spec, my PR doesn't fallback to it. It's also not theoretical, as we checked Alpine and it does not have this path.

If the var exists, we use it, and if it doesn't, we don't. The var is automatically set by systemd, and points to a directory that has been correctly setup. Creating and managing such a dir is very out of scope for Atuin.

Afaik we have no way of detecting WSL, and if that becomes an issue users can specify a different directory. I'm afraid "just follow XDG" is never as easy as it sounds.

from atuin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.