dirname(3) can modify content.
Fix symlink during fetch.
Stop using of mkstemp for regular files.
Umask is meaningless for mkstemp.
Fixes.
Fix fetching for reinstalled packages.

Reported by:	az