]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
More fixes to error handling in getlogin_r.
authorAndreas Schwab <schwab@redhat.com>
Mon, 21 Jun 2010 14:57:12 +0000 (07:57 -0700)
committerAndreas Schwab <schwab@redhat.com>
Tue, 17 Aug 2010 08:59:28 +0000 (10:59 +0200)
(cherry picked from commit e35fcef8b739ed24e083ff8a3078ac14e101cf67)

ChangeLog
sysdeps/unix/sysv/linux/getlogin_r.c

index 1573eb348c59bcbfcb4e18343af4bbf0abf2259c..42efab904be70366e1e27109549ae1b359e9f197 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-21  Andreas Schwab <schwab@redhat.com>
+
+       * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
+       Restore proper fallback handling.
+
 2010-06-19  Ulrich Drepper  <drepper@redhat.com>
 
        * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Handle
index 5c3de69e8803d44be23d78f95ca09d028370f704..7d4d6c0ed5018f3382a3e3319faa72bc8d19630f 100644 (file)
@@ -27,6 +27,10 @@ static int getlogin_r_fd0 (char *name, size_t namesize);
 #undef getlogin_r
 
 
+/* Try to determine login name from /proc/self/loginuid and return 0
+   if successful.  If /proc/self/loginuid cannot be read return -1.
+   Otherwise return the error number.  */
+
 int
 attribute_hidden
 __getlogin_r_loginuid (name, namesize)
@@ -35,7 +39,7 @@ __getlogin_r_loginuid (name, namesize)
 {
   int fd = open_not_cancel_2 ("/proc/self/loginuid", O_RDONLY);
   if (fd == -1)
-    return 1;
+    return -1;
 
   /* We are reading a 32-bit number.  12 bytes are enough for the text
      representation.  If not, something is wrong.  */
@@ -51,7 +55,7 @@ __getlogin_r_loginuid (name, namesize)
       || (uidbuf[n] = '\0',
          uid = strtoul (uidbuf, &endp, 10),
          endp == uidbuf || *endp != '\0'))
-    return 1;
+    return -1;
 
   size_t buflen = 1024;
   char *buf = alloca (buflen);