Allow specifying umask for cmd.

Please note that I haven't tested this yet, but the changes are simple enough that they Should Work. This will solve #3948.