[issue3719] platform.py: _syscmd_file() can't handle target path with space or special shell character

2008-08-28 Thread jfdp

New submission from jfdp <[EMAIL PROTECTED]>:

If you install python in a location which has a space
or shell character in the path then platform.platform()
will generate an error and/or fail to get all platform
information.

For example

$ pwd
/disk0/tmp/foobar(2)/python2.4/bin
$ ./python
Python 2.4.4 (#8, Apr 11 2008, 11:42:39) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> print platform.platform()
sh: syntax error at line 1: `(' unexpected
SunOS-5.10-sun4u-sparc-32bit

Note the error from 'sh' was well as the fact that "ELF"
is missing from the platform string. If you are in a path
with a space then it silently fails to identify "ELF".

The problem is in platform.py: _syscmd_file(target,default='')
in particular this line:

f = os.popen('file %s 2> /dev/null' % target)

This should be:

f = os.popen('file "%s" 2> /dev/null' % target)

Note the double quotes to protect the path from the shell.

I've examined the 2.5, 2.6 and 3.0 source and they all
have this same problem.

--
components: Library (Lib)
messages: 72118
nosy: jfdp
severity: normal
status: open
title: platform.py: _syscmd_file() can't handle target path with space or 
special shell character
type: behavior
versions: Python 2.4

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3719>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3719] platform.py: _syscmd_file() can't handle target path with space or special shell character

2008-09-02 Thread jfdp

jfdp <[EMAIL PROTECTED]> added the comment:

To respond to a couple questions:

Adding the double quotes fixed the issue I had -- but I did very
limited testing.

The "-b" option is not support by 'file' on Solaris.

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3719>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com