summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorGeorge Lebl <jirka@5z.com>2003-07-28 21:13:11 +0000
committerGeorge Lebl <jirka@src.gnome.org>2003-07-28 21:13:11 +0000
commitc0ef449e5f8c9347683712073fcccbaa586fdf62 (patch)
tree94e8353dd6204c15f6d60e115a715fddf1a2df74 /daemon
parent1ed4984a24db1e471ed9c560b2b99e12e868f939 (diff)
downloadgdm-c0ef449e5f8c9347683712073fcccbaa586fdf62.tar.gz
for all functions for which I found in the manpages that EINTR could be
Mon Jul 28 14:10:12 2003 George Lebl <jirka@5z.com> * daemon/gdm.h, daemon/*.c: for all functions for which I found in the manpages that EINTR could be returned on at least some systems, use a new IGNORE_EINTR macro which will ignore the EINTR errno. This should fix any bugs with signals coming at the wrong times, though that is quite unlikely I'd say. Apparently SVr4 can return EINTR even for execv which is realy anal since EINTR is pretty much useless. Why can't we all be sane like BSD. * daemon/misc.c, daemon/server.c: automatic vars have weird behaviour when using Setjmp, so use static (volatile wouldn't work here if I'm reading the docs right)
Diffstat (limited to 'daemon')
-rw-r--r--daemon/auth.c2
-rw-r--r--daemon/cookie.c4
-rw-r--r--daemon/display.c8
-rw-r--r--daemon/errorgui.c28
-rw-r--r--daemon/filecheck.c7
-rw-r--r--daemon/gdm-net.c24
-rw-r--r--daemon/gdm.c77
-rw-r--r--daemon/gdm.h7
-rw-r--r--daemon/getvt.c6
-rw-r--r--daemon/misc.c71
-rw-r--r--daemon/server.c54
-rw-r--r--daemon/slave.c225
-rw-r--r--daemon/xdmcp.c2
13 files changed, 266 insertions, 249 deletions
diff --git a/daemon/auth.c b/daemon/auth.c
index a1d0a155..5e475282 100644
--- a/daemon/auth.c
+++ b/daemon/auth.c
@@ -580,7 +580,7 @@ gdm_auth_user_remove (GdmDisplay *d, uid_t user)
/* If we are using the fallback cookie location, simply nuke the
* cookie file */
if (d->authfb) {
- unlink (d->userauth);
+ IGNORE_EINTR (unlink (d->userauth));
g_free (d->userauth);
d->userauth = NULL;
return;
diff --git a/daemon/cookie.c b/daemon/cookie.c
index bf852ec2..0fb048bd 100644
--- a/daemon/cookie.c
+++ b/daemon/cookie.c
@@ -81,14 +81,14 @@ gdm_cookie_generate (GdmDisplay *d)
for (i = 0; i < RNGS; i++) {
if ((fd = open (rngs[i].path, O_RDONLY|O_NONBLOCK)) >= 0) {
- r = read (fd, buf, sizeof (buf));
+ IGNORE_EINTR (r = read (fd, buf, sizeof (buf)));
if (r > 0)
gdm_md5_update (&ctx, buf, r);
else
r = 0;
- close (fd);
+ IGNORE_EINTR (close (fd));
if (r >= rngs[i].length)
break;
diff --git a/daemon/display.c b/daemon/display.c
index ac370806..ce67c610 100644
--- a/daemon/display.c
+++ b/daemon/display.c
@@ -314,7 +314,7 @@ gdm_display_manage (GdmDisplay *d)
gdm_debug ("gdm_display_manage: Forked slave: %d",
(int)pid);
d->master_notify_fd = fds[1];
- close (fds[0]);
+ IGNORE_EINTR (close (fds[0]));
break;
}
@@ -387,12 +387,12 @@ gdm_display_dispose (GdmDisplay *d)
}
if (d->slave_notify_fd >= 0) {
- close (d->slave_notify_fd);
+ IGNORE_EINTR (close (d->slave_notify_fd));
d->slave_notify_fd = -1;
}
if (d->master_notify_fd >= 0) {
- close (d->master_notify_fd);
+ IGNORE_EINTR (close (d->master_notify_fd));
d->master_notify_fd = -1;
}
@@ -433,7 +433,7 @@ gdm_display_dispose (GdmDisplay *d)
d->authfile_gdm = NULL;
if (d->xnest_temp_auth_file != NULL)
- unlink (d->xnest_temp_auth_file);
+ IGNORE_EINTR (unlink (d->xnest_temp_auth_file));
g_free (d->xnest_temp_auth_file);
d->xnest_temp_auth_file = NULL;
diff --git a/daemon/errorgui.c b/daemon/errorgui.c
index 328f8e6b..e5e282c8 100644
--- a/daemon/errorgui.c
+++ b/daemon/errorgui.c
@@ -251,11 +251,13 @@ gdm_error_box_full (GdmDisplay *d, GtkMessageType type, const char *error,
if (details_file) {
FILE *fp;
struct stat s;
+ int r;
gboolean valid_utf8 = TRUE;
GString *gs = g_string_new (NULL);
fp = NULL;
- if (stat (details_file, &s) == 0) {
+ IGNORE_EINTR (r = stat (details_file, &s));
+ if (r == 0) {
if (S_ISREG (s.st_mode))
fp = fopen (details_file, "r");
else {
@@ -479,17 +481,17 @@ gdm_failsafe_question (GdmDisplay *d,
char buf[BUFSIZ];
int bytes;
- close (p[1]);
+ IGNORE_EINTR (close (p[1]));
gdm_wait_for_extra (NULL);
- bytes = read (p[0], buf, BUFSIZ-1);
+ IGNORE_EINTR (bytes = read (p[0], buf, BUFSIZ-1));
if (bytes > 0) {
- close (p[0]);
+ IGNORE_EINTR (close (p[0]));
buf[bytes] = '\0';
return g_strdup (buf);
}
- close (p[0]);
+ IGNORE_EINTR (close (p[0]));
} else {
gdm_error (_("%s: Cannot fork to display error/info box"),
"gdm_failsafe_question");
@@ -564,19 +566,19 @@ gdm_failsafe_yesno (GdmDisplay *d,
char buf[BUFSIZ];
int bytes;
- close (p[1]);
+ IGNORE_EINTR (close (p[1]));
gdm_wait_for_extra (NULL);
- bytes = read (p[0], buf, BUFSIZ-1);
+ IGNORE_EINTR (bytes = read (p[0], buf, BUFSIZ-1));
if (bytes > 0) {
- close (p[0]);
+ IGNORE_EINTR (close (p[0]));
if (buf[0] == 'y')
return TRUE;
else
return FALSE;
}
- close (p[0]);
+ IGNORE_EINTR (close (p[0]));
} else {
gdm_error (_("%s: Cannot fork to display error/info box"),
"gdm_failsafe_yesno");
@@ -659,21 +661,21 @@ gdm_failsafe_ask_buttons (GdmDisplay *d,
char buf[BUFSIZ];
int bytes;
- close (p[1]);
+ IGNORE_EINTR (close (p[1]));
gdm_wait_for_extra (NULL);
- bytes = read (p[0], buf, BUFSIZ-1);
+ IGNORE_EINTR (bytes = read (p[0], buf, BUFSIZ-1));
if (bytes > 0) {
int i;
- close (p[0]);
+ IGNORE_EINTR (close (p[0]));
buf[bytes] = '\0';
if (sscanf (buf, "%d", &i) == 1)
return i;
else
return -1;
}
- close (p[0]);
+ IGNORE_EINTR (close (p[0]));
} else {
gdm_error (_("%s: Cannot fork to display error/info box"),
"gdm_failsafe_ask_buttons");
diff --git a/daemon/filecheck.c b/daemon/filecheck.c
index 7aeb653e..5cf58670 100644
--- a/daemon/filecheck.c
+++ b/daemon/filecheck.c
@@ -45,9 +45,11 @@ gdm_file_check (const gchar *caller, uid_t user, const gchar *dir,
{
struct stat statbuf;
gchar *fullpath;
+ int r;
/* Stat directory */
- if (stat (dir, &statbuf) == -1) {
+ IGNORE_EINTR (r = stat (dir, &statbuf));
+ if (r < 0) {
if ( ! absentdirok)
syslog (LOG_WARNING, _("%s: Directory %s does not exist."),
caller, dir);
@@ -75,7 +77,8 @@ gdm_file_check (const gchar *caller, uid_t user, const gchar *dir,
fullpath = g_strconcat(dir, "/", file, NULL);
/* Stat file */
- if (stat (fullpath, &statbuf) == -1) {
+ IGNORE_EINTR (r = stat (fullpath, &statbuf));
+ if (r < 0) {
/* Return true if file does not exist and that is ok */
if (absentok) {
g_free (fullpath);
diff --git a/daemon/gdm-net.c b/daemon/gdm-net.c
index b4823cc3..8da6a788 100644
--- a/daemon/gdm-net.c
+++ b/daemon/gdm-net.c
@@ -99,7 +99,7 @@ gdm_connection_handler (GIOChannel *source,
if ( ! (cond & G_IO_IN))
return close_if_needed (conn, cond);
- len = read (conn->fd, buf, sizeof (buf) -1);
+ IGNORE_EINTR (len = read (conn->fd, buf, sizeof (buf) -1));
if (len <= 0) {
return close_if_needed (conn, cond);
}
@@ -158,10 +158,10 @@ gdm_connection_write (GdmConnection *conn, const char *str)
return FALSE;
#ifdef MSG_NOSIGNAL
- ret = send (conn->fd, str, strlen (str), MSG_NOSIGNAL);
+ IGNORE_EINTR (ret = send (conn->fd, str, strlen (str), MSG_NOSIGNAL));
#else
old_handler = signal (SIGPIPE, SIG_IGN);
- ret = send (conn->fd, str, strlen (str), 0);
+ IGNORE_EINTR (ret = send (conn->fd, str, strlen (str), 0));
signal (SIGPIPE, old_handler);
#endif
@@ -186,9 +186,9 @@ gdm_socket_handler (GIOChannel *source,
if ( ! (cond & G_IO_IN))
return TRUE;
- fd = accept (conn->fd,
- (struct sockaddr *)&addr,
- &addr_size);
+ IGNORE_EINTR (fd = accept (conn->fd,
+ (struct sockaddr *)&addr,
+ &addr_size));
if (fd < 0) {
gdm_debug ("gdm_socket_handler: Rejecting connection");
return TRUE;
@@ -241,7 +241,7 @@ gdm_connection_open_unix (const char *sockname, mode_t mode)
struct sockaddr_un addr;
int fd;
- unlink (sockname);
+ IGNORE_EINTR (unlink (sockname));
fd = socket (AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
@@ -257,11 +257,11 @@ gdm_connection_open_unix (const char *sockname, mode_t mode)
(struct sockaddr *) &addr, sizeof (addr)) < 0) {
gdm_error (_("%s: Could not bind socket"),
"gdm_connection_open_unix");
- close (fd);
+ IGNORE_EINTR (close (fd));
return NULL;
}
- chmod (sockname, mode);
+ IGNORE_EINTR (chmod (sockname, mode));
conn = g_new0 (GdmConnection, 1);
conn->close_level = 0;
@@ -328,7 +328,7 @@ gdm_connection_open_fifo (const char *fifo, mode_t mode)
GdmConnection *conn;
int fd;
- unlink (fifo);
+ IGNORE_EINTR (unlink (fifo));
if (mkfifo (fifo, 0660) < 0) {
gdm_error (_("%s: Could not make FIFO"),
@@ -344,7 +344,7 @@ gdm_connection_open_fifo (const char *fifo, mode_t mode)
return NULL;
}
- chmod (fifo, mode);
+ IGNORE_EINTR (chmod (fifo, mode));
conn = g_new0 (GdmConnection, 1);
conn->close_level = 0;
@@ -453,7 +453,7 @@ gdm_connection_close (GdmConnection *conn)
}
if (conn->fd > 0) {
- close (conn->fd);
+ IGNORE_EINTR (close (conn->fd));
conn->fd = -1;
}
diff --git a/daemon/gdm.c b/daemon/gdm.c
index 34755416..c9ea3597 100644
--- a/daemon/gdm.c
+++ b/daemon/gdm.c
@@ -222,8 +222,11 @@ compare_displays (gconstpointer a, gconstpointer b)
static void
check_servauthdir (struct stat *statbuf)
{
+ int r;
+
/* Enter paranoia mode */
- if (stat (GdmServAuthDir, statbuf) == -1) {
+ IGNORE_EINTR (r = stat (GdmServAuthDir, statbuf));
+ if (r < 0) {
char *s = g_strdup_printf
(_("Server Authorization directory "
"(daemon/ServAuthDir) is set to %s "
@@ -256,8 +259,10 @@ static void
check_logdir (void)
{
struct stat statbuf;
+ int r;
- if (stat (GdmLogDir, &statbuf) == -1 ||
+ IGNORE_EINTR (r = stat (GdmLogDir, &statbuf));
+ if (r < 0 ||
! S_ISDIR (statbuf.st_mode)) {
gdm_error (_("%s: Logdir %s does not exist or isn't a directory. Using ServAuthDir %s."), "gdm_config_parse",
GdmLogDir, GdmServAuthDir);
@@ -281,11 +286,13 @@ gdm_config_parse (void)
gchar *bin;
VeConfig *cfg;
GList *list, *li;
+ int r;
displays = NULL;
high_display_num = 0;
- if (stat (GDM_CONFIG_FILE, &statbuf) == -1) {
+ IGNORE_EINTR (r = stat (GDM_CONFIG_FILE, &statbuf));
+ if (r < 0) {
gdm_error (_("%s: No configuration file: %s. Using defaults."),
"gdm_config_parse", GDM_CONFIG_FILE);
} else {
@@ -828,12 +835,12 @@ gdm_daemonify (void)
gdm_fail (_("%s: setsid() failed: %s!"), "gdm_daemonify",
strerror(errno));
- chdir (GdmServAuthDir);
+ IGNORE_EINTR (chdir (GdmServAuthDir));
umask (022);
- close (0);
- close (1);
- close (2);
+ IGNORE_EINTR (close (0));
+ IGNORE_EINTR (close (1));
+ IGNORE_EINTR (close (2));
gdm_open_dev_null (O_RDONLY); /* open stdin - fd 0 */
gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */
@@ -928,7 +935,7 @@ gdm_final_cleanup (void)
char *path;
gdm_connection_close (fifoconn);
path = g_strconcat (GdmServAuthDir, "/.gdmfifo", NULL);
- unlink (path);
+ IGNORE_EINTR (unlink (path));
g_free (path);
fifoconn = NULL;
}
@@ -939,20 +946,20 @@ gdm_final_cleanup (void)
}
if (slave_fifo_pipe_fd >= 0) {
- close (slave_fifo_pipe_fd);
+ IGNORE_EINTR (close (slave_fifo_pipe_fd));
slave_fifo_pipe_fd = -1;
}
if (unixconn != NULL) {
gdm_connection_close (unixconn);
- unlink (GDM_SUP_SOCKET);
+ IGNORE_EINTR (unlink (GDM_SUP_SOCKET));
unixconn = NULL;
}
closelog();
if (GdmPidFile != NULL)
- unlink (GdmPidFile);
+ IGNORE_EINTR (unlink (GdmPidFile));
}
static gboolean
@@ -1037,7 +1044,7 @@ deal_with_x_crashes (GdmDisplay *d)
ve_setenv ("TEXTDOMAIN", GETTEXT_PACKAGE, TRUE);
ve_setenv ("TEXTDOMAINDIR", GNOMELOCALEDIR, TRUE);
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
/* yaikes! */
_exit (32);
@@ -1125,10 +1132,10 @@ suspend_machine (void)
/* Also make a new process group */
setsid ();
- chdir ("/");
+ IGNORE_EINTR (chdir ("/"));
argv = ve_split (GdmSuspendReal);
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
/* FIXME: what about fail */
_exit (1);
}
@@ -1139,8 +1146,8 @@ static void
change_to_first_and_clear (gboolean reboot)
{
gdm_change_vt (1);
- close (1);
- close (2);
+ IGNORE_EINTR (close (1));
+ IGNORE_EINTR (close (2));
open ("/dev/tty1", O_WRONLY);
open ("/dev/tty1", O_WRONLY);
/* yet again lazy */
@@ -1323,14 +1330,14 @@ start_autopsy:
gdm_info (_("Master rebooting..."));
gdm_final_cleanup ();
- chdir ("/");
+ IGNORE_EINTR (chdir ("/"));
#ifdef __linux__
change_to_first_and_clear (TRUE /* reboot */);
#endif /* __linux */
argv = ve_split (GdmRebootReal);
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
gdm_error (_("%s: Reboot failed: %s"),
"gdm_child_action", strerror (errno));
@@ -1343,14 +1350,14 @@ start_autopsy:
gdm_info (_("Master halting..."));
gdm_final_cleanup ();
- chdir ("/");
+ IGNORE_EINTR (chdir ("/"));
#ifdef __linux__
change_to_first_and_clear (FALSE /* reboot */);
#endif /* __linux */
argv = ve_split (GdmHaltReal);
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
gdm_error (_("%s: Halt failed: %s"),
"gdm_child_action", strerror (errno));
@@ -1475,7 +1482,7 @@ gdm_restart_now (void)
gdm_info (_("GDM restarting ..."));
gdm_final_cleanup ();
gdm_restoreenv ();
- execvp (stored_argv[0], stored_argv);
+ IGNORE_EINTR (execvp (stored_argv[0], stored_argv));
gdm_error (_("Failed to restart self"));
_exit (1);
}
@@ -1589,8 +1596,8 @@ create_connections (void)
&pipeconn,
close_notify);
} else {
- close (p[0]);
- close (p[1]);
+ IGNORE_EINTR (close (p[0]));
+ IGNORE_EINTR (close (p[1]));
slave_fifo_pipe_fd = -1;
}
@@ -1658,7 +1665,7 @@ ensure_desc_012 (void)
/* Once we are up to 3, we're beyond stdin,
* stdout and stderr */
if (fd >= 3) {
- close (fd);
+ IGNORE_EINTR (close (fd));
break;
}
}
@@ -1799,7 +1806,7 @@ main (int argc, char *argv[])
fclose (pf);
}
- chdir (GdmServAuthDir);
+ IGNORE_EINTR (chdir (GdmServAuthDir));
umask (022);
}
else
@@ -1961,16 +1968,12 @@ send_slave_ack (GdmDisplay *d, const char *resp)
char not[2];
not[0] = GDM_SLAVE_NOTIFY_ACK;
not[1] = '\n';
- while (write (d->master_notify_fd, not, 2) < 0 &&
- errno == EINTR)
- ;
+ IGNORE_EINTR (write (d->master_notify_fd, not, 2));
} else {
char *not = g_strdup_printf ("%c%s\n",
GDM_SLAVE_NOTIFY_ACK,
resp);
- while (write (d->master_notify_fd, not, strlen (not)) < 0 &&
- errno == EINTR)
- ;
+ IGNORE_EINTR (write (d->master_notify_fd, not, strlen (not)));
g_free (not);
}
}
@@ -1991,9 +1994,7 @@ send_slave_command (GdmDisplay *d, const char *command)
char *cmd = g_strdup_printf ("%c%s\n",
GDM_SLAVE_NOTIFY_COMMAND,
command);
- while (write (d->master_notify_fd, cmd, strlen (cmd)) < 0 &&
- errno == EINTR)
- ;
+ IGNORE_EINTR (write (d->master_notify_fd, cmd, strlen (cmd)));
g_free (cmd);
}
if (d->slavepid > 1) {
@@ -2652,6 +2653,7 @@ handle_flexi_server (GdmConnection *conn, int type, const char *server,
if (type == TYPE_FLEXI_XNEST) {
struct stat s;
+ int r;
gboolean authorized = TRUE;
seteuid (xnest_uid);
@@ -2660,7 +2662,8 @@ handle_flexi_server (GdmConnection *conn, int type, const char *server,
g_assert (xnest_disp != NULL);
g_assert (xnest_cookie != NULL);
- if (stat (xnest_auth_file, &s) < 0)
+ IGNORE_EINTR (r = stat (xnest_auth_file, &s));
+ if (r < 0)
authorized = FALSE;
if (authorized &&
/* if readable or writable by group or others,
@@ -2829,8 +2832,10 @@ update_config (const char *key)
{
struct stat statbuf;
VeConfig *cfg;
+ int r;
- if (stat (GDM_CONFIG_FILE, &statbuf) == -1) {
+ IGNORE_EINTR (r = stat (GDM_CONFIG_FILE, &statbuf));
+ if (r < 0) {
/* if the file didn't exist before either */
if (config_file_mtime == 0)
return TRUE;
diff --git a/daemon/gdm.h b/daemon/gdm.h
index 9900327d..de1583e1 100644
--- a/daemon/gdm.h
+++ b/daemon/gdm.h
@@ -672,6 +672,13 @@ enum {
* from a local display we started */
};
+#define IGNORE_EINTR(expr) \
+ do { \
+ errno = 0; \
+ expr; \
+ } while (errno == EINTR);
+
+
#endif /* GDM_H */
/* EOF */
diff --git a/daemon/getvt.c b/daemon/getvt.c
index a133b655..61efd50a 100644
--- a/daemon/getvt.c
+++ b/daemon/getvt.c
@@ -45,13 +45,13 @@ get_free_vt (int *vtfd)
return -1;
if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || (vtno == -1)) {
- close (fd);
+ IGNORE_EINTR (close (fd));
return -1;
}
fdv = open_vt (vtno);
if (fdv < 0) {
- close (fd);
+ IGNORE_EINTR (close (fd));
return -1;
}
@@ -81,7 +81,7 @@ get_free_vt (int *vtfd)
cleanup:
for (li = to_close_vts; li != NULL; li = li->next) {
- close (GPOINTER_TO_INT (li->data));
+ IGNORE_EINTR (close (GPOINTER_TO_INT (li->data)));
}
return vtno;
}
diff --git a/daemon/misc.c b/daemon/misc.c
index 33ac182b..12eae94e 100644
--- a/daemon/misc.c
+++ b/daemon/misc.c
@@ -219,9 +219,7 @@ gdm_fdprintf (int fd, const gchar *format, ...)
s = g_strdup_vprintf (format, args);
va_end (args);
- while (write (fd, s, strlen (s)) < 0 &&
- errno == EINTR)
- ;
+ IGNORE_EINTR (write (fd, s, strlen (s)));
g_free (s);
}
@@ -328,6 +326,7 @@ gdm_get_free_display (int start, uid_t server_uid)
struct stat s;
char buf[256];
FILE *fp;
+ int r;
for (li = displays; li != NULL; li = li->next) {
GdmDisplay *dsp = li->data;
@@ -345,17 +344,19 @@ gdm_get_free_display (int start, uid_t server_uid)
serv_addr.sin_port = htons (6000 + i);
errno = 0;
- if (connect (sock, (struct sockaddr *)&serv_addr,
- sizeof (serv_addr)) >= 0 ||
- errno != ECONNREFUSED) {
- close (sock);
+ IGNORE_EINTR (connect (sock,
+ (struct sockaddr *)&serv_addr,
+ sizeof (serv_addr)));
+ if (errno != 0 && errno != ECONNREFUSED) {
+ IGNORE_EINTR (close (sock));
continue;
}
- close (sock);
+ IGNORE_EINTR (close (sock));
/* if lock file exists and the process exists */
g_snprintf (buf, sizeof (buf), "/tmp/.X%d-lock", i);
- if (stat (buf, &s) == 0 &&
+ IGNORE_EINTR (r = stat (buf, &s));
+ if (r == 0 &&
! S_ISREG (s.st_mode)) {
/* Eeeek! not a regular file? Perhaps someone
is trying to play tricks on us */
@@ -376,7 +377,7 @@ gdm_get_free_display (int start, uid_t server_uid)
fclose (fp);
/* whack the file, it's a stale lock file */
- unlink (buf);
+ IGNORE_EINTR (unlink (buf));
}
/* if starting as root, we'll be able to overwrite any
@@ -385,14 +386,16 @@ gdm_get_free_display (int start, uid_t server_uid)
if (server_uid > 0) {
g_snprintf (buf, sizeof (buf),
"/tmp/.X11-unix/X%d", i);
- if (stat (buf, &s) == 0 &&
+ IGNORE_EINTR (r = stat (buf, &s));
+ if (r == 0 &&
s.st_uid != server_uid) {
continue;
}
g_snprintf (buf, sizeof (buf),
"/tmp/.X%d-lock", i);
- if (stat (buf, &s) == 0 &&
+ IGNORE_EINTR (r = stat (buf, &s));
+ if (r == 0 &&
s.st_uid != server_uid) {
continue;
}
@@ -532,7 +535,7 @@ gdm_text_yesno_dialog (const char *msg, gboolean *ret)
return FALSE;
}
- close (tempfd);
+ IGNORE_EINTR (close (tempfd));
argv[0] = EXPANDED_LIBEXECDIR "/gdmopen";
argv[1] = "-l";
@@ -569,7 +572,7 @@ gdm_text_yesno_dialog (const char *msg, gboolean *ret)
}
}
- unlink (tempname);
+ IGNORE_EINTR (unlink (tempname));
g_free (msg_quoted);
return TRUE;
@@ -611,7 +614,7 @@ gdm_exec_wait (char * const *argv, gboolean no_display,
ve_unsetenv ("XAUTHORITY");
}
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
_exit (-1);
}
@@ -781,15 +784,18 @@ gdm_ensure_sanity (void)
if (mkdir ("/tmp/.ICE-unix", 0777) == 0) {
/* Make sure it is root */
- if (chown ("/tmp/.ICE-unix", 0, 0) == 0)
- chmod ("/tmp/.ICE-unix", 01777);
+ IGNORE_EINTR (chown ("/tmp/.ICE-unix", 0, 0));
+ if (errno != 0)
+ IGNORE_EINTR (chmod ("/tmp/.ICE-unix", 01777));
} else {
struct stat s;
- if (lstat ("/tmp/.ICE-unix", &s) == 0 &&
- S_ISDIR (s.st_mode)) {
+ int r;
+ IGNORE_EINTR (r = lstat ("/tmp/.ICE-unix", &s));
+ if (r == 0 && S_ISDIR (s.st_mode)) {
/* Make sure it is root and sticky */
- if (chown ("/tmp/.ICE-unix", 0, 0) == 0)
- chmod ("/tmp/.ICE-unix", 01777);
+ IGNORE_EINTR (chown ("/tmp/.ICE-unix", 0, 0));
+ if (errno != 0)
+ IGNORE_EINTR (chmod ("/tmp/.ICE-unix", 01777));
}
}
@@ -847,7 +853,7 @@ gdm_peek_local_address_list (void)
"gdm_peek_local_address_list");
g_free (buf);
if (sockfd != gdm_xdmcpfd)
- close (sockfd);
+ IGNORE_EINTR (close (sockfd));
addr = g_new0 (struct in_addr, 1);
addr->s_addr = INADDR_LOOPBACK;
return g_list_append (NULL, addr);
@@ -879,7 +885,7 @@ gdm_peek_local_address_list (void)
}
if (sockfd != gdm_xdmcpfd)
- close (sockfd);
+ IGNORE_EINTR (close (sockfd));
g_free (buf);
#else /* SIOCGIFCONF */
@@ -1068,10 +1074,7 @@ gdm_fdgetc (int fd)
char buf[1];
int bytes;
- do {
- errno = 0;
- bytes = read (fd, buf, 1);
- } while (bytes < 0 && errno == EINTR);
+ IGNORE_EINTR (bytes = read (fd, buf, 1));
if (bytes != 1)
return EOF;
else
@@ -1110,7 +1113,7 @@ gdm_close_all_descriptors (int from, int except, int except2)
int max = sysconf (_SC_OPEN_MAX);
for (i = from; i < max; i++) {
if (i != except && i != except2)
- close(i);
+ IGNORE_EINTR (close(i));
}
}
@@ -1354,7 +1357,8 @@ jumpback_sighandler (int signal)
GdmHostent *
gdm_gethostbyname (const char *name)
{
- struct hostent *he_;
+ /* static because of Setjmp */
+ static struct hostent * he_;
SETUP_INTERRUPTS_FOR_TERM_DECLS
/* the cached address */
@@ -1362,6 +1366,8 @@ gdm_gethostbyname (const char *name)
static time_t last_time = 0;
static char *cached_hostname = NULL;
+ he_ = NULL;
+
if (cached_hostname != NULL &&
strcmp (cached_hostname, name) == 0) {
/* don't check more then every 60 seconds */
@@ -1396,7 +1402,8 @@ gdm_gethostbyname (const char *name)
GdmHostent *
gdm_gethostbyaddr (struct in_addr *ia)
{
- struct hostent *he_;
+ /* static because of Setjmp */
+ static struct hostent * he_;
SETUP_INTERRUPTS_FOR_TERM_DECLS
/* the cached address */
@@ -1404,6 +1411,8 @@ gdm_gethostbyaddr (struct in_addr *ia)
static time_t last_time = 0;
static struct in_addr cached_addr;
+ he_ = NULL;
+
if (last_time != 0 &&
memcmp (&cached_addr, ia, sizeof (struct in_addr)) == 0) {
/* don't check more then every 60 seconds */
@@ -1476,7 +1485,7 @@ FILE *
gdm_safe_fopen_w (const char *file)
{
int fd;
- unlink (file);
+ IGNORE_EINTR (unlink (file));
fd = open (file, O_EXCL|O_CREAT|O_TRUNC|O_WRONLY, 0644);
if (fd < 0)
return NULL;
diff --git a/daemon/server.c b/daemon/server.c
index d9f8a624..0af8ece8 100644
--- a/daemon/server.c
+++ b/daemon/server.c
@@ -96,12 +96,12 @@ gdm_server_whack_lockfile (GdmDisplay *disp)
/* if lock file exists and it is our process, whack it! */
g_snprintf (buf, sizeof (buf), "/tmp/.X%d-lock", disp->dispnum);
- unlink (buf);
+ IGNORE_EINTR (unlink (buf));
/* whack the unix socket as well */
g_snprintf (buf, sizeof (buf),
"/tmp/.X11-unix/X%d", disp->dispnum);
- unlink (buf);
+ IGNORE_EINTR (unlink (buf));
}
@@ -110,11 +110,11 @@ void
gdm_server_wipe_cookies (GdmDisplay *disp)
{
if ( ! ve_string_empty (disp->authfile))
- unlink (disp->authfile);
+ IGNORE_EINTR (unlink (disp->authfile));
g_free (disp->authfile);
disp->authfile = NULL;
if ( ! ve_string_empty (disp->authfile_gdm))
- unlink (disp->authfile_gdm);
+ IGNORE_EINTR (unlink (disp->authfile_gdm));
g_free (disp->authfile_gdm);
disp->authfile_gdm = NULL;
}
@@ -166,8 +166,12 @@ gdm_server_reinit (GdmDisplay *disp)
d->servstat = SERVER_PENDING;
if (disp->dsp != NULL) {
- int (*old_xerror_handler)(Display *, XErrorEvent *) = NULL;
- int (*old_xioerror_handler)(Display *) = NULL;
+ /* static because of the Setjmp */
+ static int (*old_xerror_handler)(Display *, XErrorEvent *) = NULL;
+ static int (*old_xioerror_handler)(Display *) = NULL;
+
+ old_xerror_handler = NULL;
+ old_xioerror_handler = NULL;
/* Do note the interaction of this Setjmp and the signal
handlers and the Setjmp in slave.c */
@@ -462,8 +466,8 @@ setup_server_wait (GdmDisplay *d)
if (sigaction (SIGUSR1, &usr1, NULL) < 0) {
gdm_error (_("%s: Error setting up %s signal handler: %s"),
"gdm_server_start", "USR1", strerror (errno));
- close (server_signal_pipe[0]);
- close (server_signal_pipe[1]);
+ IGNORE_EINTR (close (server_signal_pipe[0]));
+ IGNORE_EINTR (close (server_signal_pipe[1]));
return FALSE;
}
@@ -476,8 +480,8 @@ setup_server_wait (GdmDisplay *d)
gdm_error (_("%s: Error setting up %s signal handler: %s"),
"gdm_server_start", "CHLD", strerror (errno));
gdm_signal_ignore (SIGUSR1);
- close (server_signal_pipe[0]);
- close (server_signal_pipe[1]);
+ IGNORE_EINTR (close (server_signal_pipe[0]));
+ IGNORE_EINTR (close (server_signal_pipe[1]));
return FALSE;
}
@@ -552,7 +556,7 @@ do_server_wait (GdmDisplay *d)
if (select (server_signal_pipe[0]+1, &rfds, NULL, NULL, &tv) > 0) {
char buf[4];
/* read the Yay! */
- read (server_signal_pipe[0], buf, 4);
+ IGNORE_EINTR (read (server_signal_pipe[0], buf, 4));
}
if ( ! server_signal_notified &&
t + SERVER_WAIT_ALARM < time (NULL)) {
@@ -575,8 +579,8 @@ do_server_wait (GdmDisplay *d)
sigaction (SIGCHLD, &old_svr_wait_chld, NULL);
sigprocmask (SIG_SETMASK, &old_svr_wait_mask, NULL);
- close (server_signal_pipe[0]);
- close (server_signal_pipe[1]);
+ IGNORE_EINTR (close (server_signal_pipe[0]));
+ IGNORE_EINTR (close (server_signal_pipe[1]));
if (d->servpid <= 1) {
d->servstat = SERVER_ABORT;
@@ -655,7 +659,7 @@ gdm_server_start (GdmDisplay *disp, gboolean treat_as_flexi,
/* If we were holding a vt open for the server, close it now as it has
* already taken the bait. */
if (vtfd > 0)
- close (vtfd);
+ IGNORE_EINTR (close (vtfd));
switch (d->servstat) {
@@ -784,16 +788,16 @@ safer_rename (const char *a, const char *b)
errno = 0;
if (link (a, b) < 0) {
if (errno == EEXIST) {
- unlink (a);
+ IGNORE_EINTR (unlink (a));
return;
}
- unlink (b);
+ IGNORE_EINTR (unlink (b));
/* likely this system doesn't support hard links */
rename (a, b);
- unlink (a);
+ IGNORE_EINTR (unlink (a));
return;
}
- unlink (a);
+ IGNORE_EINTR (unlink (a));
}
static void
@@ -807,7 +811,7 @@ rotate_logs (const char *dname)
char *fname = g_strconcat (GdmLogDir, "/", dname, ".log", NULL);
/* Rotate the logs (keep 4 last) */
- unlink (fname4);
+ IGNORE_EINTR (unlink (fname4));
safer_rename (fname3, fname4);
safer_rename (fname2, fname3);
safer_rename (fname1, fname2);
@@ -1008,12 +1012,12 @@ gdm_server_spawn (GdmDisplay *d, const char *vtarg)
/* Log all output from spawned programs to a file */
logfile = g_strconcat (GdmLogDir, "/", d->name, ".log", NULL);
- unlink (logfile);
+ IGNORE_EINTR (unlink (logfile));
logfd = open (logfile, O_CREAT|O_TRUNC|O_WRONLY|O_EXCL, 0644);
if (logfd != -1) {
- dup2 (logfd, 1);
- dup2 (logfd, 2);
+ IGNORE_EINTR (dup2 (logfd, 1));
+ IGNORE_EINTR (dup2 (logfd, 2));
} else {
gdm_error (_("%s: Could not open logfile for display %s!"),
"gdm_server_spawn", d->name);
@@ -1133,7 +1137,7 @@ gdm_server_spawn (GdmDisplay *d, const char *vtarg)
setgroups (1, groups);
}
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
gdm_error (_("%s: Xserver not found: %s"),
"gdm_server_spawn", command);
@@ -1178,7 +1182,7 @@ gdm_server_usr1_handler (gint sig)
server_signal_notified = TRUE;
/* this will quit the select */
- write (server_signal_pipe[1], "Yay!", 4);
+ IGNORE_EINTR (write (server_signal_pipe[1], "Yay!", 4));
gdm_in_signal--;
}
@@ -1202,7 +1206,7 @@ gdm_server_child_handler (int signal)
gdm_slave_child_handler (signal);
/* this will quit the select */
- write (server_signal_pipe[1], "Yay!", 4);
+ IGNORE_EINTR (write (server_signal_pipe[1], "Yay!", 4));
gdm_in_signal--;
}
diff --git a/daemon/slave.c b/daemon/slave.c
index 8ab1ddf1..c2c0ec7c 100644
--- a/daemon/slave.c
+++ b/daemon/slave.c
@@ -237,9 +237,7 @@ slave_waitpid_notify_all (void)
for (li = slave_waitpids; li != NULL; li = li->next) {
GdmWaitPid *wp = li->data;
if (wp->fd_w >= 0) {
- while (write (wp->fd_w, "N", 1) < 0 &&
- errno == EINTR)
- ;
+ IGNORE_EINTR (write (wp->fd_w, "N", 1));
}
}
@@ -308,7 +306,7 @@ slave_waitpid (GdmWaitPid *wp)
ret = select (wp->fd_r+1, &rfds, NULL, NULL, NULL);
if (ret == 1)
- read (wp->fd_r, buf, 1);
+ IGNORE_EINTR (read (wp->fd_r, buf, 1));
check_notifies_now ();
} while (wp->pid > 1);
check_notifies_now ();
@@ -316,8 +314,8 @@ slave_waitpid (GdmWaitPid *wp)
gdm_sigchld_block_push ();
- close (wp->fd_r);
- close (wp->fd_w);
+ IGNORE_EINTR (close (wp->fd_r));
+ IGNORE_EINTR (close (wp->fd_w));
wp->fd_r = -1;
wp->fd_w = -1;
wp->pid = -1;
@@ -409,10 +407,10 @@ static void
whack_greeter_fds (void)
{
if (greeter_fd_out > 0)
- close (greeter_fd_out);
+ IGNORE_EINTR (close (greeter_fd_out));
greeter_fd_out = -1;
if (greeter_fd_in > 0)
- close (greeter_fd_in);
+ IGNORE_EINTR (close (greeter_fd_in));
greeter_fd_in = -1;
}
@@ -473,8 +471,8 @@ gdm_slave_start (GdmDisplay *display)
{
time_t first_time;
int death_count;
- static sigset_t mask;
struct sigaction alrm, term, child, usr2;
+ sigset_t mask;
/* Ignore SIGUSR1/SIGPIPE, and especially ignore it
before the Setjmp */
@@ -1163,7 +1161,7 @@ focus_first_x_window (const char *class_res_name)
fd_set rfds;
struct timeval tv;
- close (p[1]);
+ IGNORE_EINTR (close (p[1]));
FD_ZERO(&rfds);
FD_SET(p[0], &rfds);
@@ -1174,7 +1172,7 @@ focus_first_x_window (const char *class_res_name)
select(p[0]+1, &rfds, NULL, NULL, &tv);
- close (p[0]);
+ IGNORE_EINTR (close (p[0]));
}
return;
}
@@ -1218,8 +1216,8 @@ focus_first_x_window (const char *class_res_name)
SubstructureNotifyMask);
if (p[1] >= 0) {
- write (p[1], "!", 1);
- close (p[1]);
+ IGNORE_EINTR (write (p[1], "!", 1));
+ IGNORE_EINTR (close (p[1]));
}
for (;;) {
@@ -1336,15 +1334,16 @@ run_config (GdmDisplay *display, struct passwd *pwent)
openlog ("gdm", LOG_PID, LOG_DAEMON);
- if (chdir (pwent->pw_dir) != 0)
- chdir ("/");
+ IGNORE_EINTR (chdir (pwent->pw_dir));
+ if (errno != 0)
+ IGNORE_EINTR (chdir ("/"));
/* exec the configurator */
argv = ve_split (GdmConfigurator);
if (argv != NULL &&
argv[0] != NULL &&
access (argv[0], X_OK) == 0)
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
gdm_error_box (d,
GTK_MESSAGE_ERROR,
@@ -1358,7 +1357,7 @@ run_config (GdmDisplay *display, struct passwd *pwent)
(EXPANDED_BINDIR
"/gdmsetup --disable-sound --disable-crash-dialog");
if (access (argv[0], X_OK) == 0)
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
gdm_error_box (d,
GTK_MESSAGE_ERROR,
@@ -1652,7 +1651,7 @@ run_pictures (void)
for (;;) {
struct stat s;
char *tmp, *ret;
- int i;
+ int i, r;
g_free (response);
response = gdm_slave_greeter_ctl (GDM_NEEDPIC, "");
@@ -1808,7 +1807,8 @@ run_pictures (void)
g_free (picdir);
}
- if (stat (picfile, &s) < 0) {
+ IGNORE_EINTR (r = stat (picfile, &s));
+ if (r < 0) {
seteuid (0);
setegid (GdmGroupId);
@@ -1859,28 +1859,22 @@ run_pictures (void)
int written;
/* write until we succeed in writing something */
- do {
- errno = 0;
- written = write (greeter_fd_out, buf, bytes);
- if (written < 0 && errno == EPIPE) {
- /* something very, very bad has happened */
- gdm_slave_quick_exit (DISPLAY_REMANAGE);
- }
- } while (written < 0 && errno == EINTR);
+ IGNORE_EINTR (written = write (greeter_fd_out, buf, bytes));
+ if (written < 0 && errno == EPIPE) {
+ /* something very, very bad has happened */
+ gdm_slave_quick_exit (DISPLAY_REMANAGE);
+ }
/* write until we succeed in writing everything */
while (written < bytes) {
int n;
- do {
- errno = 0;
- n = write (greeter_fd_out, &buf[written], bytes-written);
- if (n < 0 && errno == EPIPE) {
- /* something very, very bad has happened */
- gdm_slave_quick_exit (DISPLAY_REMANAGE);
- }
- if (n > 0)
- written += n;
- } while (n < 0 && errno == EINTR);
+ IGNORE_EINTR (n = write (greeter_fd_out, &buf[written], bytes-written));
+ if (n < 0 && errno == EPIPE) {
+ /* something very, very bad has happened */
+ gdm_slave_quick_exit (DISPLAY_REMANAGE);
+ }
+ if (n > 0)
+ written += n;
}
/* we have written bytes btyes if it likes it or not */
@@ -1934,25 +1928,22 @@ copy_auth_file (uid_t fromuid, uid_t touid, const char *file)
name = g_strconcat (GdmServAuthDir, "/", d->name, ".XnestAuth", NULL);
- unlink (name);
+ IGNORE_EINTR (unlink (name));
authfd = open (name, O_EXCL|O_TRUNC|O_WRONLY|O_CREAT, 0600);
if (authfd < 0) {
- close (fromfd);
+ IGNORE_EINTR (close (fromfd));
seteuid (old);
g_free (name);
return NULL;
}
/* Make it owned by the user that Xnest is started as */
- fchown (authfd, touid, -1);
+ IGNORE_EINTR (fchown (authfd, touid, -1));
for (;;) {
int written, n;
- do {
- errno = 0;
- bytes = read (fromfd, buf, sizeof (buf));
- } while (bytes < 0 && errno == EINTR);
+ IGNORE_EINTR (bytes = read (fromfd, buf, sizeof (buf)));
/* EOF */
if (bytes == 0)
@@ -1960,14 +1951,11 @@ copy_auth_file (uid_t fromuid, uid_t touid, const char *file)
written = 0;
do {
- do {
- errno = 0;
- n = write (authfd, &buf[written], bytes-written);
- } while (n < 0 && errno == EINTR);
+ IGNORE_EINTR (n = write (authfd, &buf[written], bytes-written));
if (n < 0) {
/*Error writing*/
- close (fromfd);
- close (authfd);
+ IGNORE_EINTR (close (fromfd));
+ IGNORE_EINTR (close (authfd));
setuid (old);
g_free (name);
return NULL;
@@ -1976,8 +1964,8 @@ copy_auth_file (uid_t fromuid, uid_t touid, const char *file)
} while (written < bytes);
}
- close (fromfd);
- close (authfd);
+ IGNORE_EINTR (close (fromfd));
+ IGNORE_EINTR (close (authfd));
seteuid (old);
@@ -2025,11 +2013,11 @@ gdm_slave_greeter (void)
gdm_unset_signals ();
/* Plumbing */
- close (pipe1[1]);
- close (pipe2[0]);
+ IGNORE_EINTR (close (pipe1[1]));
+ IGNORE_EINTR (close (pipe2[0]));
- dup2 (pipe1[0], STDIN_FILENO);
- dup2 (pipe2[1], STDOUT_FILENO);
+ IGNORE_EINTR (dup2 (pipe1[0], STDIN_FILENO));
+ IGNORE_EINTR (dup2 (pipe2[1], STDOUT_FILENO));
closelog ();
@@ -2184,14 +2172,14 @@ gdm_slave_greeter (void)
perhaps it's the modules causing the problem in the first place */
! d->try_different_greeter) {
gchar *modules = g_strdup_printf("--gtk-module=%s", GdmGtkModulesList);
- execl (argv[0], argv[0], modules, NULL);
+ IGNORE_EINTR (execl (argv[0], argv[0], modules, NULL));
/* Something went wrong */
gdm_error (_("%s: Cannot start greeter with gtk modules: %s. Trying without modules"),
"gdm_slave_greeter",
GdmGtkModulesList);
g_free(modules);
}
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
gdm_error (_("%s: Cannot start greeter trying default: %s"),
"gdm_slave_greeter",
@@ -2202,7 +2190,7 @@ gdm_slave_greeter (void)
argv = g_new0 (char *, 2);
argv[0] = EXPANDED_BINDIR "/gdmlogin";
argv[1] = NULL;
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
gdm_error_box (d,
GTK_MESSAGE_ERROR,
@@ -2220,11 +2208,8 @@ gdm_slave_greeter (void)
gdm_slave_exit (DISPLAY_REMANAGE, _("%s: Can't fork gdmgreeter process"), "gdm_slave_greeter");
default:
- close (pipe1[0]);
- close (pipe2[1]);
-
- fcntl(pipe1[1], F_SETFD, fcntl(pipe1[1], F_GETFD, 0) | FD_CLOEXEC);
- fcntl(pipe2[0], F_SETFD, fcntl(pipe2[0], F_GETFD, 0) | FD_CLOEXEC);
+ IGNORE_EINTR (close (pipe1[0]));
+ IGNORE_EINTR (close (pipe2[1]));
whack_greeter_fds ();
@@ -2322,8 +2307,9 @@ gdm_slave_send (const char *str, gboolean wait_for_ack)
gdm_fdprintf (fd, "\n%s\n", str);
- if (fd != slave_fifo_pipe_fd)
- close (fd);
+ if (fd != slave_fifo_pipe_fd) {
+ IGNORE_EINTR (close (fd));
+ }
#if defined(_POSIX_PRIORITY_SCHEDULING) && defined(HAVE_SCHED_YIELD)
if (wait_for_ack && ! gdm_got_ack) {
@@ -2494,14 +2480,14 @@ gdm_slave_chooser (void)
gdm_unset_signals ();
/* Plumbing */
- close (p[0]);
+ IGNORE_EINTR (close (p[0]));
if (p[1] != STDOUT_FILENO)
- dup2 (p[1], STDOUT_FILENO);
+ IGNORE_EINTR (dup2 (p[1], STDOUT_FILENO));
closelog ();
- close (0);
+ IGNORE_EINTR (close (0));
gdm_close_all_descriptors (2 /* from */, -1 /* except */, -1 /* except2 */);
gdm_open_dev_null (O_RDONLY); /* open stdin - fd 0 */
@@ -2553,7 +2539,7 @@ gdm_slave_chooser (void)
ve_setenv ("RUNNING_UNDER_GDM", "true", TRUE);
argv = ve_split (GdmChooser);
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
gdm_error_box (d,
GTK_MESSAGE_ERROR,
@@ -2570,9 +2556,7 @@ gdm_slave_chooser (void)
gdm_debug ("gdm_slave_chooser: Chooser on pid %d", d->chooserpid);
gdm_slave_send_num (GDM_SOP_CHOOSERPID, d->chooserpid);
- close (p[1]);
-
- fcntl(p[0], F_SETFD, fcntl(p[0], F_GETFD, 0) | FD_CLOEXEC);
+ IGNORE_EINTR (close (p[1]));
/* wait for the chooser to die */
@@ -2588,9 +2572,9 @@ gdm_slave_chooser (void)
/* Note: Nothing affecting the chooser needs update
* from notifies */
- bytes = read (p[0], buf, sizeof(buf)-1);
+ IGNORE_EINTR (bytes = read (p[0], buf, sizeof(buf)-1));
if (bytes > 0) {
- close (p[0]);
+ IGNORE_EINTR (close (p[0]));
if (buf[bytes-1] == '\n')
buf[bytes-1] ='\0';
@@ -2606,7 +2590,7 @@ gdm_slave_chooser (void)
}
}
- close (p[0]);
+ IGNORE_EINTR (close (p[0]));
gdm_slave_quick_exit (DISPLAY_REMANAGE);
break;
@@ -2751,7 +2735,7 @@ session_child_run (struct passwd *pwent,
setegid (pwent->pw_gid);
seteuid (pwent->pw_uid);
/* unlink to be anal */
- unlink (filename);
+ IGNORE_EINTR (unlink (filename));
logfd = open (filename, O_EXCL|O_CREAT|O_TRUNC|O_WRONLY, 0644);
seteuid (old);
setegid (oldg);
@@ -2759,25 +2743,25 @@ session_child_run (struct passwd *pwent,
g_free (filename);
if (logfd != -1) {
- dup2 (logfd, 1);
- dup2 (logfd, 2);
- close (logfd);
+ IGNORE_EINTR (dup2 (logfd, 1));
+ IGNORE_EINTR (dup2 (logfd, 2));
+ IGNORE_EINTR (close (logfd));
} else {
- close (1);
- close (2);
+ IGNORE_EINTR (close (1));
+ IGNORE_EINTR (close (2));
gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */
gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */
gdm_error (_("%s: Could not open ~/.xsession-errors"),
"run_session_child");
}
} else {
- close (1);
- close (2);
+ IGNORE_EINTR (close (1));
+ IGNORE_EINTR (close (2));
gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */
gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */
}
- close (0);
+ IGNORE_EINTR (close (0));
gdm_open_dev_null (O_RDONLY); /* open stdin - fd 0 */
/* Set this for the PreSession script */
@@ -2832,7 +2816,7 @@ session_child_run (struct passwd *pwent,
/* Now still as root make the system authfile not readable by others,
and therefore not by the gdm user */
- chmod (GDM_AUTHFILE (d), 0640);
+ IGNORE_EINTR (chmod (GDM_AUTHFILE (d), 0640));
setpgid (0, 0);
@@ -2849,8 +2833,9 @@ session_child_run (struct passwd *pwent,
* not to leave the egid around */
setegid (pwent->pw_gid);
- if (chdir (home_dir) != 0) {
- chdir ("/");
+ IGNORE_EINTR (chdir (home_dir));
+ if (errno != 0) {
+ IGNORE_EINTR (chdir ("/"));
}
#ifdef HAVE_LOGINCAP
@@ -3038,7 +3023,7 @@ session_child_run (struct passwd *pwent,
_exit (0);
}
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
/* will go to .xsession-errors */
fprintf (stderr, _("%s: Could not exec %s %s %s"),
@@ -3351,7 +3336,7 @@ gdm_slave_session_start (void)
/* Now still as root make the system authfile readable by others,
and therefore by the gdm user */
- chmod (GDM_AUTHFILE (d), 0644);
+ IGNORE_EINTR (chmod (GDM_AUTHFILE (d), 0644));
end_time = time (NULL);
@@ -3414,7 +3399,7 @@ gdm_slave_session_stop (gboolean run_post_session,
/* Now still as root make the system authfile not readable by others,
and therefore not by the gdm user */
if (GDM_AUTHFILE (d) != NULL)
- chmod (GDM_AUTHFILE (d), 0640);
+ IGNORE_EINTR (chmod (GDM_AUTHFILE (d), 0640));
gdm_debug ("gdm_slave_session_stop: %s on %s", local_login, d->name);
@@ -3446,7 +3431,7 @@ gdm_slave_session_stop (gboolean run_post_session,
TRUE /* set_parent */);
}
- unlink (x_servers_file);
+ IGNORE_EINTR (unlink (x_servers_file));
g_free (x_servers_file);
g_free (local_login);
@@ -3643,9 +3628,7 @@ gdm_slave_child_handler (int sig)
if (wp->pid == pid) {
wp->pid = -1;
if (wp->fd_w >= 0) {
- while (write (wp->fd_w, "!", 1) < 0 &&
- errno == EINTR)
- ;
+ IGNORE_EINTR (write (wp->fd_w, "!", 1));
}
}
}
@@ -3760,7 +3743,7 @@ gdm_slave_handle_usr2_message (void)
char **vec;
int i;
- count = read (d->slave_notify_fd, buf, sizeof (buf) -1);
+ IGNORE_EINTR (count = read (d->slave_notify_fd, buf, sizeof (buf) -1));
if (count <= 0) {
return;
}
@@ -4094,7 +4077,7 @@ gdm_slave_whack_temp_auth_file (void)
if (old != 0)
seteuid (0);
if (d->xnest_temp_auth_file != NULL)
- unlink (d->xnest_temp_auth_file);
+ IGNORE_EINTR (unlink (d->xnest_temp_auth_file));
g_free (d->xnest_temp_auth_file);
d->xnest_temp_auth_file = NULL;
if (old != 0)
@@ -4107,7 +4090,7 @@ create_temp_auth_file (void)
if (d->type == TYPE_FLEXI_XNEST &&
d->xnest_auth_file != NULL) {
if (d->xnest_temp_auth_file != NULL)
- unlink (d->xnest_temp_auth_file);
+ IGNORE_EINTR (unlink (d->xnest_temp_auth_file));
g_free (d->xnest_temp_auth_file);
d->xnest_temp_auth_file =
copy_auth_file (d->server_uid,
@@ -4195,12 +4178,12 @@ gdm_slave_exec_script (GdmDisplay *d, const gchar *dir, const char *login,
case 0:
closelog ();
- close (0);
+ IGNORE_EINTR (close (0));
gdm_open_dev_null (O_RDONLY); /* open stdin - fd 0 */
if ( ! pass_stdout) {
- close (1);
- close (2);
+ IGNORE_EINTR (close (1));
+ IGNORE_EINTR (close (2));
/* No error checking here - if it's messed the best response
* is to ignore & try to continue */
gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */
@@ -4224,12 +4207,13 @@ gdm_slave_exec_script (GdmDisplay *d, const gchar *dir, const char *login,
if (ve_string_empty (pwent->pw_dir)) {
ve_setenv ("HOME", "/", TRUE);
ve_setenv ("PWD", "/", TRUE);
- chdir ("/");
+ IGNORE_EINTR (chdir ("/"));
} else {
ve_setenv ("HOME", pwent->pw_dir, TRUE);
ve_setenv ("PWD", pwent->pw_dir, TRUE);
- if (chdir (pwent->pw_dir) != 0) {
- chdir ("/");
+ IGNORE_EINTR (chdir (pwent->pw_dir));
+ if (errno != 0) {
+ IGNORE_EINTR (chdir ("/"));
ve_setenv ("PWD", "/", TRUE);
}
}
@@ -4237,7 +4221,7 @@ gdm_slave_exec_script (GdmDisplay *d, const gchar *dir, const char *login,
} else {
ve_setenv ("HOME", "/", TRUE);
ve_setenv ("PWD", "/", TRUE);
- chdir ("/");
+ IGNORE_EINTR (chdir ("/"));
ve_setenv ("SHELL", "/bin/sh", TRUE);
}
@@ -4262,7 +4246,7 @@ gdm_slave_exec_script (GdmDisplay *d, const gchar *dir, const char *login,
ve_setenv ("RUNNING_UNDER_GDM", "true", TRUE);
ve_unsetenv ("MAIL");
argv = ve_split (script);
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
syslog (LOG_ERR, _("%s: Failed starting: %s"), "gdm_slave_exec_script",
script);
_exit (EXIT_SUCCESS);
@@ -4376,9 +4360,9 @@ gdm_parse_enriched_login (const gchar *s, GdmDisplay *display)
/* The child will write the username to stdout based on the DISPLAY
environment variable. */
- close (pipe1[0]);
+ IGNORE_EINTR (close (pipe1[0]));
if(pipe1[1] != STDOUT_FILENO)
- dup2 (pipe1[1], STDOUT_FILENO);
+ IGNORE_EINTR (dup2 (pipe1[1], STDOUT_FILENO));
closelog ();
@@ -4396,7 +4380,7 @@ gdm_parse_enriched_login (const gchar *s, GdmDisplay *display)
ve_unsetenv ("MAIL");
argv = ve_split (str->str);
- execv (argv[0], argv);
+ IGNORE_EINTR (execv (argv[0], argv));
gdm_error (_("%s: Failed executing: %s"),
"gdm_parse_enriched_login",
str->str);
@@ -4405,24 +4389,27 @@ gdm_parse_enriched_login (const gchar *s, GdmDisplay *display)
case -1:
gdm_error (_("%s: Can't fork script process!"),
"gdm_parse_enriched_login");
- close (pipe1[0]);
- close (pipe1[1]);
+ IGNORE_EINTR (close (pipe1[0]));
+ IGNORE_EINTR (close (pipe1[1]));
break;
default:
/* The parent reads username from the pipe a chunk at a time */
- close(pipe1[1]);
- g_string_truncate(str,0);
- while((in_buffer_len = read(pipe1[0],in_buffer,
- sizeof(in_buffer)/sizeof(char)- 1)) > 0) {
- in_buffer[in_buffer_len] = '\000';
- g_string_append(str,in_buffer);
- }
+ IGNORE_EINTR (close (pipe1[1]));
+ g_string_truncate (str, 0);
+ do {
+ IGNORE_EINTR (in_buffer_len = read (pipe1[0], in_buffer,
+ sizeof(in_buffer) - 1));
+ if (in_buffer_len > 0) {
+ in_buffer[in_buffer_len] = '\0';
+ g_string_append (str, in_buffer);
+ }
+ } while (in_buffer_len > 0);
if(str->len > 0 && str->str[str->len - 1] == '\n')
g_string_truncate(str, str->len - 1);
- close(pipe1[0]);
+ IGNORE_EINTR (close(pipe1[0]));
gdm_wait_for_extra (NULL);
}
diff --git a/daemon/xdmcp.c b/daemon/xdmcp.c
index 6d6433e7..34f2c691 100644
--- a/daemon/xdmcp.c
+++ b/daemon/xdmcp.c
@@ -312,7 +312,7 @@ gdm_xdmcp_close (void)
}
if (gdm_xdmcpfd > 0) {
- close (gdm_xdmcpfd);
+ IGNORE_EINTR (close (gdm_xdmcpfd));
gdm_xdmcpfd = -1;
}
}