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.1150
xnu-1504.15.350
xnu-1504.3.1250
xnu-1504.7.450
xnu-1504.9.1750
xnu-1504.9.2650
xnu-1504.9.3750

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