This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.tempnam fails on SUSE Linux to accept directory argument
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: andyfloe, mkiever
Priority: normal Keywords:

Created on 2006-10-25 20:52 by andyfloe, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_os.py.patch andyfloe, 2006-10-25 20:52 patch for 'Lib/test/test_os.py' to test on the correct behavior of os.tempnam().
Messages (3)
msg30395 - (view) Author: Andreas (andyfloe) Date: 2006-10-25 20:52
On SUSE Linux 10.1 the function os.tempnam does not use
the "dir" argument properly. It always takes the
tmpdir, in this case "/tmp". In the example below it is
expected to get a filename of '/tmp/tmp/pref2iGGS5'
instead of '/tmp/pref2iGGS5'. 


auser@linux-m392:~> python
Python 2.5 (r25:51908, Oct 18 2006, 22:50:32)
[GCC 4.1.0 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import os
>>> os.mkdir("/tmp/tmp")
>>> os.tempnam("/tmp/tmp", "pref")
__main__:1: RuntimeWarning: tempnam is a potential
security risk to your program
'/tmp/pref2iGGS5'
>>>
auser@linux-m392:~> ls -l /tmp/tmp
total 0
auser@linux-m392:~> ls -ld /tmp/tmp
drwxr-xr-x 2 auser users 48 2006-10-17 20:13 /tmp/tmp

This behavior is also the same on the Python version
which comes with SUSE Linux 10.1. On Solaris 10 the
behavior is as expected, e.g.

-bash-3.00$ python
Python 2.4.3 (#1, Sep 16 2006, 10:31:38) [C] on sunos5
Type "help", "copyright", "credits" or "license" for
more information.
>>> import os
>>> os.mkdir("/tmp/tmp")
>>> os.tempnam("/tmp/tmp", "pref")
__main__:1: RuntimeWarning: tempnam is a potential
security risk to your program
'/tmp/tmp/prefAAAIeaafH'

A patch for the test 'test_os.py' is attached to this
report. It has been tested on SUSE Linux 10.1.

msg30396 - (view) Author: Matthias Kievernagel (mkiever) * Date: 2006-10-26 00:12
Logged In: YES 
user_id=1477880

This one once irritated me also.
In my case the cause was
the environment variable 'TMPDIR'.
This is the first location chosen
by os.tempnam (see 'man tempnam').
Please check again.

Matthias Kievernagel
mkiever at web dot de
msg30397 - (view) Author: Andreas (andyfloe) Date: 2006-10-26 16:55
Logged In: YES 
user_id=1292384

Your hint about the environment variable TMPDIR 
actually solves my problem. I have overlooked the 
information given in the documentation about this fact. 
Thanks.
History
Date User Action Args
2022-04-11 14:56:20adminsetgithub: 44168
2006-10-25 20:52:22andyfloecreate