diff mbox series

getlogin_r: fix missing fallback if loginuid is unset (bug 30235)

Message ID mvm8rfesdgb.fsf@suse.de
State New
Headers show
Series getlogin_r: fix missing fallback if loginuid is unset (bug 30235) | expand

Commit Message

Andreas Schwab March 30, 2023, 11:09 a.m. UTC
When /proc/self/loginuid is not set, we should still fall back to using
the traditional utmp lookup, instead of failing right away.
---
 sysdeps/unix/sysv/linux/getlogin_r.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Dmitry V. Levin March 30, 2023, 11:33 a.m. UTC | #1
On Thu, Mar 30, 2023 at 01:09:24PM +0200, Andreas Schwab via Libc-alpha wrote:
> When /proc/self/loginuid is not set, we should still fall back to using
> the traditional utmp lookup, instead of failing right away.
> ---
>  sysdeps/unix/sysv/linux/getlogin_r.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
> index 879df85a16..4ae9a53503 100644
> --- a/sysdeps/unix/sysv/linux/getlogin_r.c
> +++ b/sysdeps/unix/sysv/linux/getlogin_r.c
> @@ -59,10 +59,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
>       value of, (uid_t) -1, so check if that value is set and return early to
>       avoid making unneeded nss lookups. */
>    if (uid == (uid_t) -1)
> -    {
> -      __set_errno (ENXIO);
> -      return ENXIO;
> -    }
> +    return -1;
>  
>    struct passwd pwd;
>    struct passwd *tpwd;

LGTM, thanks.
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 879df85a16..4ae9a53503 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -59,10 +59,7 @@  __getlogin_r_loginuid (char *name, size_t namesize)
      value of, (uid_t) -1, so check if that value is set and return early to
      avoid making unneeded nss lookups. */
   if (uid == (uid_t) -1)
-    {
-      __set_errno (ENXIO);
-      return ENXIO;
-    }
+    return -1;
 
   struct passwd pwd;
   struct passwd *tpwd;