isCurrentUser

Check whether username matches the current effective user.

Compares the uid of the named user against the process's effective UID, so it works correctly in setuid scenarios.

version(Posix)
@trusted
bool
isCurrentUser
(
in string username
)

Parameters

username string

login name to compare against

Return Value

Type: bool

true if the user exists and their uid equals geteuid().

Examples

import unit_threaded.assertions;

isCurrentUser(getCurrentUser().name).shouldBeTrue;
isCurrentUser("this_user_definitely_does_not_exist_xyzzy").shouldBeFalse;

Meta