diff --git a/lib/libc/sys/getlogin.2 b/lib/libc/sys/getlogin.2 index bb82a7052f47..122431d5b6b0 100644 --- a/lib/libc/sys/getlogin.2 +++ b/lib/libc/sys/getlogin.2 @@ -37,12 +37,16 @@ .Os BSD 4.4 .Sh NAME .Nm getlogin , +.Nm getlogin_r , .Nm setlogin .Nd get/set login name .Sh SYNOPSIS .Fd #include .Ft char * .Fn getlogin void +.Fd #include +.Ft char * +.Fn getlogin_r "char *name" "int len" .Ft int .Fn setlogin "const char *name" .Sh DESCRIPTION @@ -60,6 +64,18 @@ for example when .Xr su 1 is used). .Pp +.Fn getlogin_r +provides the same service as +.Fn getlogin +except the caller must provide the buffer +.Fa name +with length +.Fa len +bytes +to hold the result. The buffer should be at least +.Dv MAXLOGNAME +bytes in length. +.Pp .Fn Setlogin sets the login name of the user associated with the current session to .Fa name . @@ -115,8 +131,12 @@ precautions to prevent security violations. If a call to .Fn getlogin succeeds, it returns a pointer to a null-terminated string in a static buffer. -If the name has not been set, it returns -.Dv NULL . +.Fn getlogin_r +returns a pointer to the buffer passed in by the caller on success. +Both return +.Dv NULL +if the name has not been set. +.Pp If a call to .Fn setlogin succeeds, a value of 0 is returned. If