mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-28 12:57:50 +00:00
Create files for check_iolog_plugin in the build dir, not src dir.
This commit is contained in:
parent
9b144069fc
commit
f24dacdee2
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: ISC
|
# SPDX-License-Identifier: ISC
|
||||||
#
|
#
|
||||||
# Copyright (c) 1996, 1998-2005, 2007-2018
|
# Copyright (c) 1996, 1998-2005, 2007-2020
|
||||||
# Todd C. Miller <Todd.Miller@sudo.ws>
|
# Todd C. Miller <Todd.Miller@sudo.ws>
|
||||||
#
|
#
|
||||||
# Permission to use, copy, modify, and distribute this software for any
|
# Permission to use, copy, modify, and distribute this software for any
|
||||||
@ -468,7 +468,8 @@ check: $(TEST_PROGS) visudo testsudoers cvtsudoers
|
|||||||
./check_fill || rval=`expr $$rval + $$?`; \
|
./check_fill || rval=`expr $$rval + $$?`; \
|
||||||
./check_gentime || rval=`expr $$rval + $$?`; \
|
./check_gentime || rval=`expr $$rval + $$?`; \
|
||||||
./check_hexchar || rval=`expr $$rval + $$?`; \
|
./check_hexchar || rval=`expr $$rval + $$?`; \
|
||||||
./check_iolog_plugin $(srcdir)/regress/iolog_plugin/iolog || rval=`expr $$rval + $$?`; \
|
mkdir -p regress/iolog_plugin; \
|
||||||
|
./check_iolog_plugin regress/iolog_plugin/iolog || rval=`expr $$rval + $$?`; \
|
||||||
./check_starttime || rval=`expr $$rval + $$?`; \
|
./check_starttime || rval=`expr $$rval + $$?`; \
|
||||||
if test -f check_symbols; then \
|
if test -f check_symbols; then \
|
||||||
./check_symbols .libs/sudoers.so $(shlib_exp) || rval=`expr $$rval + $$?`; \
|
./check_symbols .libs/sudoers.so $(shlib_exp) || rval=`expr $$rval + $$?`; \
|
||||||
|
@ -81,8 +81,8 @@ sudo_printf_int(int msg_type, const char *fmt, ...)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
validate_iolog_info(const char *log_dir)
|
validate_iolog_info(const char *log_dir, bool legacy)
|
||||||
{
|
{
|
||||||
struct iolog_info *info;
|
struct iolog_info *info;
|
||||||
time_t now;
|
time_t now;
|
||||||
@ -93,33 +93,48 @@ validate_iolog_info(const char *log_dir)
|
|||||||
if ((info = iolog_parse_loginfo(-1, log_dir)) == NULL)
|
if ((info = iolog_parse_loginfo(-1, log_dir)) == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (strcmp(info->cwd, "/") != 0) {
|
if (info->cwd == NULL || strcmp(info->cwd, "/") != 0) {
|
||||||
sudo_warnx("bad cwd: want \"/\", got \"%s\"", info->cwd);
|
sudo_warnx("bad cwd: want \"/\", got \"%s\"",
|
||||||
|
info->cwd ? info->cwd : "NULL");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(info->user, "nobody") != 0) {
|
/* No host in the legacy log file. */
|
||||||
sudo_warnx("bad user: want \"nobody\" got \"%s\"", info->user);
|
if (!legacy) {
|
||||||
|
if (info->host == NULL || strcmp(info->host, "localhost") != 0) {
|
||||||
|
sudo_warnx("bad host: want \"localhost\", got \"%s\"",
|
||||||
|
info->host ? info->host : "NULL");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->user == NULL || strcmp(info->user, "nobody") != 0) {
|
||||||
|
sudo_warnx("bad user: want \"nobody\" got \"%s\"",
|
||||||
|
info->user ? info->user : "NULL");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(info->runas_user, "root") != 0) {
|
if (info->runas_user == NULL || strcmp(info->runas_user, "root") != 0) {
|
||||||
sudo_warnx("bad runas_user: want \"root\" got \"%s\"", info->runas_user);
|
sudo_warnx("bad runas_user: want \"root\" got \"%s\"",
|
||||||
|
info->runas_user ? info->runas_user : "NULL");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* No runas group specified, should be NULL. */
|
||||||
if (info->runas_group != NULL) {
|
if (info->runas_group != NULL) {
|
||||||
sudo_warnx("bad runas_group: want \"\" got \"%s\"", info->runas_user);
|
sudo_warnx("bad runas_group: want \"\" got \"%s\"", info->runas_group);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(info->tty, "/dev/console") != 0) {
|
if (info->tty == NULL || strcmp(info->tty, "/dev/console") != 0) {
|
||||||
sudo_warnx("bad tty: want \"/dev/console\" got \"%s\"", info->tty);
|
sudo_warnx("bad tty: want \"/dev/console\" got \"%s\"",
|
||||||
|
info->tty ? info->tty : "NULL");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(info->cmd, "/usr/bin/id") != 0) {
|
if (info->cmd == NULL || strcmp(info->cmd, "/usr/bin/id") != 0) {
|
||||||
sudo_warnx("bad command: want \"/usr/bin/id\" got \"%s\"", info->cmd);
|
sudo_warnx("bad command: want \"/usr/bin/id\" got \"%s\"",
|
||||||
|
info->cmd ? info->cmd : "NULL");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,6 +226,7 @@ test_endpoints(int *ntests, int *nerrors, const char *iolog_dir, char *envp[])
|
|||||||
"cols=80",
|
"cols=80",
|
||||||
"lines=24",
|
"lines=24",
|
||||||
"cwd=/",
|
"cwd=/",
|
||||||
|
"host=localhost",
|
||||||
"tty=/dev/console",
|
"tty=/dev/console",
|
||||||
"user=nobody",
|
"user=nobody",
|
||||||
NULL
|
NULL
|
||||||
@ -253,9 +269,16 @@ test_endpoints(int *ntests, int *nerrors, const char *iolog_dir, char *envp[])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Validate I/O log info file. */
|
/* Validate I/O log info file (json). */
|
||||||
(*ntests)++;
|
(*ntests)++;
|
||||||
if (!validate_iolog_info(iolog_dir))
|
if (!validate_iolog_info(iolog_dir, false))
|
||||||
|
(*nerrors)++;
|
||||||
|
|
||||||
|
/* Validate I/O log info file (legacy). */
|
||||||
|
snprintf(iolog_path, sizeof(iolog_path), "%s/log.json", iolog_dir);
|
||||||
|
unlink(iolog_path);
|
||||||
|
(*ntests)++;
|
||||||
|
if (!validate_iolog_info(iolog_dir, true))
|
||||||
(*nerrors)++;
|
(*nerrors)++;
|
||||||
|
|
||||||
/* Test log_ttyout endpoint. */
|
/* Test log_ttyout endpoint. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user