martbean — 2010-05-28T10:06:55-04:00 — #1
A website of mine receives updates from the client in a zip file. I can open and process this fine but they are now insisting that the file is password protected, which is a bit of a problem. I can do something like the following:
echo shell_exec('unzip -P password file.zip');
but as the server is running IIS this throws up a permissions error. Apparently we need to "give the Internet Guest Account (a.k.a. IUSR_MachineName or simply IUSR) read and execute permission to the command shell program, cmd.exe."
So, two questions:
- Are there any third-party apps/plugins/etc that will allow me to unzip password protected files? (I'm running PHP5 on a Windows server)
- What are the security risks in giving read and execute permissions to cmd.exe?
Any help would be gratefully received!
martbean — 2010-06-02T10:50:16-04:00 — #2
OK, i'm sort of getting somewhere. By using proc_open I can run unzip without cmd.exe being involved but I get the following error:
error: cannot create C:/Home/.../www/zip/file.txt
Anyone got any ideas on that one? I'm thinking it might be a permissions issue on the folder maybe?
wwb_99 — 2010-06-02T13:58:46-04:00 — #3
I'd look for a library that you can access from PHP rather than piping it through the shell. I know .NET has some native compression stuff you could call from PHP via .NET interop, but there is probably something more PHP specific that would be easier to wire in.
martbean — 2010-06-04T05:29:55-04:00 — #4
Do you mean a zip library? If so I've found a few but none of them will process password-protected archives, hence the reason I've had to resort to using the shell. I'll have a look at the .net option though.