Therefore, you either need to temporarily give apache write access to code files (which you can't do from within a web app running in apache, obviously) or run the upgrade as a user that already has write access to them.
Are we sure that you can't change the owner of the current process through Apache? We can execute arbitrary shell commands, if needed. The ideal solution could then be a script that can be invoked both from the web and from the command-line. Through the browser, it would ask for your local username/password, and then perform the upgrade tasks (only from a very limited set of commands, e.g. unpacking module files and copying them into the right dir). From the command-line, it would just assume the current user is the right one already. Steven Wittens