summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2002-12-02 15:54:14 +0000
committermillert <millert@openbsd.org>2002-12-02 15:54:14 +0000
commit9a9784cccb0dfe13c6409f1c25dbcb9abec8c360 (patch)
tree41652364a1cbe258efd588af6a68c1c92114ab46
parentAdd ecvt(), fcvt() and gcvt() for standard compliance and legacy code. (diff)
downloadwireguard-openbsd-9a9784cccb0dfe13c6409f1c25dbcb9abec8c360.tar.xz
wireguard-openbsd-9a9784cccb0dfe13c6409f1c25dbcb9abec8c360.zip
Document getlogin_r()
-rw-r--r--lib/libc/sys/Makefile.inc4
-rw-r--r--lib/libc/sys/getlogin.228
2 files changed, 29 insertions, 3 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 26ac85b48ff..195534ecdb2 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.62 2002/12/02 09:00:14 miod Exp $
+# $OpenBSD: Makefile.inc,v 1.63 2002/12/02 15:54:14 millert Exp $
# $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $
# @(#)Makefile.inc 8.1 (Berkeley) 6/17/93
@@ -257,7 +257,7 @@ MLINKS+=getitimer.2 timerclear.3
MLINKS+=getitimer.2 timercmp.3
MLINKS+=getitimer.2 timerisset.3
MLINKS+=getitimer.2 timersub.3
-MLINKS+=getlogin.2 setlogin.2
+MLINKS+=getlogin.2 getlogin_r.2 getlogin.2 setlogin.2
MLINKS+=getpgrp.2 getpgid.2
MLINKS+=getpid.2 getppid.2
MLINKS+=getpriority.2 setpriority.2
diff --git a/lib/libc/sys/getlogin.2 b/lib/libc/sys/getlogin.2
index 40281ba537f..94d53218410 100644
--- a/lib/libc/sys/getlogin.2
+++ b/lib/libc/sys/getlogin.2
@@ -1,4 +1,4 @@
-.\" $OpenBSD: getlogin.2,v 1.13 2002/04/30 16:31:42 mpech Exp $
+.\" $OpenBSD: getlogin.2,v 1.14 2002/12/02 15:54:14 millert Exp $
.\" $NetBSD: getlogin.2,v 1.4 1995/02/27 12:33:03 cgd Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
@@ -46,6 +46,8 @@
.Ft char *
.Fn getlogin void
.Ft int
+.Fn getlogin_r "char *name" "size_t namelen"
+.Ft int
.Fn setlogin "const char *name"
.Sh DESCRIPTION
The
@@ -61,6 +63,23 @@ for example when
.Xr su 1
is used.)
.Pp
+The
+.Fn getlogin_r
+routine is a reentrant version of
+.Fn getlogin .
+It is functionally identical to
+.Fn getlogin
+except that the caller must provide a buffer,
+.Fa name ,
+in which to store the user's login name and a corresponding
+length parameter,
+.Fa namelen ,
+that specifies the size of the buffer.
+The buffer should be large enough to store the login name and a trailing NUL
+(typically
+.Ev LOGIN_NAME_MAX
+bytes).
+.Pp
.Fn setlogin
sets the login name of the user associated with the current session to
.Fa name .
@@ -122,6 +141,9 @@ 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 .
If a call to
+.Fn getlogin_r
+succeeds, a value of 0 is returned, else the error number is returned.
+If a call to
.Fn setlogin
succeeds, a value of 0 is returned.
If
@@ -149,6 +171,10 @@ Login names are limited to
characters, currently 31.
.It Bq Er EPERM
The caller tried to set the login name and was not the superuser.
+.It Bq Er ERANGE
+The buffer passed to
+.Fn getlogin_r
+is not large enough to store the user's login name.
.El
.Sh SEE ALSO
.Xr setsid 2