OSDN Git Service

Initial checkin of text Corinna sent to cygwin-announce.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / uinfo.cc
index ff96fcc..ee90e52 100644 (file)
@@ -86,7 +86,7 @@ cygheap_user::init ()
   /* Standard way to build a security descriptor with the usual DACL */
   PSECURITY_ATTRIBUTES sa_buf = (PSECURITY_ATTRIBUTES) alloca (1024);
   psd = (PSECURITY_DESCRIPTOR)
-               (sec_user_nih (sa_buf, sid()))->lpSecurityDescriptor;
+               (sec_user_nih (sa_buf, sid()))->lpSecurityDescriptor;
 
   BOOLEAN acl_exists, dummy;
   TOKEN_DEFAULT_DACL dacl;
@@ -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
@@ -319,7 +326,7 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
              if (!(ret = NetUserGetInfo (wlogsrv, wuser, 3, (LPBYTE *) &ui)))
                {
                  sys_wcstombs (homepath_env_buf, NT_MAX_PATH,
-                               ui->usri3_home_dir);
+                               ui->usri3_home_dir);
                  if (!homepath_env_buf[0])
                    {
                      sys_wcstombs (homepath_env_buf, NT_MAX_PATH,