olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1563046.patch

00db10
commit cc8a1620eb97ccddd337d157263c13c57b39ab71
00db10
Author: Jesse Hathaway <jesse@mbuki-mvuki.org>
00db10
Date:   Tue Mar 27 21:17:59 2018 +0000
00db10
00db10
    getlogin_r: return early when linux sentinel value is set
00db10
    
00db10
    When there is no login uid Linux sets /proc/self/loginid to the sentinel
00db10
    value of, (uid_t) -1. If this is set we can return early and avoid
00db10
    needlessly looking up the sentinel value in any configured nss
00db10
    databases.
00db10
    
00db10
    Checked on aarch64-linux-gnu.
00db10
    
00db10
            * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Return
00db10
            early when linux sentinel value is set.
00db10
    
00db10
    Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
00db10
00db10
Index: b/sysdeps/unix/sysv/linux/getlogin_r.c
00db10
===================================================================
00db10
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
00db10
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
00db10
@@ -54,6 +54,15 @@ __getlogin_r_loginuid (char *name, size_
00db10
 	  endp == uidbuf || *endp != '\0'))
00db10
     return -1;
00db10
 
00db10
+  /* If there is no login uid, linux sets /proc/self/loginid to the sentinel
00db10
+     value of, (uid_t) -1, so check if that value is set and return early to
00db10
+     avoid making unneeded nss lookups. */
00db10
+  if (uid == (uid_t) -1)
00db10
+    {
00db10
+      __set_errno (ENXIO);
00db10
+      return ENXIO;
00db10
+    }
00db10
+
00db10
   size_t buflen = 1024;
00db10
   char *buf = alloca (buflen);
00db10
   bool use_malloc = false;