From 9310418c63258dfd70cef46e2682cd9adc6c8f21 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Wed, 30 Jun 2010 10:20:43 -0400 Subject: Wrap getpw* calls to retry in EINTR if getpwnam(username) returns NULL, errno needs to be checked for EINTR. This indicates that a signal was received while waiting for the blocking call to return, and getpwnam() should be retried. --- common/gdm-common.c | 19 +++++++++++++++++++ common/gdm-common.h | 3 +++ 2 files changed, 22 insertions(+) (limited to 'common') diff --git a/common/gdm-common.c b/common/gdm-common.c index 8435161e..de807000 100644 --- a/common/gdm-common.c +++ b/common/gdm-common.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -73,6 +74,24 @@ gdm_set_fatal_warnings_if_unstable (void) } } +gboolean +gdm_get_pwent_for_name (const char *name, + struct passwd **pwentp) +{ + struct passwd *pwent; + + do { + errno = 0; + pwent = getpwnam (name); + } while (pwent == NULL && errno == EINTR); + + if (pwentp != NULL) { + *pwentp = pwent; + } + + return (pwent != NULL); +} + int gdm_wait_on_pid (int pid) { diff --git a/common/gdm-common.h b/common/gdm-common.h index 1983cffe..8faeda5c 100644 --- a/common/gdm-common.h +++ b/common/gdm-common.h @@ -22,6 +22,7 @@ #define _GDM_COMMON_H #include +#include #include "gdm-common-unknown-origin.h" @@ -35,6 +36,8 @@ void gdm_set_fatal_warnings_if_unstable (void); int gdm_wait_on_pid (int pid); int gdm_signal_pid (int pid, int signal); +gboolean gdm_get_pwent_for_name (const char *name, + struct passwd **pwentp); const char * gdm_make_temp_dir (char *template); -- cgit v1.2.1