Check return value from chown()

gcc 4.8.1 is warning on unused result, and with -Werror causes the build
to fail.
Check return value from chdir()

gcc 4.8.1 is warning about an unused result, and with -Werror causees
the build to fail.