|Title||Replicator fails when paths and arguments contain spaces|
|Assigned user||Gareth Rees|
|Description||We noticed the replicator failing when "p4gdr.exe" was under "Program Files" (which has a space) because it didn't quote the command line.|
When we started the replicator, it reported "p4 info didn't report a recognisable version". On investigation, it turned out that the 'p4-client-executable' had a space in it and so Python couldn't run the program. Even when we tried putting quotes around the executable name in the command string it didn't work. In no case did win32pipe.popen return an error.
|Analysis||The run command in the p4 module needs to quote the Perforce client executable. This would be straightforward if it weren't for the unfathomable behaviour of the command interpreter (CMD.EXE) on Windows NT. I discovered that the call os.popen('"command" arg') works but the call os.popen('"command" "arg"') fails. I have no idea why this is.|
So the solution seems to be: quote the command if it has spaces in it, but don't quote the arguments. However, there is still the possibility of problems if Perforce user names or jobnames contain shell meta-characters (this is more of a problem on Unix than on Windows). I created job000099 for this problem.
|Created by||Richard Brooksby|
|Created on||2000-11-21 16:20:08|
|Last modified by||Gareth Rees|
|Last modified on||2001-12-10 19:01:31|
|History||2000-11-21 RB Created from sources (see evidence).|
2000-11-22 RB Added more evidence from Perforce alpha test.
2000-11-29 GDR Added more analysis.
2000-11-30 GDR Added more analysis. Created job000099. Fixed this job.
|5165||closed||2000-11-30 13:16:29||Gareth Rees||In the p4 module, quote the Perforce command only if it has spaces. Pass other arguments only if they are non-empty. Don't quote any other arguments. This is all so that it works under Windows NT if the Perforce command contains spaces. (It seems that the CMD.EXE shell can't cope with a quoted command and any quoted arguments.) There should be no problem on Unix.|
|5131||open||2000-11-29 19:21:01||Gareth Rees||Fixed some inconsistencies in the arguemnts to add_fix, translate_fix and replicate_changelist. They should all be in alphabetical order now.
Fixed some bugs in replicator.py (not calling the right functions when replicating fixes).
Fixed Perforce commands involving jobs so that they quote the jobname. This means that the commands will mostly work if a job has a shell meta-character in its name. This is not a perfect solution, though: simply quoting the argument isn't a reliable way to avoid problems: carefully contrived sets of shell meta-characters can still sneak through. This means that the replicator provides a security loophole. Maybe I should check jobnames for acceptable sets of characters?