1 2010-08-06 Ulrich Drepper <drepper@redhat.com>
3 * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
4 Also fail if tpwd after pwuid call is NULL.
6 2010-06-21 Andreas Schwab <schwab@redhat.com>
8 * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
9 Restore proper fallback handling.
11 2010-06-19 Ulrich Drepper <drepper@redhat.com>
13 * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Handle
14 OOM in getpwuid_r correctly. Return error number when the caller
15 should return, otherwise -1.
16 (getlogin_r): Adjust to return also for result of __getlogin_r_loginuid
17 call returning > 0 value.
18 * sysdeps/unix/sysv/linux/getlogin.c (getlogin): Likewise.
20 Index: glibc-2.12-2-gc4ccff1/sysdeps/unix/sysv/linux/getlogin.c
21 ===================================================================
22 --- glibc-2.12-2-gc4ccff1.orig/sysdeps/unix/sysv/linux/getlogin.c
23 +++ glibc-2.12-2-gc4ccff1/sysdeps/unix/sysv/linux/getlogin.c
28 - if (__getlogin_r_loginuid (name, sizeof (name)) == 0)
30 + int res = __getlogin_r_loginuid (name, sizeof (name));
32 + return res == 0 ? name : NULL;
34 return getlogin_fd0 ();
36 Index: glibc-2.12-2-gc4ccff1/sysdeps/unix/sysv/linux/getlogin_r.c
37 ===================================================================
38 --- glibc-2.12-2-gc4ccff1.orig/sysdeps/unix/sysv/linux/getlogin_r.c
39 +++ glibc-2.12-2-gc4ccff1/sysdeps/unix/sysv/linux/getlogin_r.c
40 @@ -27,6 +27,10 @@ static int getlogin_r_fd0 (char *name, s
44 +/* Try to determine login name from /proc/self/loginuid and return 0
45 + if successful. If /proc/self/loginuid cannot be read return -1.
46 + Otherwise return the error number. */
50 __getlogin_r_loginuid (name, namesize)
51 @@ -35,7 +39,7 @@ __getlogin_r_loginuid (name, namesize)
53 int fd = open_not_cancel_2 ("/proc/self/loginuid", O_RDONLY);
58 /* We are reading a 32-bit number. 12 bytes are enough for the text
59 representation. If not, something is wrong. */
60 @@ -51,37 +55,38 @@ __getlogin_r_loginuid (name, namesize)
62 uid = strtoul (uidbuf, &endp, 10),
63 endp == uidbuf || *endp != '\0'))
68 char *buf = alloca (buflen);
69 bool use_malloc = false;
75 - while ((res = __getpwuid_r (uid, &pwd, buf, buflen, &tpwd)) != 0)
76 + while ((res = __getpwuid_r (uid, &pwd, buf, buflen, &tpwd)) == ERANGE)
77 if (__libc_use_alloca (2 * buflen))
78 - extend_alloca (buf, buflen, 2 * buflen);
79 + buf = extend_alloca (buf, buflen, 2 * buflen);
83 char *newp = realloc (use_malloc ? buf : NULL, buflen);
99 + if (res != 0 || tpwd == NULL)
106 size_t needed = strlen (pwd.pw_name) + 1;
107 if (needed > namesize)
109 @@ -109,8 +114,9 @@ getlogin_r (name, namesize)
113 - if (__getlogin_r_loginuid (name, namesize) == 0)
115 + int res = __getlogin_r_loginuid (name, namesize);
119 return getlogin_r_fd0 (name, namesize);