This change is wrong. Specifically, the way you made the chown()
"non-fatal" defeats this bit of code:
/*
* IMPORTANT SECURITY NOTE:
* if not preserving mode or we cannot set uid/gid, then PROHIBIT
* set uid/gid bits
*/
You must fix it so this works properly again.