From c8727fa6e5073d28ed6d0eb40a006ac2c1b9f9f3 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 24 Mar 2010 17:02:57 -0700 Subject: Fix Linux getlogin{_r,} implementation The old implementation uses fd 0 to determine the login TTY. This was needed because using /dev/tty it is not possible to deduce the login TTY. For some time now there is the pseudo-file /proc/self/loginuid which directly helps us to find the user. Prefer using this file. It also works if stdin is closed, redirected, or re-opened. --- sysdeps/unix/getlogin_r.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sysdeps/unix/getlogin_r.c') diff --git a/sysdeps/unix/getlogin_r.c b/sysdeps/unix/getlogin_r.c index ba7badd054..bf3c889e13 100644 --- a/sysdeps/unix/getlogin_r.c +++ b/sysdeps/unix/getlogin_r.c @@ -1,5 +1,5 @@ /* Reentrant function to return the current login name. Unix version. - Copyright (C) 1991,92,96,97,98,2002 Free Software Foundation, Inc. + Copyright (C) 1991,92,96,97,98,2002,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -31,6 +31,9 @@ If it cannot be determined or some other error occurred, return the error code. Otherwise return 0. */ +#ifdef STATIC +STATIC +#endif int getlogin_r (name, name_len) char *name; @@ -96,4 +99,6 @@ getlogin_r (name, name_len) return result; } +#ifndef STATIC libc_hidden_def (getlogin_r) +#endif -- cgit 1.4.1