Make sure password files from lookups are created with restrictive permissions

Also adds checks for the lookup integration test for passwords.

Fixes #8652