Skip to content
BSD syscall#50

svc · unix #50

setlogin

Sets the login name of the current session.

Prototype

int setlogin(char *namebuf);

Returns: int

Arguments

NameTypeDirDescription
namebufchar-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard50
xnu-1486.2.11—50
xnu-1504.15.3—50
xnu-1504.3.12—50
xnu-1504.7.4—50
xnu-1504.9.17—50
xnu-1504.9.26—50
xnu-1504.9.37—50

Notes

Requires effective root and only affects the session of the calling process. Used by login(1) and sshd to record the authenticated user, which getlogin() then retrieves. Should be called once after setsid()/setpgid() and before dropping privileges.

Related APIs

getloginsetsidsetuidsetgidinitgroups