Permission bits passed to open(2) are AND-ed with current process umask.
Set umask to 0 at the beginning of extractData() and restore it at the
end, to extract files with desired permissions no matter what's the
current process umask.
How does dpkg do it? It invokes tar binary to extract data.tar.gz, and
tar sets current process umask to 0 if it's running as root. (See
--no-same-permissions in tar(1)).
Also fix expected permissions of /tmp from 01775 to 01777.
Permission bits passed to open(2) are AND-ed with current process umask. Set umask to 0 at the beginning of extractData() and restore it at the end, to extract files with desired permissions no matter what's the current process umask.
How does dpkg do it? It invokes tar binary to extract data.tar.gz, and tar sets current process umask to 0 if it's running as root. (See --no-same-permissions in tar(1)).
Also fix expected permissions of /tmp from 01775 to 01777.