5 ms·
Would something based on __file__ be more preferred, then? If so, it could be argued the bug already existed and this patch simply uses the existing behaviour.
by lstamour 7y ago
Would something based on __file__ be more preferred, then?
If so, it could be argued the bug already existed and this patch simply uses the existing behaviour...
- mehrdadn 7y agoI don't think __file__ would be any different... it's not even an absolute path necessarily. That's why I said I don't think there's any secure way to do this in Python. You're right though, I didn't see the issue was still there. The home directory should also not be there either. I think I looked at this too hastily but now I'm confused too.
- user5994461 7y agoos.path.realpath(__file__) That will give you the absolute path of the current python script, dereferencing any symlink and the .. notation.
- mehrdadn 7y agoIt will also be insecure due to a race condition.