mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-03 15:55:40 +00:00
Split out log file word wrap code into its own file and add unit
tests. Fixes an off-by one in the word wrap when the log line length matches loglinelen.
This commit is contained in:
4
MANIFEST
4
MANIFEST
@@ -174,6 +174,7 @@ plugins/sudoers/linux_audit.c
|
|||||||
plugins/sudoers/linux_audit.h
|
plugins/sudoers/linux_audit.h
|
||||||
plugins/sudoers/logging.c
|
plugins/sudoers/logging.c
|
||||||
plugins/sudoers/logging.h
|
plugins/sudoers/logging.h
|
||||||
|
plugins/sudoers/logwrap.c
|
||||||
plugins/sudoers/match.c
|
plugins/sudoers/match.c
|
||||||
plugins/sudoers/mkdefaults
|
plugins/sudoers/mkdefaults
|
||||||
plugins/sudoers/parse.c
|
plugins/sudoers/parse.c
|
||||||
@@ -194,6 +195,9 @@ plugins/sudoers/redblack.c
|
|||||||
plugins/sudoers/redblack.h
|
plugins/sudoers/redblack.h
|
||||||
plugins/sudoers/regress/iolog_path/check_iolog_path.c
|
plugins/sudoers/regress/iolog_path/check_iolog_path.c
|
||||||
plugins/sudoers/regress/iolog_path/data
|
plugins/sudoers/regress/iolog_path/data
|
||||||
|
plugins/sudoers/regress/logging/check_wrap.c
|
||||||
|
plugins/sudoers/regress/logging/check_wrap.in
|
||||||
|
plugins/sudoers/regress/logging/check_wrap.out.ok
|
||||||
plugins/sudoers/regress/parser/check_fill.c
|
plugins/sudoers/regress/parser/check_fill.c
|
||||||
plugins/sudoers/regress/sudoers/test1.in
|
plugins/sudoers/regress/sudoers/test1.in
|
||||||
plugins/sudoers/regress/sudoers/test1.out.ok
|
plugins/sudoers/regress/sudoers/test1.out.ok
|
||||||
|
@@ -106,7 +106,7 @@ SHELL = @SHELL@
|
|||||||
|
|
||||||
PROGS = sudoers.la visudo sudoreplay testsudoers
|
PROGS = sudoers.la visudo sudoreplay testsudoers
|
||||||
|
|
||||||
TEST_PROGS = check_iolog_path check_fill
|
TEST_PROGS = check_iolog_path check_fill check_wrap
|
||||||
|
|
||||||
AUTH_OBJS = sudo_auth.lo @AUTH_OBJS@
|
AUTH_OBJS = sudo_auth.lo @AUTH_OBJS@
|
||||||
|
|
||||||
@@ -115,8 +115,8 @@ LIBSUDOERS_OBJS = alias.lo audit.lo defaults.lo gram.lo match.lo pwutil.lo \
|
|||||||
|
|
||||||
SUDOERS_OBJS = $(AUTH_OBJS) boottime.lo check.lo env.lo goodpath.lo \
|
SUDOERS_OBJS = $(AUTH_OBJS) boottime.lo check.lo env.lo goodpath.lo \
|
||||||
group_plugin.lo find_path.lo interfaces.lo logging.lo \
|
group_plugin.lo find_path.lo interfaces.lo logging.lo \
|
||||||
parse.lo set_perms.lo sudoers.lo sudo_nss.lo iolog.lo \
|
logwrap.lo parse.lo set_perms.lo sudoers.lo sudo_nss.lo \
|
||||||
iolog_path.lo @SUDOERS_OBJS@
|
iolog.lo iolog_path.lo @SUDOERS_OBJS@
|
||||||
|
|
||||||
VISUDO_OBJS = visudo.o goodpath.o find_path.o error.o
|
VISUDO_OBJS = visudo.o goodpath.o find_path.o error.o
|
||||||
|
|
||||||
@@ -125,10 +125,12 @@ REPLAY_OBJS = getdate.o sudoreplay.o error.o
|
|||||||
TEST_OBJS = interfaces.o testsudoers.o tsgetgrpw.o error.o group_plugin.o \
|
TEST_OBJS = interfaces.o testsudoers.o tsgetgrpw.o error.o group_plugin.o \
|
||||||
net_ifs.o
|
net_ifs.o
|
||||||
|
|
||||||
CHECK_IOLOG_PATH_OBJS = check_iolog_path.o error.o iolog_path.lo pwutil.lo \
|
CHECK_IOLOG_PATH_OBJS = check_iolog_path.o error.o iolog_path.o pwutil.o \
|
||||||
redblack.lo
|
redblack.o
|
||||||
|
|
||||||
CHECK_FILL_OBJS = check_fill.o toke_util.lo error.o
|
CHECK_FILL_OBJS = check_fill.o toke_util.o error.o
|
||||||
|
|
||||||
|
CHECK_WRAP_OBJS = check_wrap.o logwrap.o error.o
|
||||||
|
|
||||||
LIBOBJDIR = $(top_builddir)/@ac_config_libobj_dir@/
|
LIBOBJDIR = $(top_builddir)/@ac_config_libobj_dir@/
|
||||||
|
|
||||||
@@ -174,6 +176,9 @@ check_iolog_path: $(CHECK_IOLOG_PATH_OBJS) $(LT_LIBS)
|
|||||||
check_fill: $(CHECK_FILL_OBJS) $(LT_LIBS)
|
check_fill: $(CHECK_FILL_OBJS) $(LT_LIBS)
|
||||||
$(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_FILL_OBJS) $(LDFLAGS) $(LIBS)
|
$(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_FILL_OBJS) $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
check_wrap: $(CHECK_WRAP_OBJS) $(LT_LIBS)
|
||||||
|
$(LIBTOOL) --mode=link $(CC) -o $@ $(CHECK_WRAP_OBJS) $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
# Uncomment the following if you want "make distclean" to clean the parser
|
# Uncomment the following if you want "make distclean" to clean the parser
|
||||||
@DEV@GENERATED = gram.h gram.c toke.c def_data.c def_data.h getdate.c
|
@DEV@GENERATED = gram.h gram.c toke.c def_data.c def_data.h getdate.c
|
||||||
|
|
||||||
@@ -256,6 +261,9 @@ check: $(TEST_PROGS) visudo testsudoers
|
|||||||
rval=`expr $$rval + $$?`; \
|
rval=`expr $$rval + $$?`; \
|
||||||
./check_fill; \
|
./check_fill; \
|
||||||
rval=`expr $$rval + $$?`; \
|
rval=`expr $$rval + $$?`; \
|
||||||
|
./check_wrap $(srcdir)/regress/logging/check_wrap.in > check_wrap.out; \
|
||||||
|
diff check_wrap.out $(srcdir)/regress/logging/check_wrap.out.ok; \
|
||||||
|
rval=`expr $$rval + $$?`; \
|
||||||
passed=0; failed=0; total=0; \
|
passed=0; failed=0; total=0; \
|
||||||
for t in $(srcdir)/regress/sudoers/*.in; do \
|
for t in $(srcdir)/regress/sudoers/*.in; do \
|
||||||
dir=`dirname $$t`; \
|
dir=`dirname $$t`; \
|
||||||
@@ -387,6 +395,9 @@ check_iolog_path.o: $(srcdir)/regress/iolog_path/check_iolog_path.c \
|
|||||||
$(srcdir)/sudo_nss.h $(incdir)/sudo_plugin.h \
|
$(srcdir)/sudo_nss.h $(incdir)/sudo_plugin.h \
|
||||||
$(incdir)/gettext.h $(srcdir)/def_data.c
|
$(incdir)/gettext.h $(srcdir)/def_data.c
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/regress/iolog_path/check_iolog_path.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/regress/iolog_path/check_iolog_path.c
|
||||||
|
check_wrap.o: $(srcdir)/regress/logging/check_wrap.c $(top_builddir)/config.h \
|
||||||
|
$(incdir)/missing.h $(incdir)/error.h
|
||||||
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/regress/logging/check_wrap.c
|
||||||
dce.lo: $(authdir)/dce.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
dce.lo: $(authdir)/dce.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
||||||
$(top_builddir)/pathnames.h $(incdir)/missing.h $(incdir)/error.h \
|
$(top_builddir)/pathnames.h $(incdir)/missing.h $(incdir)/error.h \
|
||||||
$(incdir)/alloc.h $(incdir)/list.h $(incdir)/fileops.h \
|
$(incdir)/alloc.h $(incdir)/list.h $(incdir)/fileops.h \
|
||||||
@@ -471,6 +482,7 @@ iolog_path.lo: $(srcdir)/iolog_path.c $(top_builddir)/config.h \
|
|||||||
$(srcdir)/def_data.h $(srcdir)/logging.h $(srcdir)/sudo_nss.h \
|
$(srcdir)/def_data.h $(srcdir)/logging.h $(srcdir)/sudo_nss.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/gettext.h
|
$(incdir)/sudo_plugin.h $(incdir)/gettext.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/iolog_path.c
|
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/iolog_path.c
|
||||||
|
iolog_path.o: iolog_path.lo
|
||||||
kerb4.lo: $(authdir)/kerb4.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
kerb4.lo: $(authdir)/kerb4.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
||||||
$(top_builddir)/pathnames.h $(incdir)/missing.h $(incdir)/error.h \
|
$(top_builddir)/pathnames.h $(incdir)/missing.h $(incdir)/error.h \
|
||||||
$(incdir)/alloc.h $(incdir)/list.h $(incdir)/fileops.h \
|
$(incdir)/alloc.h $(incdir)/list.h $(incdir)/fileops.h \
|
||||||
@@ -500,6 +512,13 @@ logging.lo: $(srcdir)/logging.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
|||||||
$(srcdir)/defaults.h $(srcdir)/def_data.h $(srcdir)/logging.h \
|
$(srcdir)/defaults.h $(srcdir)/def_data.h $(srcdir)/logging.h \
|
||||||
$(srcdir)/sudo_nss.h $(incdir)/sudo_plugin.h $(incdir)/gettext.h
|
$(srcdir)/sudo_nss.h $(incdir)/sudo_plugin.h $(incdir)/gettext.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/logging.c
|
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/logging.c
|
||||||
|
logwrap.lo: $(srcdir)/logwrap.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
||||||
|
$(top_builddir)/pathnames.h $(incdir)/missing.h $(incdir)/error.h \
|
||||||
|
$(incdir)/alloc.h $(incdir)/list.h $(incdir)/fileops.h \
|
||||||
|
$(srcdir)/defaults.h $(srcdir)/def_data.h $(srcdir)/logging.h \
|
||||||
|
$(srcdir)/sudo_nss.h $(incdir)/sudo_plugin.h $(incdir)/gettext.h
|
||||||
|
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/logwrap.c
|
||||||
|
logwrap.o: logwrap.lo
|
||||||
match.lo: $(srcdir)/match.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
match.lo: $(srcdir)/match.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
||||||
$(top_builddir)/pathnames.h $(incdir)/missing.h $(incdir)/error.h \
|
$(top_builddir)/pathnames.h $(incdir)/missing.h $(incdir)/error.h \
|
||||||
$(incdir)/alloc.h $(incdir)/list.h $(incdir)/fileops.h \
|
$(incdir)/alloc.h $(incdir)/list.h $(incdir)/fileops.h \
|
||||||
@@ -542,9 +561,11 @@ pwutil.lo: $(srcdir)/pwutil.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
|||||||
$(srcdir)/sudo_nss.h $(incdir)/sudo_plugin.h $(incdir)/gettext.h \
|
$(srcdir)/sudo_nss.h $(incdir)/sudo_plugin.h $(incdir)/gettext.h \
|
||||||
$(srcdir)/redblack.h
|
$(srcdir)/redblack.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/pwutil.c
|
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/pwutil.c
|
||||||
|
pwutil.o: pwutil.lo
|
||||||
redblack.lo: $(srcdir)/redblack.c $(top_builddir)/config.h $(incdir)/missing.h \
|
redblack.lo: $(srcdir)/redblack.c $(top_builddir)/config.h $(incdir)/missing.h \
|
||||||
$(incdir)/alloc.h $(srcdir)/redblack.h
|
$(incdir)/alloc.h $(srcdir)/redblack.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/redblack.c
|
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/redblack.c
|
||||||
|
redblack.o: redblack.lo
|
||||||
rfc1938.lo: $(authdir)/rfc1938.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
rfc1938.lo: $(authdir)/rfc1938.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
||||||
$(top_builddir)/pathnames.h $(incdir)/missing.h $(incdir)/error.h \
|
$(top_builddir)/pathnames.h $(incdir)/missing.h $(incdir)/error.h \
|
||||||
$(incdir)/alloc.h $(incdir)/list.h $(incdir)/fileops.h \
|
$(incdir)/alloc.h $(incdir)/list.h $(incdir)/fileops.h \
|
||||||
@@ -640,6 +661,7 @@ toke_util.lo: $(srcdir)/toke_util.c $(top_builddir)/config.h \
|
|||||||
$(incdir)/sudo_plugin.h $(incdir)/gettext.h $(srcdir)/parse.h \
|
$(incdir)/sudo_plugin.h $(incdir)/gettext.h $(srcdir)/parse.h \
|
||||||
$(srcdir)/toke.h $(srcdir)/gram.h
|
$(srcdir)/toke.h $(srcdir)/gram.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/toke_util.c
|
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/toke_util.c
|
||||||
|
toke_util.o: toke_util.lo
|
||||||
tsgetgrpw.o: $(srcdir)/tsgetgrpw.c $(top_builddir)/config.h \
|
tsgetgrpw.o: $(srcdir)/tsgetgrpw.c $(top_builddir)/config.h \
|
||||||
$(srcdir)/tsgetgrpw.h $(top_builddir)/config.h \
|
$(srcdir)/tsgetgrpw.h $(top_builddir)/config.h \
|
||||||
$(srcdir)/sudoers.h $(top_builddir)/pathnames.h \
|
$(srcdir)/sudoers.h $(top_builddir)/pathnames.h \
|
||||||
|
@@ -176,19 +176,16 @@ do_syslog(int pri, char *msg)
|
|||||||
#endif /* HAVE_SETLOCALE */
|
#endif /* HAVE_SETLOCALE */
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOG_INDENT " "
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_logfile(char *msg)
|
do_logfile(char *msg)
|
||||||
{
|
{
|
||||||
char *full_line, *beg, *end, *indent = "";
|
char *full_line;
|
||||||
size_t len, maxlen;
|
size_t len;
|
||||||
mode_t oldmask;
|
mode_t oldmask;
|
||||||
time_t now;
|
time_t now;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
oldmask = umask(077);
|
oldmask = umask(077);
|
||||||
maxlen = def_loglinelen > 0 ? def_loglinelen : 0;
|
|
||||||
fp = fopen(def_logfile, "a");
|
fp = fopen(def_logfile, "a");
|
||||||
(void) umask(oldmask);
|
(void) umask(oldmask);
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
@@ -222,32 +219,9 @@ do_logfile(char *msg)
|
|||||||
get_timestr(now, def_log_year), user_name, msg);
|
get_timestr(now, def_log_year), user_name, msg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print out full_line with word wrap around maxlen characters.
|
* Print out full_line with word wrap around def_loglinelen chars.
|
||||||
*/
|
*/
|
||||||
beg = full_line;
|
writeln_wrap(fp, full_line, len, def_loglinelen);
|
||||||
while (len > maxlen) {
|
|
||||||
end = beg + maxlen + 1;
|
|
||||||
while (end != beg && *end != ' ')
|
|
||||||
end--;
|
|
||||||
if (beg == end) {
|
|
||||||
/* Unable to find word break within maxlen, look beyond. */
|
|
||||||
end = strchr(beg + maxlen + 1, ' ');
|
|
||||||
if (end == NULL)
|
|
||||||
break; /* no word break */
|
|
||||||
}
|
|
||||||
fprintf(fp, "%s%.*s\n", indent, (int)(end - beg), beg);
|
|
||||||
while (*end == ' ')
|
|
||||||
end++;
|
|
||||||
len -= (end - beg);
|
|
||||||
beg = end;
|
|
||||||
if (indent[0] == '\0') {
|
|
||||||
indent = LOG_INDENT;
|
|
||||||
maxlen -= sizeof(LOG_INDENT) - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Print remainder, if any. */
|
|
||||||
if (len)
|
|
||||||
fprintf(fp, "%s%s\n", indent, beg);
|
|
||||||
efree(full_line);
|
efree(full_line);
|
||||||
}
|
}
|
||||||
(void) fflush(fp);
|
(void) fflush(fp);
|
||||||
|
@@ -47,11 +47,17 @@
|
|||||||
# define MAXSYSLOGLEN 960
|
# define MAXSYSLOGLEN 960
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Indentation level for file-based logs when word wrap is enabled.
|
||||||
|
*/
|
||||||
|
#define LOG_INDENT " "
|
||||||
|
|
||||||
void audit_success(char *[]);
|
void audit_success(char *[]);
|
||||||
void audit_failure(char *[], char const * const, ...);
|
void audit_failure(char *[], char const * const, ...);
|
||||||
void log_allowed(int);
|
void log_allowed(int);
|
||||||
void log_denial(int, int);
|
void log_denial(int, int);
|
||||||
void log_error(int flags, const char *fmt, ...) __printflike(2, 3);
|
void log_error(int flags, const char *fmt, ...) __printflike(2, 3);
|
||||||
void reapchild(int);
|
void reapchild(int);
|
||||||
|
void writeln_wrap(FILE *fp, char *line, size_t len, size_t maxlen);
|
||||||
|
|
||||||
#endif /* _LOGGING_H */
|
#endif /* _LOGGING_H */
|
||||||
|
103
plugins/sudoers/regress/logging/check_wrap.c
Normal file
103
plugins/sudoers/regress/logging/check_wrap.c
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
|
*
|
||||||
|
* 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 <sys/types.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef STDC_HEADERS
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <stddef.h>
|
||||||
|
#else
|
||||||
|
# ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
# endif
|
||||||
|
#endif /* STDC_HEADERS */
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# if defined(HAVE_MEMORY_H) && !defined(STDC_HEADERS)
|
||||||
|
# include <memory.h>
|
||||||
|
# endif
|
||||||
|
# include <string.h>
|
||||||
|
#endif /* HAVE_STRING_H */
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
# include <strings.h>
|
||||||
|
#endif /* HAVE_STRINGS_H */
|
||||||
|
|
||||||
|
#include "missing.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
|
extern void writeln_wrap(FILE *fp, char *line, size_t len, size_t maxlen);
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "usage: check_wrap inputfile\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
FILE *fp;
|
||||||
|
char *cp, *dash, *line, lines[2][2048];
|
||||||
|
int which = 0;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
usage();
|
||||||
|
|
||||||
|
fp = fopen(argv[1], "r");
|
||||||
|
if (fp == NULL)
|
||||||
|
errorx(1, "unable to open %s", argv[1]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Each test record consists of a log entry on one line and a list of
|
||||||
|
* line lengths to test it with on the next. E.g.
|
||||||
|
*
|
||||||
|
* Jun 30 14:49:51 : millert : TTY=ttypn ; PWD=/usr/src/local/millert/hg/sudo/trunk/plugins/sudoers ; USER=root ; TSID=0004LD ; COMMAND=/usr/local/sbin/visudo
|
||||||
|
* 60-80,40
|
||||||
|
*/
|
||||||
|
while ((line = fgets(lines[which], sizeof(lines[which]), fp)) != NULL) {
|
||||||
|
len = strcspn(line, "\n");
|
||||||
|
line[len] = '\0';
|
||||||
|
|
||||||
|
/* If we read the 2nd line, parse list of line lengths and check. */
|
||||||
|
if (which) {
|
||||||
|
for (cp = strtok(lines[1], ","); cp != NULL; cp = strtok(NULL, ",")) {
|
||||||
|
size_t maxlen;
|
||||||
|
/* May be either a number or a range. */
|
||||||
|
len = maxlen = atoi(cp);
|
||||||
|
dash = strchr(cp, '-');
|
||||||
|
if (dash)
|
||||||
|
maxlen = atoi(dash + 1);
|
||||||
|
while (len <= maxlen) {
|
||||||
|
printf("# word wrap at %d characters\n", (int)len);
|
||||||
|
writeln_wrap(stdout, lines[0], strlen(lines[0]), len);
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
which = !which;
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cleanup(int gotsig)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
4
plugins/sudoers/regress/logging/check_wrap.in
Normal file
4
plugins/sudoers/regress/logging/check_wrap.in
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ; PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
60-80,120,140
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ; PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
60-80,120,140
|
175
plugins/sudoers/regress/logging/check_wrap.out.ok
Normal file
175
plugins/sudoers/regress/logging/check_wrap.out.ok
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
# word wrap at 60 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1
|
||||||
|
; PWD=/home/tu2sp3-a ; USER=root ;
|
||||||
|
COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 61 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1
|
||||||
|
; PWD=/home/tu2sp3-a ; USER=root ;
|
||||||
|
COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 62 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ;
|
||||||
|
COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 63 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ;
|
||||||
|
COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 64 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ;
|
||||||
|
COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 65 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ;
|
||||||
|
COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 66 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ;
|
||||||
|
COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 67 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool
|
||||||
|
list users
|
||||||
|
# word wrap at 68 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool
|
||||||
|
list users
|
||||||
|
# word wrap at 69 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool
|
||||||
|
list users
|
||||||
|
# word wrap at 70 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool
|
||||||
|
list users
|
||||||
|
# word wrap at 71 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool
|
||||||
|
list users
|
||||||
|
# word wrap at 72 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list
|
||||||
|
users
|
||||||
|
# word wrap at 73 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list
|
||||||
|
users
|
||||||
|
# word wrap at 74 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list
|
||||||
|
users
|
||||||
|
# word wrap at 75 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list
|
||||||
|
users
|
||||||
|
# word wrap at 76 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list
|
||||||
|
users
|
||||||
|
# word wrap at 77 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list
|
||||||
|
users
|
||||||
|
# word wrap at 78 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 79 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 80 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ;
|
||||||
|
PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 120 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ; PWD=/home/tu2sp3-a ; USER=root ;
|
||||||
|
COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 140 characters
|
||||||
|
Jul 11 11:30:17 : tu2sp3-a : command not allowed ; TTY=pts/1 ; PWD=/home/tu2sp3-a ; USER=root ; COMMAND=/opt/quest/bin/vastool list users
|
||||||
|
# word wrap at 60 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ;
|
||||||
|
TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 61 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ;
|
||||||
|
TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 62 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ;
|
||||||
|
TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 63 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ;
|
||||||
|
TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 64 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ;
|
||||||
|
TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 65 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ;
|
||||||
|
TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 66 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ;
|
||||||
|
TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 67 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ;
|
||||||
|
TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 68 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ;
|
||||||
|
TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 69 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ;
|
||||||
|
TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 70 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT
|
||||||
|
; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 71 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT
|
||||||
|
; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 72 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ;
|
||||||
|
COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 73 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ;
|
||||||
|
COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 74 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ;
|
||||||
|
COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 75 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ;
|
||||||
|
COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 76 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ;
|
||||||
|
COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 77 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ;
|
||||||
|
COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 78 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ;
|
||||||
|
COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 79 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ;
|
||||||
|
PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ;
|
||||||
|
COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 80 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ; PWD=/usr/src/local/millert/hg/sudo/build
|
||||||
|
; USER=root ; TSID=0004KT ; COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 120 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ; PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ;
|
||||||
|
COMMAND=/bin/rm /root/.bash_profile
|
||||||
|
# word wrap at 140 characters
|
||||||
|
Jun 26 18:00:06 : millert : TTY=ttypm ; PWD=/usr/src/local/millert/hg/sudo/build ; USER=root ; TSID=0004KT ; COMMAND=/bin/rm
|
||||||
|
/root/.bash_profile
|
Reference in New Issue
Block a user