summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWilliam Jon McCann <jmccann@redhat.com>2010-06-30 10:20:43 -0400
committerRay Strode <rstrode@redhat.com>2010-08-17 13:45:20 -0400
commit9310418c63258dfd70cef46e2682cd9adc6c8f21 (patch)
tree3931193258559e6570482801acebc46b3aed3d1f /common
parent36e72382eb19c31ee9e59b72f27cb8537ef960dd (diff)
downloadgdm-9310418c63258dfd70cef46e2682cd9adc6c8f21.tar.gz
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.
Diffstat (limited to 'common')
-rw-r--r--common/gdm-common.c19
-rw-r--r--common/gdm-common.h3
2 files changed, 22 insertions, 0 deletions
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 <locale.h>
#include <fcntl.h>
#include <sys/wait.h>
+#include <pwd.h>
#include <glib.h>
#include <glib/gi18n.h>
@@ -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 <glib.h>
+#include <pwd.h>
#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);