Implement Metze's suggestion of trying getpwuid(0) then getpwnam(root).