Move cap_enter() closer to the start of the main()

Implement dh_checklocal() returning uid_t of a specified user, or
-1 on error. -1 may be a bad choise for error indication, but it
works for PoC code.