summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys/getlogin.2
diff options
context:
space:
mode:
authorwes <wes@FreeBSD.org>1999-11-28 22:41:50 +0000
committerwes <wes@FreeBSD.org>1999-11-28 22:41:50 +0000
commit7cf3e9fa26c2aa7049ece490c34b16ab439eb40c (patch)
tree20c99cbbd2a5da22a1914809fe4e2942c92838dc /lib/libc/sys/getlogin.2
parent6ed770d48894580ab774368b42e9851442d48788 (diff)
downloadFreeBSD-src-7cf3e9fa26c2aa7049ece490c34b16ab439eb40c.zip
FreeBSD-src-7cf3e9fa26c2aa7049ece490c34b16ab439eb40c.tar.gz
Document the getlogin_r function.
Diffstat (limited to 'lib/libc/sys/getlogin.2')
-rw-r--r--lib/libc/sys/getlogin.224
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/libc/sys/getlogin.2 b/lib/libc/sys/getlogin.2
index bb82a70..122431d5 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 <unistd.h>
.Ft char *
.Fn getlogin void
+.Fd #include <sys/param.h>
+.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
OpenPOWER on IntegriCloud