mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 09:46:17 +01:00
Handle multiple user names with the same UID better. (#319535, Laszlo
2005-12-04 Matthias Clasen <mclasen@redhat.com> Handle multiple user names with the same UID better. (#319535, Laszlo Peter) * glib/gutils.c (g_get_any_init_do): When determining user data, first look up $LOGNAME. If the UID doesn't match getuid(), fall back to the current behaviour of looking up the user data based on getuid().
This commit is contained in:
parent
00f952f8e8
commit
8529c47126
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2005-12-04 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
Handle multiple user names with the same UID better.
|
||||||
|
(#319535, Laszlo Peter)
|
||||||
|
|
||||||
|
* glib/gutils.c (g_get_any_init_do): When determining user
|
||||||
|
data, first look up $LOGNAME. If the UID doesn't match
|
||||||
|
getuid(), fall back to the current behaviour of looking
|
||||||
|
up the user data based on getuid().
|
||||||
|
|
||||||
2005-12-04 Matthias Clasen <mclasen@redhat.com>
|
2005-12-04 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gmacros.h (G_GNUC_WARN_UNUSED_RESULT): Add a macro
|
* glib/gmacros.h (G_GNUC_WARN_UNUSED_RESULT): Add a macro
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2005-12-04 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
Handle multiple user names with the same UID better.
|
||||||
|
(#319535, Laszlo Peter)
|
||||||
|
|
||||||
|
* glib/gutils.c (g_get_any_init_do): When determining user
|
||||||
|
data, first look up $LOGNAME. If the UID doesn't match
|
||||||
|
getuid(), fall back to the current behaviour of looking
|
||||||
|
up the user data based on getuid().
|
||||||
|
|
||||||
2005-12-04 Matthias Clasen <mclasen@redhat.com>
|
2005-12-04 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gmacros.h (G_GNUC_WARN_UNUSED_RESULT): Add a macro
|
* glib/gmacros.h (G_GNUC_WARN_UNUSED_RESULT): Add a macro
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2005-12-04 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
Handle multiple user names with the same UID better.
|
||||||
|
(#319535, Laszlo Peter)
|
||||||
|
|
||||||
|
* glib/gutils.c (g_get_any_init_do): When determining user
|
||||||
|
data, first look up $LOGNAME. If the UID doesn't match
|
||||||
|
getuid(), fall back to the current behaviour of looking
|
||||||
|
up the user data based on getuid().
|
||||||
|
|
||||||
2005-12-04 Matthias Clasen <mclasen@redhat.com>
|
2005-12-04 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gmacros.h (G_GNUC_WARN_UNUSED_RESULT): Add a macro
|
* glib/gmacros.h (G_GNUC_WARN_UNUSED_RESULT): Add a macro
|
||||||
|
@ -1555,6 +1555,7 @@ g_get_any_init_do (void)
|
|||||||
struct passwd *pw = NULL;
|
struct passwd *pw = NULL;
|
||||||
gpointer buffer = NULL;
|
gpointer buffer = NULL;
|
||||||
gint error;
|
gint error;
|
||||||
|
gchar *logname;
|
||||||
|
|
||||||
# if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
|
# if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
|
||||||
struct passwd pwd;
|
struct passwd pwd;
|
||||||
@ -1568,6 +1569,8 @@ g_get_any_init_do (void)
|
|||||||
glong bufsize = 64;
|
glong bufsize = 64;
|
||||||
# endif /* _SC_GETPW_R_SIZE_MAX */
|
# endif /* _SC_GETPW_R_SIZE_MAX */
|
||||||
|
|
||||||
|
logname = (gchar *) g_getenv ("LOGNAME");
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
g_free (buffer);
|
g_free (buffer);
|
||||||
@ -1578,7 +1581,15 @@ g_get_any_init_do (void)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
# ifdef HAVE_POSIX_GETPWUID_R
|
# ifdef HAVE_POSIX_GETPWUID_R
|
||||||
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
if (logname) {
|
||||||
|
error = getpwnam_r (logname, &pwd, buffer, bufsize, &pw);
|
||||||
|
if (!pw || (pw->pw_uid != getuid ())) {
|
||||||
|
/* LOGNAME is lying, fall back to looking up the uid */
|
||||||
|
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
||||||
|
}
|
||||||
error = error < 0 ? errno : error;
|
error = error < 0 ? errno : error;
|
||||||
# else /* HAVE_NONPOSIX_GETPWUID_R */
|
# else /* HAVE_NONPOSIX_GETPWUID_R */
|
||||||
/* HPUX 11 falls into the HAVE_POSIX_GETPWUID_R case */
|
/* HPUX 11 falls into the HAVE_POSIX_GETPWUID_R case */
|
||||||
@ -1586,7 +1597,15 @@ g_get_any_init_do (void)
|
|||||||
error = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
error = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
||||||
pw = error == 0 ? &pwd : NULL;
|
pw = error == 0 ? &pwd : NULL;
|
||||||
# else /* !_AIX */
|
# else /* !_AIX */
|
||||||
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
if (logname) {
|
||||||
|
pw = getpwnam_r (logname, &pwd, buffer, bufsize);
|
||||||
|
if (!pw || (pw->pw_uid != getuid ())) {
|
||||||
|
/* LOGNAME is lying, fall back to looking up the uid */
|
||||||
|
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
||||||
|
}
|
||||||
error = pw ? 0 : errno;
|
error = pw ? 0 : errno;
|
||||||
# endif /* !_AIX */
|
# endif /* !_AIX */
|
||||||
# endif /* HAVE_NONPOSIX_GETPWUID_R */
|
# endif /* HAVE_NONPOSIX_GETPWUID_R */
|
||||||
|
Loading…
Reference in New Issue
Block a user