Skip to content

Commit b9dab8c

Browse files
committed
Merge sudo 1.9.11p3 from tip.
--HG-- branch : 1.9
2 parents ecb5be2 + 01a9e5a commit b9dab8c

7 files changed

Lines changed: 97 additions & 36 deletions

File tree

NEWS

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
What's new in Sudo 1.9.11p3
2+
3+
* Fixed "connection reset" errors on AIX when running shell scripts
4+
with the "intercept" or "log_subcmds" sudoers options enabled.
5+
Bug #1034.
6+
7+
* Fixed very slow execution of shell scripts when the "intercept"
8+
or "log_subcmds" sudoers options are set on systems that enable
9+
Nagle's algorithm on the loopback device, such as AIX.
10+
Bug #1034.
11+
112
What's new in Sudo 1.9.11p2
213

314
* Fixed a compilation error on Linux/x86_64 with the x32 ABI.

configure

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# Guess values for system-dependent variables and create Makefiles.
3-
# Generated by GNU Autoconf 2.71 for sudo 1.9.11p2.
3+
# Generated by GNU Autoconf 2.71 for sudo 1.9.11p3.
44
#
55
# Report bugs to <https://bugzilla.sudo.ws/>.
66
#
@@ -621,8 +621,8 @@ MAKEFLAGS=
621621
# Identity of this package.
622622
PACKAGE_NAME='sudo'
623623
PACKAGE_TARNAME='sudo'
624-
PACKAGE_VERSION='1.9.11p2'
625-
PACKAGE_STRING='sudo 1.9.11p2'
624+
PACKAGE_VERSION='1.9.11p3'
625+
PACKAGE_STRING='sudo 1.9.11p3'
626626
PACKAGE_BUGREPORT='https://bugzilla.sudo.ws/'
627627
PACKAGE_URL=''
628628

@@ -1640,7 +1640,7 @@ if test "$ac_init_help" = "long"; then
16401640
# Omit some internal or obsolete options to make the list less imposing.
16411641
# This message is too long to be a string in the A/UX 3.1 sh.
16421642
cat <<_ACEOF
1643-
\`configure' configures sudo 1.9.11p2 to adapt to many kinds of systems.
1643+
\`configure' configures sudo 1.9.11p3 to adapt to many kinds of systems.
16441644

16451645
Usage: $0 [OPTION]... [VAR=VALUE]...
16461646

@@ -1706,7 +1706,7 @@ fi
17061706

17071707
if test -n "$ac_init_help"; then
17081708
case $ac_init_help in
1709-
short | recursive ) echo "Configuration of sudo 1.9.11p2:";;
1709+
short | recursive ) echo "Configuration of sudo 1.9.11p3:";;
17101710
esac
17111711
cat <<\_ACEOF
17121712

@@ -1996,7 +1996,7 @@ fi
19961996
test -n "$ac_init_help" && exit $ac_status
19971997
if $ac_init_version; then
19981998
cat <<\_ACEOF
1999-
sudo configure 1.9.11p2
1999+
sudo configure 1.9.11p3
20002000
generated by GNU Autoconf 2.71
20012001

20022002
Copyright (C) 2021 Free Software Foundation, Inc.
@@ -2653,7 +2653,7 @@ cat >config.log <<_ACEOF
26532653
This file contains any messages produced by compilers while
26542654
running configure, to aid debugging if configure makes a mistake.
26552655

2656-
It was created by sudo $as_me 1.9.11p2, which was
2656+
It was created by sudo $as_me 1.9.11p3, which was
26572657
generated by GNU Autoconf 2.71. Invocation command line was
26582658

26592659
$ $0$ac_configure_args_raw
@@ -33050,7 +33050,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
3305033050
# report actual input values of CONFIG_FILES etc. instead of their
3305133051
# values after options handling.
3305233052
ac_log="
33053-
This file was extended by sudo $as_me 1.9.11p2, which was
33053+
This file was extended by sudo $as_me 1.9.11p3, which was
3305433054
generated by GNU Autoconf 2.71. Invocation command line was
3305533055

3305633056
CONFIG_FILES = $CONFIG_FILES
@@ -33118,7 +33118,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
3311833118
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
3311933119
ac_cs_config='$ac_cs_config_escaped'
3312033120
ac_cs_version="\\
33121-
sudo config.status 1.9.11p2
33121+
sudo config.status 1.9.11p3
3312233122
configured by $0, generated by GNU Autoconf 2.71,
3312333123
with options \\"\$ac_cs_config\\"
3312433124

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1818
dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1919
dnl
2020
AC_PREREQ([2.70])
21-
AC_INIT([sudo], [1.9.11p2], [https://bugzilla.sudo.ws/], [sudo])
21+
AC_INIT([sudo], [1.9.11p3], [https://bugzilla.sudo.ws/], [sudo])
2222
AC_CONFIG_HEADERS([config.h pathnames.h])
2323
AC_CONFIG_SRCDIR([src/sudo.c])
2424
AC_CONFIG_AUX_DIR([scripts])

lib/util/getgrouplist.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ int
6666
sudo_getgrouplist2_v1(const char *name, GETGROUPS_T basegid,
6767
GETGROUPS_T **groupsp, int *ngroupsp)
6868
{
69+
#ifdef __APPLE__
70+
int *groups = (int *)*groupsp;
71+
#else
6972
GETGROUPS_T *groups = *groupsp;
73+
#endif
7074
int ngroups;
7175
#ifndef HAVE_GETGROUPLIST_2
7276
int grpsize, tries;

plugins/sudoers/logging.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -573,15 +573,15 @@ log_allowed(struct eventlog *evlog)
573573
}
574574

575575
bool
576-
log_exit_status(int exit_status)
576+
log_exit_status(int status)
577577
{
578578
struct eventlog evlog;
579579
int evl_flags = 0;
580-
int ecode = 0;
580+
int exit_value = 0;
581581
int oldlocale;
582582
struct timespec run_time;
583583
char sigbuf[SIG2STR_MAX];
584-
char *signame = NULL;
584+
char *signal_name = NULL;
585585
bool dumped_core = false;
586586
bool ret = true;
587587
debug_decl(log_exit_status, SUDOERS_DEBUG_LOGGING);
@@ -594,17 +594,17 @@ log_exit_status(int exit_status)
594594
}
595595
sudo_timespecsub(&run_time, &sudo_user.submit_time, &run_time);
596596

597-
if (WIFEXITED(exit_status)) {
598-
ecode = WEXITSTATUS(exit_status);
599-
} else if (WIFSIGNALED(exit_status)) {
600-
int signo = WTERMSIG(exit_status);
597+
if (WIFEXITED(status)) {
598+
exit_value = WEXITSTATUS(status);
599+
} else if (WIFSIGNALED(status)) {
600+
int signo = WTERMSIG(status);
601601
if (signo <= 0 || sig2str(signo, sigbuf) == -1)
602602
(void)snprintf(sigbuf, sizeof(sigbuf), "%d", signo);
603-
signame = sigbuf;
604-
ecode = signo | 128;
605-
dumped_core = WCOREDUMP(exit_status);
603+
signal_name = sigbuf;
604+
exit_value = signo | 128;
605+
dumped_core = WCOREDUMP(status);
606606
} else {
607-
sudo_warnx("invalid exit status 0x%x", exit_status);
607+
sudo_warnx("invalid exit status 0x%x", status);
608608
ret = false;
609609
goto done;
610610
}
@@ -619,8 +619,8 @@ log_exit_status(int exit_status)
619619
SET(evl_flags, EVLOG_MAIL_ONLY);
620620
}
621621
evlog.run_time = run_time;
622-
evlog.exit_value = ecode;
623-
evlog.signal_name = signame;
622+
evlog.exit_value = exit_value;
623+
evlog.signal_name = signal_name;
624624
evlog.dumped_core = dumped_core;
625625
if (!eventlog_exit(&evlog, evl_flags))
626626
ret = false;

src/exec_intercept.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <sys/socket.h>
2727
#include <netinet/in.h>
28+
#include <netinet/tcp.h>
2829

2930
#if defined(HAVE_STDINT_H)
3031
# include <stdint.h>
@@ -560,8 +561,12 @@ intercept_read(int fd, struct intercept_closure *closure)
560561
case false:
561562
goto done;
562563
default:
563-
if (errno == EINTR || errno == EAGAIN)
564+
if (errno == EINTR || errno == EAGAIN) {
564565
debug_return_bool(true);
566+
sudo_debug_printf(
567+
SUDO_DEBUG_WARN|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO,
568+
"reading intercept token");
569+
}
565570
sudo_warn("recv");
566571
goto done;
567572
}
@@ -574,8 +579,12 @@ intercept_read(int fd, struct intercept_closure *closure)
574579
nread = recv(fd, &req_len, sizeof(req_len), 0);
575580
if (nread != sizeof(req_len)) {
576581
if (nread == -1) {
577-
if (errno == EINTR || errno == EAGAIN)
582+
if (errno == EINTR || errno == EAGAIN) {
583+
sudo_debug_printf(
584+
SUDO_DEBUG_WARN|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO,
585+
"reading intercept message size");
578586
debug_return_bool(true);
587+
}
579588
sudo_warn("recv");
580589
}
581590
goto done;
@@ -605,8 +614,12 @@ intercept_read(int fd, struct intercept_closure *closure)
605614
/* EOF, other side must have exited. */
606615
goto done;
607616
case -1:
608-
if (errno == EINTR || errno == EAGAIN)
617+
if (errno == EINTR || errno == EAGAIN) {
618+
sudo_debug_printf(
619+
SUDO_DEBUG_WARN|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO,
620+
"reading intercept message");
609621
debug_return_bool(true);
622+
}
610623
sudo_warn("recv");
611624
goto done;
612625
default:
@@ -835,8 +848,12 @@ intercept_write(int fd, struct intercept_closure *closure)
835848
nwritten = send(fd, closure->buf + closure->off,
836849
closure->len - closure->off, 0);
837850
if (nwritten == -1) {
838-
if (errno == EINTR || errno == EAGAIN)
851+
if (errno == EINTR || errno == EAGAIN) {
852+
sudo_debug_printf(
853+
SUDO_DEBUG_WARN|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO,
854+
"writing intercept message");
839855
debug_return_bool(true);
856+
}
840857
sudo_warn("send");
841858
goto done;
842859
}
@@ -930,7 +947,7 @@ intercept_accept_cb(int fd, int what, void *v)
930947
struct sudo_event_base *evbase = sudo_ev_get_base(&closure->ev);
931948
struct sockaddr_in sin;
932949
socklen_t sin_len = sizeof(sin);
933-
int client_sock, flags;
950+
int client_sock, flags, on = 1;
934951
debug_decl(intercept_accept_cb, SUDO_DEBUG_EXEC);
935952

936953
if (closure->state != RECV_CONNECTION) {
@@ -951,6 +968,9 @@ intercept_accept_cb(int fd, int what, void *v)
951968
if (flags != -1)
952969
(void)fcntl(client_sock, F_SETFL, flags | O_NONBLOCK);
953970

971+
/* Send data immediately, we need low latency IPC. */
972+
(void)setsockopt(client_sock, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
973+
954974
/*
955975
* Create a new intercept closure and register an event for client_sock.
956976
*/

src/sudo_intercept_common.c

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <sys/types.h>
2727
#include <sys/socket.h>
2828
#include <netinet/in.h>
29+
#include <netinet/tcp.h>
2930

3031
#if defined(HAVE_STDINT_H)
3132
# include <stdint.h>
@@ -136,16 +137,29 @@ recv_intercept_response(int fd)
136137
debug_decl(recv_intercept_response, SUDO_DEBUG_EXEC);
137138

138139
/* Read message size (uint32_t in host byte order). */
139-
nread = recv(fd, &res_len, sizeof(res_len), 0);
140-
if ((size_t)nread != sizeof(res_len)) {
141-
if (nread == 0) {
140+
for (;;) {
141+
nread = recv(fd, &res_len, sizeof(res_len), 0);
142+
if (nread == ssizeof(res_len))
143+
break;
144+
switch (nread) {
145+
case 0:
142146
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
143147
"unexpected EOF reading response size");
144-
} else {
145-
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
148+
break;
149+
case -1:
150+
if (errno == EINTR)
151+
continue;
152+
sudo_debug_printf(
153+
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
146154
"error reading response size");
155+
break;
156+
default:
157+
sudo_debug_printf(
158+
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
159+
"error reading response size: short read");
160+
break;
147161
}
148-
goto done;
162+
goto done;
149163
}
150164
if (res_len > MESSAGE_SIZE_MAX) {
151165
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
@@ -169,7 +183,8 @@ recv_intercept_response(int fd)
169183
case -1:
170184
if (errno == EINTR)
171185
continue;
172-
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
186+
sudo_debug_printf(
187+
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
173188
"error reading response");
174189
goto done;
175190
default:
@@ -199,7 +214,7 @@ sudo_interposer_init(void)
199214
{
200215
InterceptResponse *res = NULL;
201216
static bool initialized;
202-
int fd = -1;
217+
int flags, fd = -1;
203218
char **p;
204219
debug_decl(sudo_interposer_init, SUDO_DEBUG_EXEC);
205220

@@ -239,6 +254,13 @@ sudo_interposer_init(void)
239254
goto done;
240255
}
241256

257+
/*
258+
* We don't want to use non-blocking I/O.
259+
*/
260+
flags = fcntl(fd, F_GETFL, 0);
261+
if (flags != -1)
262+
(void)fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
263+
242264
/*
243265
* Send InterceptHello message to over the fd.
244266
*/
@@ -334,6 +356,7 @@ static int
334356
intercept_connect(void)
335357
{
336358
int sock = -1;
359+
int on = 1;
337360
struct sockaddr_in sin;
338361
debug_decl(command_allowed, SUDO_DEBUG_EXEC);
339362

@@ -353,6 +376,9 @@ intercept_connect(void)
353376
goto done;
354377
}
355378

379+
/* Send data immediately, we need low latency IPC. */
380+
(void)setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
381+
356382
if (connect(sock, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
357383
sudo_warn("connect");
358384
close(sock);

0 commit comments

Comments
 (0)