summaryrefslogtreecommitdiff
path: root/lib/libc/sys
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2008-06-25 11:10:24 +0000
committerad <ad@NetBSD.org>2008-06-25 11:10:24 +0000
commit5f64faa3a91c551e42e464c3f9d1c0cf8ebd690f (patch)
tree3c7e2e4c424532e2a1363db4daa2690d6c869f10 /lib/libc/sys
parentd29b52efe8625150feb6300703349f98a3511230 (diff)
Add getlogin_r. Manual page changes mostly lifted from FreeBSD.
Diffstat (limited to 'lib/libc/sys')
-rw-r--r--lib/libc/sys/Makefile.inc3
-rw-r--r--lib/libc/sys/getlogin.236
2 files changed, 34 insertions, 5 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 7e91155be24..04d44b5f58b 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.188 2008/06/15 20:36:52 christos Exp $
+# $NetBSD: Makefile.inc,v 1.189 2008/06/25 11:10:25 ad Exp $
# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94
# sys sources
@@ -253,6 +253,7 @@ MLINKS+=getcontext.2 setcontext.2
MLINKS+=getgid.2 getegid.2
MLINKS+=getitimer.2 setitimer.2
MLINKS+=getlogin.2 setlogin.2
+MLINKS+=getlogin_r.2 setlogin_r.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 203a355ba2e..5152d0cbd04 100644
--- a/lib/libc/sys/getlogin.2
+++ b/lib/libc/sys/getlogin.2
@@ -1,4 +1,4 @@
-.\" $NetBSD: getlogin.2,v 1.19 2004/05/13 10:20:58 wiz Exp $
+.\" $NetBSD: getlogin.2,v 1.20 2008/06/25 11:10:25 ad Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,11 +29,12 @@
.\"
.\" @(#)getlogin.2 8.1 (Berkeley) 6/9/93
.\"
-.Dd August 11, 2002
+.Dd June 25, 2008
.Dt GETLOGIN 2
.Os
.Sh NAME
.Nm getlogin ,
+.Nm getlogin_r ,
.Nm setlogin
.Nd get/set login name
.Sh LIBRARY
@@ -43,6 +44,8 @@
.Ft char *
.Fn getlogin void
.Ft int
+.Fn getlogin_r "char *name" "int len"
+.Ft int
.Fn setlogin "const char *name"
.Sh DESCRIPTION
The
@@ -59,6 +62,21 @@ for example when
.Xr su 1
is used.)
.Pp
+The
+.Fn getlogin_r
+function
+provides the same service as
+.Fn getlogin ,
+however 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 .
@@ -119,6 +137,7 @@ If a call to
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 .
+.Pp
If a call to
.Fn setlogin
succeeds, a value of 0 is returned.
@@ -127,6 +146,11 @@ If
fails, a value of \-1 is returned and an error code is
placed in the global location
.Va errno .
+.Pp
+The
+.Fn getlogin_r
+function
+returns zero if successful, or the error number upon failure.
.Sh ERRORS
The following errors may be returned by these calls:
.Bl -tag -width Er
@@ -147,14 +171,18 @@ Login names are limited to
characters, currently 16.
.It Bq Er EPERM
The caller tried to set the login name and was not the super-user.
+.It Bq Er ERANGE
+The size of the buffer is smaller than the result to be returned.
.El
.Sh SEE ALSO
.Xr setsid 2
.Sh STANDARDS
The
.Fn getlogin
-function conforms to
-.St -p1003.1-90 .
+and
+.Fn getlogin_r
+functions conform to
+.St -p1003.1-96 .
.Sh HISTORY
The
.Fn getlogin