Remove vsyslog(3) emulation, it is no longer used.

This commit is contained in:
Todd C. Miller
2021-06-14 13:11:39 -06:00
parent d311c7b2ee
commit cc3b4ffb04
9 changed files with 1 additions and 278 deletions

View File

@@ -285,7 +285,6 @@ lib/util/regress/sudo_parseln/test5.out.ok
lib/util/regress/sudo_parseln/test6.in
lib/util/regress/sudo_parseln/test6.out.ok
lib/util/regress/tailq/hltq_test.c
lib/util/regress/vsyslog/vsyslog_test.c
lib/util/roundup.c
lib/util/secure_path.c
lib/util/setgroups.c
@@ -314,7 +313,6 @@ lib/util/unlinkat.c
lib/util/util.exp.in
lib/util/utimens.c
lib/util/uuid.c
lib/util/vsyslog.c
lib/zlib/Makefile.in
lib/zlib/adler32.c
lib/zlib/compress.c

View File

@@ -970,9 +970,6 @@
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
/* Define to 1 if you have the `vsyslog' function. */
#undef HAVE_VSYSLOG
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H

27
configure vendored
View File

@@ -21819,33 +21819,6 @@ fi
fi
for ac_func in vsyslog
do :
ac_fn_c_check_func "$LINENO" "vsyslog" "ac_cv_func_vsyslog"
if test "x$ac_cv_func_vsyslog" = xyes
then :
printf "%s\n" "#define HAVE_VSYSLOG 1" >>confdefs.h
else $as_nop
case " $LIBOBJS " in
*" vsyslog.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS vsyslog.$ac_objext"
;;
esac
for _sym in sudo_vsyslog; do
COMPAT_EXP="${COMPAT_EXP}${_sym}
"
done
COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }vsyslog_test"
fi
done
ac_fn_c_check_func "$LINENO" "setpassent" "ac_cv_func_setpassent"
if test "x$ac_cv_func_setpassent" = xyes
then :

View File

@@ -2863,11 +2863,6 @@ AC_CHECK_MEMBER([struct stat.st_mtim],
[AC_CHECK_MEMBER([struct stat.st_nmtime], AC_DEFINE(HAVE_ST_NMTIME))])
]
)
AC_CHECK_FUNCS([vsyslog], [], [
AC_LIBOBJ(vsyslog)
SUDO_APPEND_COMPAT_EXP(sudo_vsyslog)
COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }vsyslog_test"
])
dnl
dnl 4.4BSD-based systems can force the password or group file to be held open
dnl

View File

@@ -553,11 +553,6 @@ sudo_dso_public void *sudo_reallocarray(void *ptr, size_t nmemb, size_t size);
# undef reallocarray
# define reallocarray(_a, _b, _c) sudo_reallocarray((_a), (_b), (_c))
#endif /* HAVE_REALLOCARRAY */
#ifndef HAVE_VSYSLOG
sudo_dso_public void sudo_vsyslog(int pri, const char *fmt, va_list ap);
# undef vsyslog
# define vsyslog(_a, _b, _c) sudo_vsyslog((_a), (_b), (_c))
#endif /* HAVE_VSYSLOG */
#ifndef HAVE_DUP3
sudo_dso_public int sudo_dup3(int oldd, int newd, int flags);
# undef dup3

View File

@@ -176,8 +176,6 @@ GETGROUPLIST_TEST_OBJS = getgrouplist_test.lo getgrouplist.lo
STRSIG_TEST_OBJS = strsig_test.lo sig2str.lo str2sig.lo @SIGNAME@
VSYSLOG_TEST_OBJS = vsyslog_test.lo vsyslog.lo
FUZZ_SUDO_CONF_OBJS = fuzz_sudo_conf.lo
FUZZ_SUDO_CONF_CORPUS = $(srcdir)/regress/corpus/seed/sudo_conf/sudo.conf.*
@@ -295,9 +293,6 @@ strtonum_test: $(STRTONUM_TEST_OBJS) libsudo_util.la
strtoid_test: $(STRTOID_TEST_OBJS) libsudo_util.la
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(STRTOID_TEST_OBJS) libsudo_util.la $(ASAN_LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(TEST_LDFLAGS) $(TEST_LIBS)
vsyslog_test: $(VSYSLOG_TEST_OBJS) libsudo_util.la
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(VSYSLOG_TEST_OBJS) libsudo_util.la $(ASAN_LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(TEST_LDFLAGS) $(TEST_LIBS)
fuzz_sudo_conf: $(FUZZ_SUDO_CONF_OBJS) $(LIBFUZZSTUB) libsudo_util.la
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(FUZZ_SUDO_CONF_OBJS) $(ASAN_LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(FUZZ_LDFLAGS) $(FUZZ_LIBS) libsudo_util.la
@@ -434,9 +429,6 @@ check: $(TEST_PROGS) check-fuzzer
rm -f ./progname_test2; ln -s ./progname_test ./progname_test2; \
./progname_test2 || rval=`expr $$rval + $$?`; \
rm -f ./progname_test2; \
if test -f vsyslog_test; then \
./vsyslog_test || rval=`expr $$rval + $$?`; \
fi; \
build_dir=`pwd`; \
cd $(srcdir); \
for dir in sudo_conf sudo_parseln; do \
@@ -1510,21 +1502,3 @@ uuid.i: $(srcdir)/uuid.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
$(CC) -E -o $@ $(CPPFLAGS) $<
uuid.plog: uuid.i
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/uuid.c --i-file $< --output-file $@
vsyslog.lo: $(srcdir)/vsyslog.c $(incdir)/sudo_compat.h $(top_builddir)/config.h
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/vsyslog.c
vsyslog.i: $(srcdir)/vsyslog.c $(incdir)/sudo_compat.h $(top_builddir)/config.h
$(CC) -E -o $@ $(CPPFLAGS) $<
vsyslog.plog: vsyslog.i
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/vsyslog.c --i-file $< --output-file $@
vsyslog_test.lo: $(srcdir)/regress/vsyslog/vsyslog_test.c \
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
$(incdir)/sudo_fatal.h $(incdir)/sudo_plugin.h \
$(incdir)/sudo_util.h $(top_builddir)/config.h
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/regress/vsyslog/vsyslog_test.c
vsyslog_test.i: $(srcdir)/regress/vsyslog/vsyslog_test.c \
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
$(incdir)/sudo_fatal.h $(incdir)/sudo_plugin.h \
$(incdir)/sudo_util.h $(top_builddir)/config.h
$(CC) -E -o $@ $(CPPFLAGS) $<
vsyslog_test.plog: vsyslog_test.i
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/regress/vsyslog/vsyslog_test.c --i-file $< --output-file $@

View File

@@ -1,130 +0,0 @@
/*
* SPDX-License-Identifier: ISC
*
* Copyright (c) 2017-2020 Todd C. Miller <Todd.Miller@sudo.ws>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include "sudo_compat.h"
#include "sudo_fatal.h"
#include "sudo_util.h"
sudo_dso_public int main(int argc, char *argv[]);
/*
* Test that sudo_vsyslog() works as expected.
*/
static char *expected_result;
static int errors;
static int ntests;
/*
* Replacement for syslog(3) that just verifies the message
*/
void
syslog(int priority, const char *fmt, ...)
{
va_list ap;
const char *msg;
if (strcmp(fmt, "%s") != 0)
sudo_fatalx_nodebug("Expected syslog format \"%%s\", got \"%s\"", fmt);
va_start(ap, fmt);
msg = va_arg(ap, char *);
if (strcmp(msg, expected_result) != 0) {
sudo_warnx_nodebug("Expected \"%s\", got \"%s\"", expected_result, msg);
errors++;
} else {
ntests++;
}
va_end(ap);
}
static void
test_vsyslog(int priority, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
sudo_vsyslog(priority, fmt, ap);
va_end(ap);
}
int
main(int argc, char *argv[])
{
int len;
char buf1[1024 * 16], buf2[1024 * 16];
initprogname(argc > 0 ? argv[0] : "vsyslog_test");
/* Test small buffer. */
expected_result = "sudo: millert : TTY=ttypa ; PWD=/etc/mail ; USER=root ; TSID=000AB0 ; COMMAND=/usr/sbin/newaliases";
test_vsyslog(0,
"%s: %s : TTY=%s ; PWD=%s ; USER=%s ; TSID=%s ; COMMAND=%s",
"sudo", "millert", "ttypa", "/etc/mail", "root", "000AB0",
"/usr/sbin/newaliases");
/* Test small buffer w/ errno. */
len = snprintf(buf1, sizeof(buf1),
"unable to open %s: %s", "/var/log/sudo-io/seq", strerror(ENOENT));
if (len < 0 || len >= ssizeof(buf1))
sudo_warnx_nodebug("buf1 truncated at %s:%d", __FILE__, __LINE__);
expected_result = buf1;
errno = ENOENT;
test_vsyslog(0, "unable to open %s: %m", "/var/log/sudo-io/seq");
/* Test large buffer > 8192 bytes. */
memset(buf1, 'a', 8192);
buf1[8192] = '\0';
expected_result = buf1;
test_vsyslog(0, "%s", buf1);
/* Test large buffer w/ errno > 8192 bytes. */
memset(buf1, 'b', 8184);
buf1[8184] = '\0';
len = snprintf(buf2, sizeof(buf2), "%s: %s", buf1, strerror(EINVAL));
if (len < 0 || len >= ssizeof(buf2))
sudo_warnx_nodebug("buf2 truncated at %s:%d", __FILE__, __LINE__);
expected_result = buf2;
errno = EINVAL;
test_vsyslog(0, "%s: %m", buf1);
/* Test large format string > 8192 bytes, expect truncation to 2048. */
memset(buf1, 'b', 8184);
buf1[8184] = '\0';
len = snprintf(buf2, sizeof(buf2), "%.*s", 2047, buf1);
if (len < 0 || len >= ssizeof(buf2))
sudo_warnx_nodebug("buf2 truncated at %s:%d", __FILE__, __LINE__);
expected_result = buf2;
test_vsyslog(0, buf1);
if (ntests != 0) {
printf("%s: %d tests run, %d errors, %d%% success rate\n",
getprogname(), ntests, errors, (ntests - errors) * 100 / ntests);
} else {
printf("%s: error, no tests run!\n", getprogname());
errors = 1;
}
exit(errors);
}

View File

@@ -1,79 +0,0 @@
/*
* SPDX-License-Identifier: ISC
*
* Copyright (c) 2016-2017 Todd C. Miller <Todd.Miller@sudo.ws>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* This is an open source non-commercial project. Dear PVS-Studio, please check it.
* PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
*/
#include <config.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include "sudo_compat.h"
#ifndef HAVE_VSYSLOG
void
sudo_vsyslog(int pri, const char *fmt, va_list ap)
{
int saved_errno = errno;
char *cp, *ep, msgbuf[8192], new_fmt[2048];
va_list ap2;
size_t len;
/* Rewrite fmt, replacing %m with an errno string. */
for (cp = new_fmt, ep = new_fmt + sizeof(new_fmt); *fmt != '\0'; fmt++) {
if (fmt[0] == '%' && fmt[1] == 'm') {
fmt++;
len = strlcpy(cp, strerror(saved_errno), (ep - cp));
if (len >= (size_t)(ep - cp))
len = (size_t)(ep - cp) - 1;
cp += len;
} else {
if (fmt[0] == '%' && fmt[1] == '%') {
fmt++;
if (cp < ep - 1)
*cp++ = '%';
}
if (cp < ep - 1)
*cp++ = *fmt;
}
}
*cp = '\0';
/* Format message and log it, using a static buffer if possible. */
va_copy(ap2, ap);
len = (size_t)vsnprintf(msgbuf, sizeof(msgbuf), new_fmt, ap2);
va_end(ap2);
if (len < sizeof(msgbuf)) {
syslog(pri, "%s", msgbuf);
} else {
/* Too big for static buffer? */
char *buf;
if (vasprintf(&buf, new_fmt, ap) != -1) {
syslog(pri, "%s", buf);
free(buf);
}
}
}
#endif /* HAVE_VSYSLOG */

View File

@@ -116,7 +116,7 @@ sub mkdep {
# XXX - fill in AUTH_OBJS from contents of the auth dir instead
$makefile =~ s:\@AUTH_OBJS\@:afs.lo aix_auth.lo bsdauth.lo dce.lo fwtk.lo getspwuid.lo kerb5.lo pam.lo passwd.lo rfc1938.lo secureware.lo securid5.lo sia.lo:;
$makefile =~ s:\@DIGEST\@:digest.lo digest_openssl.lo digest_gcrypt.lo:;
$makefile =~ s:\@LTLIBOBJS\@:arc4random.lo arc4random_uniform.lo cfmakeraw.lo closefrom.lo dup3.lo explicit_bzero.lo fchmodat.lo freezero.lo fstatat.lo fnmatch.lo getaddrinfo.lo getcwd.lo getentropy.lo getgrouplist.lo getdelim.lo getopt_long.lo getusershell.lo glob.lo inet_ntop_lo inet_pton.lo isblank.lo memrchr.lo mksiglist.lo mksigname.lo mktemp.lo nanosleep.lo openat.lo pipe2.lo pread.lo pwrite.lo pw_dup.lo reallocarray.lo sha2.lo sig2str.lo siglist.lo signame.lo snprintf.lo str2sig.lo strlcat.lo strlcpy.lo strndup.lo strnlen.lo strsignal.lo unlinkat.lo utimens.lo vsyslog.lo:;
$makefile =~ s:\@LTLIBOBJS\@:arc4random.lo arc4random_uniform.lo cfmakeraw.lo closefrom.lo dup3.lo explicit_bzero.lo fchmodat.lo freezero.lo fstatat.lo fnmatch.lo getaddrinfo.lo getcwd.lo getentropy.lo getgrouplist.lo getdelim.lo getopt_long.lo getusershell.lo glob.lo inet_ntop_lo inet_pton.lo isblank.lo memrchr.lo mksiglist.lo mksigname.lo mktemp.lo nanosleep.lo openat.lo pipe2.lo pread.lo pwrite.lo pw_dup.lo reallocarray.lo sha2.lo sig2str.lo siglist.lo signame.lo snprintf.lo str2sig.lo strlcat.lo strlcpy.lo strndup.lo strnlen.lo strsignal.lo unlinkat.lo utimens.lo:;
# Parse OBJS lines
my %objs;