Skip to content

Unset TMPDIR before calling tempnam in tempname #35342

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

Closed

Conversation

ivan-timokhin
Copy link

tempnam consults the TMPDIR environment variable before its argument (see man page), so if it is set the function will suddenly and quietly ignore the parent argument.

tempnam consults the TMPDIR environment variable before its argument,
so if it is set the function will suddenly and quietly ignore the
`parent` argument.
@KristofferC
Copy link
Member

Ref #34726

@ivan-timokhin
Copy link
Author

Ref #34726

Ugh. Fair enough. The problem is that the current conclusion for this case (C function depending on the environment) in the linked thread is "don't do that, use the library's configuration API", and the whole issue here is that tmpnam consults TMPDIR before its explicit parameters. So I'm not sure what would a better fix look like (aside from not using tmpnam at all—#22949).

If this approach is deemed unacceptable, I have no objections to closing this PR; I'll open an issue instead.

@ivan-timokhin
Copy link
Author

I have thought about this some more, and convinced myself this is not going to work—as written, tempname would break any concurrent calls to tempdir, which is probably worse than the original problem. Mea culpa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants