-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std::env::temp_dir
should return env var XDG_RUNTIME_DIR under Linux if declared
#39081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
std::env::temp_dir
should return env var XDG_RUNTIME_DIR under Linux if it existsstd::env::temp_dir
should return env var XDG_RUNTIME_DIR under Linux if declared
In theory, I'm all with you (however, IMO, it should be
The Also, FYI, issues like this usually go in the RFC repo (https://github.com/rust-lang/rfcs/issues). |
Also, note that XDG is only for the GNU/Linux desktop, and not for the server. |
@Stebalien: I do think issue 1 and 2 are actually a single issue. As you point out, the programmer (‘user’) may expect the behavior as documented now. This behavior would indeed change, but only superficially, since the new behavior may very well match old behavior. That is the case when a user chooses to apply the current best solution you proposed*. To rephrase, in case the user sets up Perhaps there should be My thinking was that the original proposal isn't a language change but a bug fix/improvement to the standard library, so not an RFC candidate. Perhaps I'm mistaken, if so, can someone point to some rules regarding this I overlooked? |
@est31: Also note that I propose that |
One and two really are different issues. In 1, I'm referring to the fact that Rust, as a programming language, really shouldn't be dictating stuff like this. Changes like this should start at a distro level and go through some sort of standardization process like a Freedesktop spec. In 2, I'm referring to Rust's stability guarantees.
I disagree but that doesn't really matter. It's still a large breaking change by Rust's standards.
Currently, Rust is behaving correctly according to the POSIX spec (as far as I can tell). Also, I should have noted in my comment that I set the mode of my Really, at the end of the day, I think this issue is much bigger than Rust and should be solved by distros first. |
Its not. Rust reserves itself the right to introduce breakage where there is a bug, and ignoring distro standards I think counts as a bug. |
Do any other languages have an equivalent function that looks at |
On the standards
What other libraries of equal status do Considering all the evidence I just listed,
|
Just for accuracy, I didn't suggest that. Linux distros need to agree on a standard secure temporary file location but I don't think
|
You didn't state that, sorry. |
Triage: no change. |
Triage: no change rust/library/std/src/sys/unix/os.rs Line 556 in 45f638b
|
I agree that I do think there's an improvement to make here, though: the documentation for |
You make good points @joshtriplett , I retract what I said earlier. |
Reading back this thread, it seems that everyone came to the conclusion that temp_dir should not return XDG_RUNTIME_DIR, so I'm closing this issue. However, some other issues were brought up: 1: We're using TMPDIR without a check:
2: A problem with temporary files in a shared folder:
3: A documentation issue:
Issue 1 requires a separate discussion about what the right behaviour would be. @sanmai-NL: Feel free to open a new issue or PR for this, to start that discussion. Issue 2 is a general problem with temp folders, and Issue 3 is already addressed by #81219. |
Currently, Rust programs under Unix will use
$TMPDIR
as root temporary directory. This normally means/tmp/
.This is not optimally secure with most modern Linux distros.
$TMPDIR
is not guaranteed to be private.Instead, I propose using the value of
$XDG_RUNTIME_DIR
first, since that is most likely set.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: