2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

Add check_man script to check for man page warnings.

This commit is contained in:
Todd C. Miller 2025-02-24 20:33:52 -07:00
parent 38c0bdd7ad
commit c2e77b7133
5 changed files with 177 additions and 74 deletions

View File

@ -1279,6 +1279,7 @@ po/zh_CN.mo
po/zh_CN.po po/zh_CN.po
po/zh_TW.mo po/zh_TW.mo
po/zh_TW.po po/zh_TW.po
scripts/check_man.in
scripts/config.guess scripts/config.guess
scripts/config.sub scripts/config.sub
scripts/generate_test_coverage.sh scripts/generate_test_coverage.sh

137
configure vendored
View File

@ -674,6 +674,8 @@ PYTHON
FLEX FLEX
YFLAGS YFLAGS
YACC YACC
NROFFPROG
MANDOCPROG
GROFFPROG GROFFPROG
TRPROG TRPROG
UNAMEPROG UNAMEPROG
@ -17649,16 +17651,19 @@ printf "%s\n" "no" >&6; }
fi fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for mandoc or nroff" >&5 # Extract the first word of "mandoc", so it can be a program name with args.
printf %s "checking for mandoc or nroff... " >&6; } set dummy mandoc; ac_word=$2
if test ${ac_cv_path_NROFF+y} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
printf %s "checking for $ac_word... " >&6; }
if test ${ac_cv_path_MANDOCPROG+y}
then : then :
printf %s "(cached) " >&6 printf %s "(cached) " >&6
else case e in #( else case e in #(
e) e) case $MANDOCPROG in
if test -z "$NROFF"; then [\\/]* | ?:[\\/]*)
ac_path_NROFF_found=false ac_cv_path_MANDOCPROG="$MANDOCPROG" # Let the user override the test with a path.
# Loop through the user's path and test for each of PROGNAME-LIST ;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH for as_dir in $PATH
do do
@ -17668,45 +17673,104 @@ do
*/) ;; */) ;;
*) as_dir=$as_dir/ ;; *) as_dir=$as_dir/ ;;
esac esac
for ac_prog in mandoc nroff
do
for ac_exec_ext in '' $ac_executable_extensions; do for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_NROFF="$as_dir$ac_prog$ac_exec_ext" if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
as_fn_executable_p "$ac_path_NROFF" || continue ac_cv_path_MANDOCPROG="$as_dir$ac_word$ac_exec_ext"
ac_cv_path_NROFF="$ac_path_NROFF" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
$ac_path_NROFF_found && break 3 break 2
done fi
done done
done done
IFS=$as_save_IFS IFS=$as_save_IFS
if test -z "$ac_cv_path_NROFF"; then
ac_cv_path_NROFF=no test -z "$ac_cv_path_MANDOCPROG" && ac_cv_path_MANDOCPROG="mandoc"
fi ;;
else esac ;;
ac_cv_path_NROFF=$NROFF esac
fi fi
MANDOCPROG=$ac_cv_path_MANDOCPROG
if test -n "$MANDOCPROG"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANDOCPROG" >&5
printf "%s\n" "$MANDOCPROG" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
if test "$ac_cv_path_MANDOCPROG" != "mandoc"
then :
ac_cv_path_NROFFPROG="$ac_cv_path_MANDOCPROG"
else case e in #(
e)
# Extract the first word of "nroff", so it can be a program name with args.
set dummy nroff; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
printf %s "checking for $ac_word... " >&6; }
if test ${ac_cv_path_NROFFPROG+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) case $NROFFPROG in
[\\/]* | ?:[\\/]*)
ac_cv_path_NROFFPROG="$NROFFPROG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
case $as_dir in #(((
'') as_dir=./ ;;
*/) ;;
*) as_dir=$as_dir/ ;;
esac
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
ac_cv_path_NROFFPROG="$as_dir$ac_word$ac_exec_ext"
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_NROFFPROG" && ac_cv_path_NROFFPROG="nroff"
;;
esac ;;
esac
fi
NROFFPROG=$ac_cv_path_NROFFPROG
if test -n "$NROFFPROG"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NROFFPROG" >&5
printf "%s\n" "$NROFFPROG" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
;; ;;
esac esac
fi fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_NROFF" >&5 # Check whether nroff supports -mdoc, this may produce incorrect
printf "%s\n" "$ac_cv_path_NROFF" >&6; } # results when cross-compiling.
case "$ac_cv_path_NROFF" in test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE"
*mandoc|no) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which macro set to use for manual pages" >&5
# Prefer mdoc format for mandoc (or when no formatter is present).
: ${MANTYPE='mdoc'}
;;
*)
# Check whether nroff supports -mdoc, this may produce incorrect
# results when cross-compiling.
test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which macro set to use for manual pages" >&5
printf %s "checking which macro set to use for manual pages... " >&6; } printf %s "checking which macro set to use for manual pages... " >&6; }
if test ${sudo_cv_var_mantype+y} if test ${sudo_cv_var_mantype+y}
then : then :
printf %s "(cached) " >&6 printf %s "(cached) " >&6
else case e in #( else case e in #(
e) e)
case "$ac_cv_path_NROFFPROG" in
*mandoc|nroff)
# Prefer mdoc format for mandoc (or when no formatter is present).
sudo_cv_var_mantype="mdoc"
;;
*)
sudo_cv_var_mantype="man" sudo_cv_var_mantype="man"
echo ".Sh NAME" > conftest echo ".Sh NAME" > conftest
echo ".Nm sudo" >> conftest echo ".Nm sudo" >> conftest
@ -17717,15 +17781,15 @@ else case e in #(
sudo_cv_var_mantype="mdoc" sudo_cv_var_mantype="mdoc"
fi fi
rm -f conftest rm -f conftest
;;
esac
;; ;;
esac esac
fi fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_var_mantype" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_var_mantype" >&5
printf "%s\n" "$sudo_cv_var_mantype" >&6; } printf "%s\n" "$sudo_cv_var_mantype" >&6; }
MANTYPE="$sudo_cv_var_mantype" MANTYPE="$sudo_cv_var_mantype"
;;
esac
if test -n "$sudo_cv_prev_host" if test -n "$sudo_cv_prev_host"
then : then :
@ -36485,7 +36549,7 @@ then :
fi fi
ac_config_files="$ac_config_files Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/ssl_compat/Makefile lib/util/Makefile lib/util/regress/harness lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/regress/harness plugins/sudoers/sudoers" ac_config_files="$ac_config_files Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/ssl_compat/Makefile lib/util/Makefile lib/util/regress/harness lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/regress/harness plugins/sudoers/sudoers scripts/check_man"
ac_config_commands="$ac_config_commands harness" ac_config_commands="$ac_config_commands harness"
@ -37518,6 +37582,7 @@ do
"plugins/sudoers/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/Makefile" ;; "plugins/sudoers/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/Makefile" ;;
"plugins/sudoers/regress/harness") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/regress/harness" ;; "plugins/sudoers/regress/harness") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/regress/harness" ;;
"plugins/sudoers/sudoers") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/sudoers" ;; "plugins/sudoers/sudoers") CONFIG_FILES="$CONFIG_FILES plugins/sudoers/sudoers" ;;
"scripts/check_man") CONFIG_FILES="$CONFIG_FILES scripts/check_man" ;;
"harness") CONFIG_COMMANDS="$CONFIG_COMMANDS harness" ;; "harness") CONFIG_COMMANDS="$CONFIG_COMMANDS harness" ;;
*) as_fn_error $? "invalid argument: '$ac_config_target'" "$LINENO" 5;; *) as_fn_error $? "invalid argument: '$ac_config_target'" "$LINENO" 5;;

View File

@ -1727,21 +1727,24 @@ AC_PATH_PROG(SHA1SUM, [sha1sum], [openssl dgst -sha1])
AC_PATH_PROG(UNAMEPROG, [uname], [uname]) AC_PATH_PROG(UNAMEPROG, [uname], [uname])
AC_PATH_PROG(TRPROG, [tr], [tr]) AC_PATH_PROG(TRPROG, [tr], [tr])
AC_PATH_PROG(GROFFPROG, [groff], [groff]) AC_PATH_PROG(GROFFPROG, [groff], [groff])
AC_CACHE_CHECK([for mandoc or nroff], [ac_cv_path_NROFF], [ AC_PATH_PROG(MANDOCPROG, [mandoc], [mandoc])
AC_PATH_PROGS_FEATURE_CHECK([NROFF], [mandoc nroff], [ac_cv_path_NROFF="$ac_path_NROFF"], [ac_cv_path_NROFF=no]) AS_IF([test "$ac_cv_path_MANDOCPROG" != "mandoc"], [
ac_cv_path_NROFFPROG="$ac_cv_path_MANDOCPROG"
], [
AC_PATH_PROG(NROFFPROG, [nroff], [nroff])
]) ])
case "$ac_cv_path_NROFF" in # Check whether nroff supports -mdoc, this may produce incorrect
*mandoc|no) # results when cross-compiling.
# Prefer mdoc format for mandoc (or when no formatter is present). test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE"
: ${MANTYPE='mdoc'} AC_CACHE_CHECK([which macro set to use for manual pages],
;;
*)
# Check whether nroff supports -mdoc, this may produce incorrect
# results when cross-compiling.
test -n "$MANTYPE" && sudo_cv_var_mantype="$MANTYPE"
AC_CACHE_CHECK([which macro set to use for manual pages],
[sudo_cv_var_mantype], [sudo_cv_var_mantype],
[ [
case "$ac_cv_path_NROFFPROG" in
*mandoc|nroff)
# Prefer mdoc format for mandoc (or when no formatter is present).
sudo_cv_var_mantype="mdoc"
;;
*)
sudo_cv_var_mantype="man" sudo_cv_var_mantype="man"
echo ".Sh NAME" > conftest echo ".Sh NAME" > conftest
echo ".Nm sudo" >> conftest echo ".Nm sudo" >> conftest
@ -1752,11 +1755,11 @@ case "$ac_cv_path_NROFF" in
sudo_cv_var_mantype="mdoc" sudo_cv_var_mantype="mdoc"
fi fi
rm -f conftest rm -f conftest
]
)
MANTYPE="$sudo_cv_var_mantype"
;; ;;
esac esac
]
)
MANTYPE="$sudo_cv_var_mantype"
dnl dnl
dnl If a config.cache exists make sure it matches the current host. dnl If a config.cache exists make sure it matches the current host.
@ -4470,7 +4473,7 @@ AS_IF([test X"$INIT_SCRIPT" != X""], [
AC_CONFIG_FILES([etc/init.d/sudo.conf]) AC_CONFIG_FILES([etc/init.d/sudo.conf])
]) ])
AC_CONFIG_FILES([Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/ssl_compat/Makefile lib/util/Makefile lib/util/regress/harness lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/regress/harness plugins/sudoers/sudoers]) AC_CONFIG_FILES([Makefile docs/Makefile examples/Makefile examples/sudoers examples/sudo.conf examples/sudo_logsrvd.conf examples/syslog.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/ssl_compat/Makefile lib/util/Makefile lib/util/regress/harness lib/util/util.exp logsrvd/Makefile src/intercept.exp src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/regress/harness plugins/sudoers/sudoers scripts/check_man])
AC_CONFIG_COMMANDS([harness], [chmod +x lib/util/regress/harness plugins/sudoers/regress/harness]) AC_CONFIG_COMMANDS([harness], [chmod +x lib/util/regress/harness plugins/sudoers/regress/harness])
AC_OUTPUT AC_OUTPUT

View File

@ -32,11 +32,10 @@ scriptdir = $(top_srcdir)/scripts
# Tools to use # Tools to use
SED = @SED@ SED = @SED@
IGOR = igor IGOR = igor
MANDOC = mandoc MANDOC = @MANDOCPROG@
MANCOMPRESS = @MANCOMPRESS@ MANCOMPRESS = @MANCOMPRESS@
MANCOMPRESSEXT = @MANCOMPRESSEXT@ MANCOMPRESSEXT = @MANCOMPRESSEXT@
TR = @TRPROG@ TR = @TRPROG@
GROFF = @GROFFPROG@
# Our install program supports extra flags... # Our install program supports extra flags...
INSTALL = $(SHELL) $(scriptdir)/install-sh -c INSTALL = $(SHELL) $(scriptdir)/install-sh -c
@ -119,21 +118,7 @@ igor:
exit $$rval exit $$rval
lint: all lint: all
@if [ "$(mantype)" != "mdoc" ]; then \ $(SHELL) $(top_builddir)/scripts/check_man $(DOCS)
echo "make lint only supported for mdoc manuals" 1>&2; \
exit 1; \
else \
rval=0; \
for m in $(DOCS); do \
echo $(MANDOC) -Tlint -Wwarning $$m; \
$(MANDOC) -Tlint -Wwarning $$m || rval=`expr $$rval + $$?`; \
if [ -n "$(GROFF)" ]; then \
echo $(GROFF) -mandoc -K utf8 -rF0 -rHY=0 -ww -b -z $$m; \
$(GROFF) -mandoc -K utf8 -rF0 -rHY=0 -ww -b -z $$m || rval=`expr $$rval + $$?`; \
fi; \
done; \
exit $$rval; \
fi
depend: depend:

49
scripts/check_man.in Executable file
View File

@ -0,0 +1,49 @@
#!/bin/sh
MANDOC="@MANDOCPROG@"
GROFF="@GROFFPROG@"
MANTYPE="@MANTYPE@"
EGREP="@EGREP@"
if [ "$MANTYPE" != "mdoc" ]; then
echo "$0 only supports mdoc manuals" 1>&2
exit 1
fi
TFILE=`mktemp -t check_man.XXXXXX` || exit 1
rval=0
while [ $# != 0 ]; do
if [ "$MANDOC" != "mandoc" ]; then
# Ignore OS warning and missing cross-references
$MANDOC -Tlint $1 | $EGREP -v 'STYLE: (operating system explicitly specified|referenced manual not found):' > "$TFILE" 2>&1
if [ -s "$TFILE" ]; then
rval=`expr $rval + 1`
cat "$TFILE"
fi
fi
if [ "$GROFF" != "groff" ]; then
$GROFF -mandoc -K utf8 -rF0 -rHY=0 -rCHECKSTYLE=10 -ww -b -z $1 || \
rval=`expr $rval + $?`
fi
$EGREP '^\.It[ ].*[ ]Ta$' $1 > "$TFILE" 2>&1
if [ -s "$TFILE" ]; then
rval=`expr $rval + 1`
echo "Empty table cell at EOL leads to trailing whitespace:"
cat "$TFILE"
fi
$EGREP '[ ]$' $1 > "$TFILE" 2>&1
if [ -s "$TFILE" ]; then
rval=`expr $rval + 1`
echo "Trailing whitespace:"
cat "$TFILE"
fi
shift
done
rm -f "$TFILE"
exit $rval