mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 22:35:10 +00:00
Reinstall the event handler if we get EAGAIN from read/write callback.
The read and write events do not set SUDO_EV_PERSIST so we need to explicitly re-enable the event if there is still data to be read. Bug #963.
This commit is contained in:
@@ -676,8 +676,12 @@ read_callback(int fd, int what, void *v)
|
|||||||
/* Schedule SIGTTIN to be forwarded to the command. */
|
/* Schedule SIGTTIN to be forwarded to the command. */
|
||||||
schedule_signal(iob->ec, SIGTTIN);
|
schedule_signal(iob->ec, SIGTTIN);
|
||||||
}
|
}
|
||||||
if (errno == EAGAIN || errno == EINTR)
|
if (errno == EAGAIN || errno == EINTR) {
|
||||||
|
/* Re-enable reader. */
|
||||||
|
if (sudo_ev_add(evbase, iob->revent, NULL, false) == -1)
|
||||||
|
sudo_fatal("%s", U_("unable to add event to queue"));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* treat read error as fatal and close the fd */
|
/* treat read error as fatal and close the fd */
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR,
|
sudo_debug_printf(SUDO_DEBUG_ERROR,
|
||||||
"error reading fd %d: %s", fd, strerror(errno));
|
"error reading fd %d: %s", fd, strerror(errno));
|
||||||
@@ -717,6 +721,8 @@ read_callback(int fd, int what, void *v)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -783,7 +789,9 @@ write_callback(int fd, int what, void *v)
|
|||||||
}
|
}
|
||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
/* not an error */
|
/* Not an error, re-enable writer. */
|
||||||
|
if (sudo_ev_add(evbase, iob->wevent, NULL, false) == -1)
|
||||||
|
sudo_fatal("%s", U_("unable to add event to queue"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* XXX - need a way to distinguish non-exec error. */
|
/* XXX - need a way to distinguish non-exec error. */
|
||||||
@@ -821,6 +829,8 @@ write_callback(int fd, int what, void *v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user