[ python-Bugs-1584723 ] os.tempnam fails on SUSE Linux to accept directory argument

SourceForge.net noreply at sourceforge.net
Thu Oct 26 18:55:47 CEST 2006


Bugs item #1584723, was opened at 2006-10-25 22:52
Message generated for change (Comment added) made by andyfloe
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1584723&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Andreas (andyfloe)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.tempnam fails on SUSE Linux to accept directory argument

Initial Comment:
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 at 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 at linux-m392:~> ls -l /tmp/tmp
total 0
auser at 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.



----------------------------------------------------------------------

>Comment By: Andreas (andyfloe)
Date: 2006-10-26 18:55

Message:
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.

----------------------------------------------------------------------

Comment By: Matthias Kievernagel (mkiever)
Date: 2006-10-26 02:12

Message:
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


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1584723&group_id=5470


More information about the Python-bugs-list mailing list