diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a75f54caa..6622ac4ea 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2011-05-16 Corinna Vinschen + + * globals.cc (__getlogin_username): Remove. + * uinfo.cc (getlogin_r): Fetch username from cygheap. + (getlogin): Add static buffer username and fetch username from + getlogin_r. + 2011-05-16 Corinna Vinschen * cygtls.h (struct _local_storage): Remove unused members rarg and diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc index 68bd5519c..f27429c6b 100644 --- a/winsup/cygwin/globals.cc +++ b/winsup/cygwin/globals.cc @@ -56,9 +56,6 @@ bool display_title; bool strip_title_path; bool allow_glob = true; -/* Static getlogin buffer. */ -char __getlogin_username[UNLEN + 1]; - bool NO_COPY in_forkee; int __argc_safe; diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index ff96fcc7f..0c9c3eca9 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -187,7 +187,7 @@ uinfo_init () extern "C" int getlogin_r (char *name, size_t namesize) { - char *login = getlogin (); + const char *login = cygheap->user.name (); size_t len = strlen (login) + 1; if (len > namesize) return ERANGE; @@ -201,7 +201,14 @@ getlogin_r (char *name, size_t namesize) extern "C" char * getlogin (void) { - return strcpy (__getlogin_username, cygheap->user.name ()); + static char username[UNLEN]; + int ret = getlogin_r (username, UNLEN); + if (ret) + { + set_errno (ret); + return NULL; + } + return username; } extern "C" __uid32_t