Set file permissions, and added code for root perms check