Reputation: 21
when a python file is compiled in linux machine the following warning is seen but the same file compiled in Solaris machine, warning is not seen
/opt/swe/tools/ext/gnu/python-2.3.5_p1/i686-linux2.4/lib/python2.3/config/libpython2.3.a(posixmodule.o)(.text+0x3e9a): In function `posix_tmpnam':
./Modules/posixmodule.c:6138: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/opt/swe/tools/ext/gnu/python-2.3.5_p1/i686-linux2.4/lib/python2.3/config/libpython2.3.a(posixmodule.o)(.text+0x3de9): In function `posix_tempnam':
./Modules/posixmodule.c:6093: warning: the use of `tempnam' is dangerous, better use `mkstemp'
Not able to resolve the above warning snippet
can any one help
Upvotes: 2
Views: 2135
Reputation: 41
You get the same warning with libpython2.6.a so the suggestions to upgrade are unhelpful. Only upgrading to Python 3 gets rid of the warnings (see Python bug 1318) but that's not an option for some people.
One way to avoid the warning is to link to a library providing definitions of tmpnam_r and tempnam so that the uses of it in libpython2.6.a resolve to your definitions, not the real ones in glibc. The definitions in glicb trigger the warnings because there are .gnu.warning.tmpnam_r and .gnu.warning.tempnam sections in libc.so
If you don't actually use os.tempnam() and os.tmpnam() you can ignore the warnings.
Upvotes: 1
Reputation: 23950
You are using an older version of python.
Since then it became clear that the tmpnam function is not safe, and the libraries / headers shipping with linux have been updated to give you a warning. But it should compile, as backwards compatibility is pretty important.
Python 2.3 was developed in a time it was not yet clear that mktemp was a security issue, and mkstemp probably wasn't available.
Solaris might not have that problem because either tmpnam isn't insecure on that platform, or your solaris is a bit older.
If you want to get rid of the warning you have different possibilities:
I'd go with upgrading if possible, and live with it otherwise.
Upvotes: 4