Skip to content

Commit 172cbd9

Browse files
committed
Merge sudo 1.9.16p2 from tip.
--HG-- branch : 1.9
2 parents 1fbc146 + 73cbe4e commit 172cbd9

File tree

17 files changed

+134
-65
lines changed

17 files changed

+134
-65
lines changed

NEWS

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
What's new in Sudo 1.9.16p2
2+
3+
* Sudo now passes the terminal device number to the policy plugin
4+
even if it cannot resolve it to a path name. This allows sudo
5+
to run without warnings in a chroot jail when the terminal device
6+
files are not present. GitHub issue #421.
7+
8+
* On Linux systems, sudo will now attempt to use the symbolic links
9+
in /proc/self/fd/{0,1,2} when resolving the terminal device
10+
number. This can allow sudo to map a terminal device to its
11+
path name even when /dev/pts is not mounted in a chroot jail.
12+
13+
* Fixed compilation errors with gcc and clang in C23 mode.
14+
C23 no longer supports functions with unspecified arguments.
15+
116
What's new in Sudo 1.9.16p1
217

318
* Fixed the test for cross-compiling when checking for C99 snprintf().

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.72 for sudo 1.9.16p1.
3+
# Generated by GNU Autoconf 2.72 for sudo 1.9.16p2.
44
#
55
# Report bugs to <https://bugzilla.sudo.ws/>.
66
#
@@ -614,8 +614,8 @@ MAKEFLAGS=
614614
# Identity of this package.
615615
PACKAGE_NAME='sudo'
616616
PACKAGE_TARNAME='sudo'
617-
PACKAGE_VERSION='1.9.16p1'
618-
PACKAGE_STRING='sudo 1.9.16p1'
617+
PACKAGE_VERSION='1.9.16p2'
618+
PACKAGE_STRING='sudo 1.9.16p2'
619619
PACKAGE_BUGREPORT='https://bugzilla.sudo.ws/'
620620
PACKAGE_URL=''
621621

@@ -1645,7 +1645,7 @@ if test "$ac_init_help" = "long"; then
16451645
# Omit some internal or obsolete options to make the list less imposing.
16461646
# This message is too long to be a string in the A/UX 3.1 sh.
16471647
cat <<_ACEOF
1648-
'configure' configures sudo 1.9.16p1 to adapt to many kinds of systems.
1648+
'configure' configures sudo 1.9.16p2 to adapt to many kinds of systems.
16491649

16501650
Usage: $0 [OPTION]... [VAR=VALUE]...
16511651

@@ -1711,7 +1711,7 @@ fi
17111711

17121712
if test -n "$ac_init_help"; then
17131713
case $ac_init_help in
1714-
short | recursive ) echo "Configuration of sudo 1.9.16p1:";;
1714+
short | recursive ) echo "Configuration of sudo 1.9.16p2:";;
17151715
esac
17161716
cat <<\_ACEOF
17171717

@@ -2006,7 +2006,7 @@ fi
20062006
test -n "$ac_init_help" && exit $ac_status
20072007
if $ac_init_version; then
20082008
cat <<\_ACEOF
2009-
sudo configure 1.9.16p1
2009+
sudo configure 1.9.16p2
20102010
generated by GNU Autoconf 2.72
20112011

20122012
Copyright (C) 2023 Free Software Foundation, Inc.
@@ -2826,7 +2826,7 @@ cat >config.log <<_ACEOF
28262826
This file contains any messages produced by compilers while
28272827
running configure, to aid debugging if configure makes a mistake.
28282828

2829-
It was created by sudo $as_me 1.9.16p1, which was
2829+
It was created by sudo $as_me 1.9.16p2, which was
28302830
generated by GNU Autoconf 2.72. Invocation command line was
28312831

28322832
$ $0$ac_configure_args_raw
@@ -36774,7 +36774,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
3677436774
# report actual input values of CONFIG_FILES etc. instead of their
3677536775
# values after options handling.
3677636776
ac_log="
36777-
This file was extended by sudo $as_me 1.9.16p1, which was
36777+
This file was extended by sudo $as_me 1.9.16p2, which was
3677836778
generated by GNU Autoconf 2.72. Invocation command line was
3677936779

3678036780
CONFIG_FILES = $CONFIG_FILES
@@ -36842,7 +36842,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
3684236842
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
3684336843
ac_cs_config='$ac_cs_config_escaped'
3684436844
ac_cs_version="\\
36845-
sudo config.status 1.9.16p1
36845+
sudo config.status 1.9.16p2
3684636846
configured by $0, generated by GNU Autoconf 2.72,
3684736847
with options \\"\$ac_cs_config\\"
3684836848

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.69])
21-
AC_INIT([sudo], [1.9.16p1], [https://bugzilla.sudo.ws/], [sudo])
21+
AC_INIT([sudo], [1.9.16p2], [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])

include/sudo_plugin.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ typedef int (*sudo_printf_t)(int msg_type, const char * restrict fmt, ...);
9696
#endif
9797

9898
/* Hook functions typedefs. */
99+
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
100+
typedef int (*sudo_hook_fn_t)(...);
101+
#else
99102
typedef int (*sudo_hook_fn_t)();
103+
#endif
100104
typedef int (*sudo_hook_fn_setenv_t)(const char *name, const char *value, int overwrite, void *closure);
101105
typedef int (*sudo_hook_fn_putenv_t)(char *string, void *closure);
102106
typedef int (*sudo_hook_fn_getenv_t)(const char *name, char **value, void *closure);

lib/util/regress/parse_gids/parse_gids_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static struct parse_gids_test test_data[] = {
5050
{ "1,2,3,4", &test_data[0].basegid, 0, 5, test1_out },
5151
{ "1,2,3,4", NULL, 0, 4, test2_out },
5252
{ "1,-2,3,4", &test_data[2].basegid, 0, 5, test3_out },
53-
{ NULL, false, 0, 0, NULL }
53+
{ NULL, NULL, 0, 0, NULL }
5454
};
5555

5656
static void

lib/util/setgroups.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ sudo_setgroups_v1(int ngids, const GETGROUPS_T *gids)
5050
if (maxgids == -1)
5151
maxgids = NGROUPS_MAX;
5252
if (ngids > maxgids)
53-
ret = setgroups(maxgids, (GETGROUPS_T *)gids);
53+
ret = setgroups((int)maxgids, (GETGROUPS_T *)gids);
5454
}
5555
debug_return_int(ret);
5656
}

lib/util/ttyname_dev.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,39 @@ char *
253253
sudo_ttyname_dev_v1(dev_t rdev, char *buf, size_t buflen)
254254
{
255255
const char *devsearch, *devsearch_end;
256-
char path[PATH_MAX], *ret;
256+
char path[PATH_MAX], *ret = NULL;
257257
const char *cp, *ep;
258258
size_t len;
259259
debug_decl(sudo_ttyname_dev, SUDO_DEBUG_UTIL);
260260

261+
#ifdef __linux__
262+
/*
263+
* First check std{in,out,err} and use /proc/self/fd/{0,1,2} if possible.
264+
*/
265+
for (int fd = STDIN_FILENO; fd <= STDERR_FILENO; fd++) {
266+
char fdpath[] = "/proc/self/fd/N";
267+
struct stat sb;
268+
269+
if (fstat(fd, &sb) == -1 || !S_ISCHR(sb.st_mode))
270+
continue;
271+
if (rdev != sb.st_rdev)
272+
continue;
273+
274+
fdpath[sizeof("/proc/self/fd/N") - 2] = '0' + fd;
275+
len = readlink(fdpath, buf, buflen);
276+
if (len != (size_t)-1) {
277+
if (len == buflen) {
278+
errno = ERANGE; /* buf too small */
279+
} else {
280+
/* readlink(2) does not NUL-terminate. */
281+
buf[len] = '\0';
282+
ret = buf;
283+
}
284+
goto done;
285+
}
286+
}
287+
#endif
288+
261289
/*
262290
* First, check /dev/console.
263291
*/

plugins/sudoers/cvtsudoers_ldif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ print_global_defaults_ldif(FILE *fp,
204204
lbuf.len = 0;
205205
if (!sudo_lbuf_append(&lbuf, "# "))
206206
goto done;
207-
if (!sudoers_format_default_line(&lbuf, parse_tree, opt, false, true))
207+
if (!sudoers_format_default_line(&lbuf, parse_tree, opt, NULL, true))
208208
goto done;
209209
fprintf(fp, "# Unable to translate %s:%d:%d:\n%s\n",
210210
opt->file, opt->line, opt->column, lbuf.buf);

plugins/sudoers/cvtsudoers_pwutil.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ cvtsudoers_make_grlist_item(const struct passwd *pw, char * const *unused1)
403403
struct cache_item_grlist *grlitem;
404404
struct sudoers_string *s;
405405
struct group_list *grlist;
406-
size_t groupname_len;
406+
long groupname_len;
407407
debug_decl(cvtsudoers_make_grlist_item, SUDOERS_DEBUG_NSS);
408408

409409
/*
@@ -421,15 +421,17 @@ cvtsudoers_make_grlist_item(const struct passwd *pw, char * const *unused1)
421421
}
422422

423423
#ifdef _SC_LOGIN_NAME_MAX
424-
groupname_len = (size_t)MAX(sysconf(_SC_LOGIN_NAME_MAX), 32);
424+
groupname_len = sysconf(_SC_LOGIN_NAME_MAX);
425+
if (groupname_len < 32)
426+
groupname_len = 32;
425427
#else
426428
groupname_len = MAX(LOGIN_NAME_MAX, 32);
427429
#endif
428430

429431
/* Allocate in one big chunk for easy freeing. */
430432
nsize = strlen(pw->pw_name) + 1;
431433
total = sizeof(*grlitem) + nsize;
432-
total += groupname_len * ngroups;
434+
total += (size_t)groupname_len * ngroups;
433435

434436
again:
435437
if ((grlitem = calloc(1, total)) == NULL) {
@@ -470,7 +472,7 @@ cvtsudoers_make_grlist_item(const struct passwd *pw, char * const *unused1)
470472
}
471473
len = strlen(s->str) + 1;
472474
if ((size_t)(cp - (char *)grlitem) + len > total) {
473-
total += len + groupname_len;
475+
total += len + (size_t)groupname_len;
474476
free(grlitem);
475477
goto again;
476478
}

plugins/sudoers/policy.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,10 +1358,10 @@ sudoers_policy_version(int verbose)
13581358
}
13591359

13601360
static struct sudo_hook sudoers_hooks[] = {
1361-
{ SUDO_HOOK_VERSION, SUDO_HOOK_SETENV, sudoers_hook_setenv, NULL },
1362-
{ SUDO_HOOK_VERSION, SUDO_HOOK_UNSETENV, sudoers_hook_unsetenv, NULL },
1363-
{ SUDO_HOOK_VERSION, SUDO_HOOK_GETENV, sudoers_hook_getenv, NULL },
1364-
{ SUDO_HOOK_VERSION, SUDO_HOOK_PUTENV, sudoers_hook_putenv, NULL },
1361+
{ SUDO_HOOK_VERSION, SUDO_HOOK_SETENV, (sudo_hook_fn_t)sudoers_hook_setenv, NULL },
1362+
{ SUDO_HOOK_VERSION, SUDO_HOOK_UNSETENV, (sudo_hook_fn_t)sudoers_hook_unsetenv, NULL },
1363+
{ SUDO_HOOK_VERSION, SUDO_HOOK_GETENV, (sudo_hook_fn_t)sudoers_hook_getenv, NULL },
1364+
{ SUDO_HOOK_VERSION, SUDO_HOOK_PUTENV, (sudo_hook_fn_t)sudoers_hook_putenv, NULL },
13651365
{ 0, 0, NULL, NULL }
13661366
};
13671367

0 commit comments

Comments
 (0)