summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2022-10-15 15:01:16 +0100
committerColin Watson <cjwatson@debian.org>2022-10-15 15:01:16 +0100
commit175b15a789c92ea810f2d60f51725c44abf31efd (patch)
tree0ee982dbba89377fba8a27aed49df522f64c9c4a /lib
parent8a20bb7f39d2e3d90f2368a2a6b2a1ff8bc5968d (diff)
parentfba1f23672e534ca4bb4d61baf5fb28e9ee5a9da (diff)
Import man-db_2.11.0.orig.tar.xz
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am4
-rw-r--r--lib/Makefile.in53
-rw-r--r--lib/README4
-rw-r--r--lib/appendstr.c2
-rw-r--r--lib/appendstr.h2
-rw-r--r--lib/cleanup.c35
-rw-r--r--lib/cleanup.h6
-rw-r--r--lib/compression.c195
-rw-r--r--lib/compression.h42
-rw-r--r--lib/encodings.c3
-rw-r--r--lib/filenames.c165
-rw-r--r--lib/filenames.h56
-rw-r--r--lib/sandbox.c23
-rw-r--r--lib/security.c2
-rw-r--r--lib/security.h4
-rw-r--r--lib/tempfile.c13
-rw-r--r--lib/util.c3
-rw-r--r--lib/util.h4
18 files changed, 573 insertions, 43 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 49f7809f..8623ea44 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -36,12 +36,16 @@ libman_la_SOURCES = \
appendstr.h \
cleanup.c \
cleanup.h \
+ compression.c \
+ compression.h \
debug.c \
debug.h \
encodings.c \
encodings.h \
fatal.c \
fatal.h \
+ filenames.c \
+ filenames.h \
glcontainers.c \
glcontainers.h \
linelength.c \
diff --git a/lib/Makefile.in b/lib/Makefile.in
index d05eec68..1a54f1a2 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -213,6 +213,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/man-arg-automatic-create.m4 \
$(top_srcdir)/gl/m4/pthread_sigmask.m4 \
$(top_srcdir)/gl/m4/raise.m4 $(top_srcdir)/gl/m4/rawmemchr.m4 \
$(top_srcdir)/gl/m4/readdir.m4 $(top_srcdir)/gl/m4/readlink.m4 \
+ $(top_srcdir)/gl/m4/readlinkat.m4 \
$(top_srcdir)/gl/m4/realloc.m4 \
$(top_srcdir)/gl/m4/reallocarray.m4 \
$(top_srcdir)/gl/m4/regex.m4 $(top_srcdir)/gl/m4/rename.m4 \
@@ -224,8 +225,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/man-arg-automatic-create.m4 \
$(top_srcdir)/gl/m4/sigaction.m4 \
$(top_srcdir)/gl/m4/signal_h.m4 \
$(top_srcdir)/gl/m4/signalblocking.m4 \
- $(top_srcdir)/gl/m4/size_max.m4 $(top_srcdir)/gl/m4/sleep.m4 \
- $(top_srcdir)/gl/m4/socketlib.m4 \
+ $(top_srcdir)/gl/m4/sigpipe.m4 $(top_srcdir)/gl/m4/size_max.m4 \
+ $(top_srcdir)/gl/m4/sleep.m4 $(top_srcdir)/gl/m4/socketlib.m4 \
$(top_srcdir)/gl/m4/sockets.m4 $(top_srcdir)/gl/m4/socklen.m4 \
$(top_srcdir)/gl/m4/ssize_t.m4 \
$(top_srcdir)/gl/m4/stat-time.m4 $(top_srcdir)/gl/m4/stat.m4 \
@@ -233,7 +234,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/man-arg-automatic-create.m4 \
$(top_srcdir)/gl/m4/stdbool.m4 $(top_srcdir)/gl/m4/stddef_h.m4 \
$(top_srcdir)/gl/m4/stdint.m4 $(top_srcdir)/gl/m4/stdint_h.m4 \
$(top_srcdir)/gl/m4/stdio_h.m4 $(top_srcdir)/gl/m4/stdlib_h.m4 \
- $(top_srcdir)/gl/m4/strcase.m4 \
+ $(top_srcdir)/gl/m4/stpcpy.m4 $(top_srcdir)/gl/m4/strcase.m4 \
$(top_srcdir)/gl/m4/strcasestr.m4 \
$(top_srcdir)/gl/m4/strchrnul.m4 $(top_srcdir)/gl/m4/strdup.m4 \
$(top_srcdir)/gl/m4/strerror.m4 \
@@ -252,6 +253,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/man-arg-automatic-create.m4 \
$(top_srcdir)/gl/m4/sys_uio_h.m4 \
$(top_srcdir)/gl/m4/sysexits.m4 \
$(top_srcdir)/gl/m4/tempname.m4 \
+ $(top_srcdir)/gl/m4/termios_h.m4 \
$(top_srcdir)/gl/m4/threadlib.m4 $(top_srcdir)/gl/m4/time_h.m4 \
$(top_srcdir)/gl/m4/timespec.m4 \
$(top_srcdir)/gl/m4/unistd-safer.m4 \
@@ -312,11 +314,12 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)"
LTLIBRARIES = $(pkglib_LTLIBRARIES)
libman_la_DEPENDENCIES = ../gl/lib/libgnu.la $(LTLIBOBJS)
am_libman_la_OBJECTS = libman_la-appendstr.lo libman_la-cleanup.lo \
- libman_la-debug.lo libman_la-encodings.lo libman_la-fatal.lo \
- libman_la-glcontainers.lo libman_la-linelength.lo \
- libman_la-orderfiles.lo libman_la-pathsearch.lo \
- libman_la-sandbox.lo libman_la-security.lo \
- libman_la-tempfile.lo libman_la-util.lo \
+ libman_la-compression.lo libman_la-debug.lo \
+ libman_la-encodings.lo libman_la-fatal.lo \
+ libman_la-filenames.lo libman_la-glcontainers.lo \
+ libman_la-linelength.lo libman_la-orderfiles.lo \
+ libman_la-pathsearch.lo libman_la-sandbox.lo \
+ libman_la-security.lo libman_la-tempfile.lo libman_la-util.lo \
libman_la-wordfnmatch.lo libman_la-xregcomp.lo
libman_la_OBJECTS = $(am_libman_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
@@ -343,9 +346,11 @@ depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/libman_la-appendstr.Plo \
./$(DEPDIR)/libman_la-cleanup.Plo \
+ ./$(DEPDIR)/libman_la-compression.Plo \
./$(DEPDIR)/libman_la-debug.Plo \
./$(DEPDIR)/libman_la-encodings.Plo \
./$(DEPDIR)/libman_la-fatal.Plo \
+ ./$(DEPDIR)/libman_la-filenames.Plo \
./$(DEPDIR)/libman_la-glcontainers.Plo \
./$(DEPDIR)/libman_la-linelength.Plo \
./$(DEPDIR)/libman_la-orderfiles.Plo \
@@ -451,6 +456,7 @@ ERRNO_H = @ERRNO_H@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+FILECMD = @FILECMD@
FLOAT_H = @FLOAT_H@
FNMATCH_H = @FNMATCH_H@
GETOPT_CDEFS_H = @GETOPT_CDEFS_H@
@@ -471,6 +477,7 @@ GL_GNULIB_CALLOC_GNU = @GL_GNULIB_CALLOC_GNU@
GL_GNULIB_CALLOC_POSIX = @GL_GNULIB_CALLOC_POSIX@
GL_GNULIB_CANONICALIZE_FILE_NAME = @GL_GNULIB_CANONICALIZE_FILE_NAME@
GL_GNULIB_CHDIR = @GL_GNULIB_CHDIR@
+GL_GNULIB_CHMOD = @GL_GNULIB_CHMOD@
GL_GNULIB_CHOWN = @GL_GNULIB_CHOWN@
GL_GNULIB_CLOSE = @GL_GNULIB_CLOSE@
GL_GNULIB_CLOSEDIR = @GL_GNULIB_CLOSEDIR@
@@ -762,6 +769,7 @@ GL_GNULIB_STRVERSCMP = @GL_GNULIB_STRVERSCMP@
GL_GNULIB_SYMLINK = @GL_GNULIB_SYMLINK@
GL_GNULIB_SYMLINKAT = @GL_GNULIB_SYMLINKAT@
GL_GNULIB_SYSTEM_POSIX = @GL_GNULIB_SYSTEM_POSIX@
+GL_GNULIB_TCGETSID = @GL_GNULIB_TCGETSID@
GL_GNULIB_TIMEGM = @GL_GNULIB_TIMEGM@
GL_GNULIB_TIMESPEC_GET = @GL_GNULIB_TIMESPEC_GET@
GL_GNULIB_TIMESPEC_GETRES = @GL_GNULIB_TIMESPEC_GETRES@
@@ -890,6 +898,7 @@ HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
HAVE_DECL_STRTOIMAX = @HAVE_DECL_STRTOIMAX@
HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
HAVE_DECL_STRTOUMAX = @HAVE_DECL_STRTOUMAX@
+HAVE_DECL_TCGETSID = @HAVE_DECL_TCGETSID@
HAVE_DECL_TRUNCATE = @HAVE_DECL_TRUNCATE@
HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@
HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@
@@ -1067,6 +1076,7 @@ HAVE_SYS_SOCKET_H = @HAVE_SYS_SOCKET_H@
HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@
HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
HAVE_SYS_UIO_H = @HAVE_SYS_UIO_H@
+HAVE_TERMIOS_H = @HAVE_TERMIOS_H@
HAVE_TIMEGM = @HAVE_TIMEGM@
HAVE_TIMESPEC_GET = @HAVE_TIMESPEC_GET@
HAVE_TIMESPEC_GETRES = @HAVE_TIMESPEC_GETRES@
@@ -1222,6 +1232,7 @@ NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UIO_H@
+NEXT_AS_FIRST_DIRECTIVE_TERMIOS_H = @NEXT_AS_FIRST_DIRECTIVE_TERMIOS_H@
NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
NEXT_AS_FIRST_DIRECTIVE_UTIME_H = @NEXT_AS_FIRST_DIRECTIVE_UTIME_H@
@@ -1257,6 +1268,7 @@ NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@
NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@
NEXT_SYS_UIO_H = @NEXT_SYS_UIO_H@
+NEXT_TERMIOS_H = @NEXT_TERMIOS_H@
NEXT_TIME_H = @NEXT_TIME_H@
NEXT_UNISTD_H = @NEXT_UNISTD_H@
NEXT_UTIME_H = @NEXT_UTIME_H@
@@ -1293,6 +1305,7 @@ REPLACE_BTOWC = @REPLACE_BTOWC@
REPLACE_CALLOC_FOR_CALLOC_GNU = @REPLACE_CALLOC_FOR_CALLOC_GNU@
REPLACE_CALLOC_FOR_CALLOC_POSIX = @REPLACE_CALLOC_FOR_CALLOC_POSIX@
REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHMOD = @REPLACE_CHMOD@
REPLACE_CHOWN = @REPLACE_CHOWN@
REPLACE_CLOSE = @REPLACE_CLOSE@
REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
@@ -1658,12 +1671,16 @@ libman_la_SOURCES = \
appendstr.h \
cleanup.c \
cleanup.h \
+ compression.c \
+ compression.h \
debug.c \
debug.h \
encodings.c \
encodings.h \
fatal.c \
fatal.h \
+ filenames.c \
+ filenames.h \
glcontainers.c \
glcontainers.h \
linelength.c \
@@ -1775,9 +1792,11 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_la-appendstr.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_la-cleanup.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_la-compression.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_la-debug.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_la-encodings.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_la-fatal.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_la-filenames.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_la-glcontainers.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_la-linelength.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_la-orderfiles.Plo@am__quote@ # am--include-marker
@@ -1830,6 +1849,13 @@ libman_la-cleanup.lo: cleanup.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libman_la-cleanup.lo `test -f 'cleanup.c' || echo '$(srcdir)/'`cleanup.c
+libman_la-compression.lo: compression.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libman_la-compression.lo -MD -MP -MF $(DEPDIR)/libman_la-compression.Tpo -c -o libman_la-compression.lo `test -f 'compression.c' || echo '$(srcdir)/'`compression.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libman_la-compression.Tpo $(DEPDIR)/libman_la-compression.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='compression.c' object='libman_la-compression.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libman_la-compression.lo `test -f 'compression.c' || echo '$(srcdir)/'`compression.c
+
libman_la-debug.lo: debug.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libman_la-debug.lo -MD -MP -MF $(DEPDIR)/libman_la-debug.Tpo -c -o libman_la-debug.lo `test -f 'debug.c' || echo '$(srcdir)/'`debug.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libman_la-debug.Tpo $(DEPDIR)/libman_la-debug.Plo
@@ -1851,6 +1877,13 @@ libman_la-fatal.lo: fatal.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libman_la-fatal.lo `test -f 'fatal.c' || echo '$(srcdir)/'`fatal.c
+libman_la-filenames.lo: filenames.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libman_la-filenames.lo -MD -MP -MF $(DEPDIR)/libman_la-filenames.Tpo -c -o libman_la-filenames.lo `test -f 'filenames.c' || echo '$(srcdir)/'`filenames.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libman_la-filenames.Tpo $(DEPDIR)/libman_la-filenames.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='filenames.c' object='libman_la-filenames.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libman_la-filenames.lo `test -f 'filenames.c' || echo '$(srcdir)/'`filenames.c
+
libman_la-glcontainers.lo: glcontainers.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libman_la-glcontainers.lo -MD -MP -MF $(DEPDIR)/libman_la-glcontainers.Tpo -c -o libman_la-glcontainers.lo `test -f 'glcontainers.c' || echo '$(srcdir)/'`glcontainers.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libman_la-glcontainers.Tpo $(DEPDIR)/libman_la-glcontainers.Plo
@@ -2056,9 +2089,11 @@ clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
distclean: distclean-am
-rm -f ./$(DEPDIR)/libman_la-appendstr.Plo
-rm -f ./$(DEPDIR)/libman_la-cleanup.Plo
+ -rm -f ./$(DEPDIR)/libman_la-compression.Plo
-rm -f ./$(DEPDIR)/libman_la-debug.Plo
-rm -f ./$(DEPDIR)/libman_la-encodings.Plo
-rm -f ./$(DEPDIR)/libman_la-fatal.Plo
+ -rm -f ./$(DEPDIR)/libman_la-filenames.Plo
-rm -f ./$(DEPDIR)/libman_la-glcontainers.Plo
-rm -f ./$(DEPDIR)/libman_la-linelength.Plo
-rm -f ./$(DEPDIR)/libman_la-orderfiles.Plo
@@ -2116,9 +2151,11 @@ installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/libman_la-appendstr.Plo
-rm -f ./$(DEPDIR)/libman_la-cleanup.Plo
+ -rm -f ./$(DEPDIR)/libman_la-compression.Plo
-rm -f ./$(DEPDIR)/libman_la-debug.Plo
-rm -f ./$(DEPDIR)/libman_la-encodings.Plo
-rm -f ./$(DEPDIR)/libman_la-fatal.Plo
+ -rm -f ./$(DEPDIR)/libman_la-filenames.Plo
-rm -f ./$(DEPDIR)/libman_la-glcontainers.Plo
-rm -f ./$(DEPDIR)/libman_la-linelength.Plo
-rm -f ./$(DEPDIR)/libman_la-orderfiles.Plo
diff --git a/lib/README b/lib/README
index 3055cf5b..6a991200 100644
--- a/lib/README
+++ b/lib/README
@@ -2,10 +2,12 @@ These library source files have various authors and specific licenses,
but may all be used as part of a complete work that is distributed under
the terms of the GNU General Public License version 2 or later.
-See the files ../COPYING and ../COPYING.LIB for relevant information.
+See the files ../docs/COPYING.GPLv2 and ../docs/COPYING.LIB for relevant
+information.
appendstr.* author - Markus Armbruster
cleanup.* author - Markus Armbruster, Colin Watson
+compression.* author - Wilf., Colin Watson
debug.* author - Colin Watson
encodings.* author - Colin Watson
glcontainers.* author - Colin Watson
diff --git a/lib/appendstr.c b/lib/appendstr.c
index 21cdae1f..3be8bff4 100644
--- a/lib/appendstr.c
+++ b/lib/appendstr.c
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING.LIB. If not, write
+ along with this program; see the file docs/COPYING.LIB. If not, write
to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
02139, USA. */
diff --git a/lib/appendstr.h b/lib/appendstr.h
index 30b18b81..9875faa1 100644
--- a/lib/appendstr.h
+++ b/lib/appendstr.h
@@ -14,7 +14,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING.LIB. If not, write
+ * along with this program; see the file docs/COPYING.LIB. If not, write
* to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
* 02139, USA.
*/
diff --git a/lib/cleanup.c b/lib/cleanup.c
index b122de82..42b603b0 100644
--- a/lib/cleanup.c
+++ b/lib/cleanup.c
@@ -14,7 +14,7 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; see the file COPYING.LIB. If not,
+ * License along with this library; see the file docs/COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
* Floor, Boston, MA 02110-1301 USA.
*/
@@ -23,6 +23,7 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
+#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h> /* SunOS's loosing assert.h needs it */
#include <assert.h>
@@ -41,7 +42,9 @@
/* saved signal actions */
+#ifdef SIGHUP
static struct sigaction saved_hup_action;
+#endif /* SIGHUP */
static struct sigaction saved_int_action;
static struct sigaction saved_term_action;
@@ -53,7 +56,7 @@ sighandler (int signo)
struct sigaction act;
sigset_t set;
- do_cleanups_sigsafe (1);
+ do_cleanups_sigsafe (true);
/* set default signal action */
memset (&act, 0, sizeof act);
@@ -107,9 +110,13 @@ trap_signal (int signo, struct sigaction *oldact)
static int
trap_abnormal_exits (void)
{
- if ( trap_signal (SIGHUP, &saved_hup_action)
- || trap_signal (SIGINT, &saved_int_action)
- || trap_signal (SIGTERM, &saved_term_action))
+#ifdef SIGHUP
+ if (trap_signal (SIGHUP, &saved_hup_action))
+ return -1;
+#endif /* SIGHUP */
+ if (trap_signal (SIGINT, &saved_int_action))
+ return -1;
+ if (trap_signal (SIGTERM, &saved_term_action))
return -1;
return 0;
}
@@ -137,9 +144,13 @@ untrap_signal (int signo, struct sigaction *oldact)
static int
untrap_abnormal_exits (void)
{
- if ( untrap_signal (SIGHUP, &saved_hup_action)
- | untrap_signal (SIGINT, &saved_int_action)
- | untrap_signal (SIGTERM, &saved_term_action))
+#ifdef SIGHUP
+ if (untrap_signal (SIGHUP, &saved_hup_action))
+ return -1;
+#endif /* SIGHUP */
+ if (untrap_signal (SIGINT, &saved_int_action))
+ return -1;
+ if (untrap_signal (SIGTERM, &saved_term_action))
return -1;
return 0;
}
@@ -164,7 +175,7 @@ static unsigned tos = 0; /* top of stack, 0 <= tos <= nslots */
* called.
*/
void
-do_cleanups_sigsafe (int in_sighandler)
+do_cleanups_sigsafe (bool in_sighandler)
{
unsigned i;
@@ -180,7 +191,7 @@ do_cleanups_sigsafe (int in_sighandler)
void
do_cleanups (void)
{
- do_cleanups_sigsafe (0);
+ do_cleanups_sigsafe (false);
tos = 0;
nslots = 0;
free (stack);
@@ -197,14 +208,14 @@ do_cleanups (void)
int
push_cleanup (cleanup_fun fun, void *arg, int sigsafe)
{
- static int handler_installed = 0;
+ static bool handler_installed = false;
assert (tos <= nslots);
if (!handler_installed) {
if (atexit (do_cleanups))
return -1;
- handler_installed = 1;
+ handler_installed = true;
}
if (tos == nslots) {
diff --git a/lib/cleanup.h b/lib/cleanup.h
index 555900db..5415b7f1 100644
--- a/lib/cleanup.h
+++ b/lib/cleanup.h
@@ -14,7 +14,7 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; see the file COPYING.LIB. If not,
+ * License along with this library; see the file docs/COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
* Floor, Boston, MA 02110-1301 USA.
*/
@@ -22,9 +22,11 @@
#ifndef _CLEANUP_H
#define _CLEANUP_H
+#include <stdbool.h>
+
typedef void (*cleanup_fun) (void *);
-extern void do_cleanups_sigsafe (int);
+extern void do_cleanups_sigsafe (bool);
extern void do_cleanups (void);
extern int push_cleanup (cleanup_fun, void *, int);
extern void pop_cleanup (cleanup_fun, void *);
diff --git a/lib/compression.c b/lib/compression.c
new file mode 100644
index 00000000..fe4696c0
--- /dev/null
+++ b/lib/compression.c
@@ -0,0 +1,195 @@
+/*
+ * compression.c: code to find decompressor / compression extension
+ *
+ * Copyright (C) 1994, 1995 Graeme W. Wilford. (Wilf.)
+ * Copyright (C) 2001-2022 Colin Watson.
+ *
+ * This file is part of man-db.
+ *
+ * man-db is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * man-db is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with man-db; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Sat Aug 20 15:01:02 BST 1994 Wilf. (G.Wilford@ee.surrey.ac.uk)
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <assert.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "error.h"
+#include "xstrndup.h"
+#include "xvasprintf.h"
+
+#include "manconfig.h"
+
+#include "appendstr.h"
+#include "compression.h"
+
+/*--------------------------------------------------------------------------*/
+/* This is where we define the decompressors used to decompress any nroff */
+/* source that we find. All cat pages are compressed with either gzip (if */
+/* available) or compress. This is not the place to define _the_ cat page */
+/* decompressor - see ./manconfig.h for that. */
+/* */
+/* To add a decompressor all you need to know is its name (preferrably its */
+/* location), and the unique extension that it gives to files compressed */
+/* with it. Here is an example. You have a compressor named foobar and */
+/* compressed files have an extension of .fb . It is located in /usr/bin */
+/* and requires a -d option to be used as a decompressor. Add the following */
+/* line to the structure below. */
+/* */
+/* {"/usr/bin/foobar -d", "fb", NULL}, */
+/*--------------------------------------------------------------------------*/
+
+struct compression comp_list[] = {
+
+/* If we have gzip, incorporate the following */
+#ifdef HAVE_GZIP
+ {PROG_GUNZIP, "gz", NULL},
+ {PROG_GUNZIP, "z", NULL},
+#endif /* HAVE_GZIP */
+
+/* If we have compress, incorporate the following */
+#ifdef HAVE_COMPRESS
+ {PROG_UNCOMPRESS, "Z", NULL},
+/* Else if we have gzip, incorporate the following */
+#elif defined (HAVE_GZIP)
+ {PROG_GUNZIP, "Z", NULL},
+#endif /* HAVE_COMPRESS || HAVE_GZIP */
+
+/* If we have bzip2, incorporate the following */
+#ifdef HAVE_BZIP2
+ {PROG_BUNZIP2, "bz2", NULL},
+#endif /* HAVE_BZIP2 */
+
+/* If we have xz, incorporate the following */
+#ifdef HAVE_XZ
+ {PROG_UNXZ, "xz", NULL},
+ {PROG_UNXZ, "lzma", NULL},
+/* Else if we have lzma, incorporate the following */
+#elif defined (HAVE_LZMA)
+ {PROG_UNLZMA, "lzma", NULL},
+#endif /* HAVE_XZ || HAVE_LZMA */
+
+/* If we have lzip, incorporate the following */
+#ifdef HAVE_LZIP
+ {PROG_UNLZIP, "lz", NULL},
+#endif /* HAVE_LZIP */
+
+/* If we have zstd, incorporate the following */
+#ifdef HAVE_ZSTD
+ {PROG_UNZSTD, "zst", NULL},
+ {PROG_UNZSTD, "zstd", NULL},
+#endif /* HAVE_ZSTD */
+
+/*------------------------------------------------------*/
+/* Add your decompressor(s) and extension(s) below here */
+/*------------------------------------------------------*/
+
+/*----------------*/
+/* and above here */
+/*----------------*/
+
+/* ... and the last structure is */
+ {NULL, NULL, NULL}
+};
+
+/* Take filename as arg, return structure containing decompressor
+ and extension, or NULL if no comp extension found.
+ If want_stem, set comp->stem to the filename without extension, which
+ the caller should free.
+
+ eg.
+ filename = /usr/man/man1/foo.1.gz
+
+ comp->prog = "/usr/bin/gzip -dc";
+ comp->ext = "gz";
+ comp->stem = "/usr/man/man1/foo.1";
+ */
+struct compression *comp_info (const char *filename, bool want_stem)
+{
+ const char *ext;
+ static struct compression hpux_comp =
+ {PROG_GUNZIP " -S \"\"", "", NULL};
+
+ ext = strrchr (filename, '.');
+
+ if (ext) {
+ struct compression *comp;
+ for (comp = comp_list; comp->ext; comp++) {
+ if (strcmp (comp->ext, ext + 1) == 0) {
+ if (want_stem)
+ comp->stem = xstrndup (filename,
+ ext - filename);
+ else
+ comp->stem = NULL;
+ return comp;
+ }
+ }
+ }
+
+ if (*PROG_GUNZIP) {
+ ext = strstr (filename, ".Z/");
+ if (ext) {
+ if (want_stem)
+ hpux_comp.stem = xstrndup (filename,
+ ext - filename);
+ else
+ hpux_comp.stem = NULL;
+ return &hpux_comp;
+ }
+ }
+
+ return NULL;
+}
+
+/* take filename w/o comp ext. as arg, return comp->stem as a relative
+ compressed file or NULL if none found */
+struct compression *comp_file (const char *filename)
+{
+ size_t len;
+ char *compfile;
+ struct compression *comp;
+
+ compfile = xasprintf ("%s.", filename);
+ assert (compfile);
+ len = strlen (compfile);
+
+ for (comp = comp_list; comp->ext; comp++) {
+ struct stat buf;
+
+ compfile = appendstr (compfile, comp->ext, (void *) 0);
+
+ if (stat (compfile, &buf) == 0) {
+ comp->stem = compfile;
+ return comp;
+ }
+
+ *(compfile + len) = '\0';
+ }
+ free (compfile);
+ return NULL;
+}
diff --git a/lib/compression.h b/lib/compression.h
new file mode 100644
index 00000000..52ede354
--- /dev/null
+++ b/lib/compression.h
@@ -0,0 +1,42 @@
+/*
+ * compression.h: interface to finding decompressor / compression extension
+ *
+ * Copyright (C) 1994, 1995 Graeme W. Wilford. (Wilf.)
+ * Copyright (C) 2001-2022 Colin Watson.
+ *
+ * This file is part of man-db.
+ *
+ * man-db is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * man-db is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with man-db; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdbool.h>
+
+struct compression {
+ /* The following are const because they should be pointers to parts
+ * of strings allocated elsewhere and should not be written through
+ * or freed themselves.
+ */
+ const char *prog;
+ const char *ext;
+ /* The following should be freed when discarding an instance of this
+ * structure.
+ */
+ char *stem;
+};
+
+extern struct compression comp_list[];
+
+extern struct compression *comp_info (const char *filename, bool want_stem);
+extern struct compression *comp_file (const char *filename);
diff --git a/lib/encodings.c b/lib/encodings.c
index 1f8dae10..68c06c65 100644
--- a/lib/encodings.c
+++ b/lib/encodings.c
@@ -590,7 +590,8 @@ out:
/* Can we take this input encoding and produce this output encoding, perhaps
* with the help of some iconv pipes? */
-static bool compatible_encodings (const char *input, const char *output)
+static bool ATTRIBUTE_PURE compatible_encodings (const char *input,
+ const char *output)
{
if (STREQ (input, output))
return true;
diff --git a/lib/filenames.c b/lib/filenames.c
new file mode 100644
index 00000000..5e592c39
--- /dev/null
+++ b/lib/filenames.c
@@ -0,0 +1,165 @@
+/*
+ * filenames.c: compose and dissect man page file names
+ *
+ * Copyright (C) 1994, 1995 Graeme W. Wilford. (Wilf.)
+ * Copyright (C) 2001, 2002 Colin Watson.
+ *
+ * This file is part of man-db.
+ *
+ * man-db is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * man-db is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with man-db; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "dirname.h"
+#include "error.h"
+#include "xalloc.h"
+#include "xvasprintf.h"
+
+#include "gettext.h"
+#define _(String) gettext (String)
+
+#include "manconfig.h"
+
+#include "appendstr.h"
+#include "compression.h"
+#include "debug.h"
+#include "filenames.h"
+
+static void gripe_bogus_manpage (const char *manpage)
+{
+ error (0, 0, _("warning: %s: ignoring bogus filename"), manpage);
+}
+
+char *make_filename (const char *path, const char *name,
+ struct mandata *in, const char *type)
+{
+ static char *file;
+
+ if (!name)
+ name = in->name; /* comes from dblookup(), so non-NULL */
+
+ file = xasprintf ("%s/%s%s/%s.%s", path, type, in->sec, name, in->ext);
+
+ if (in->comp && *in->comp != '-') /* Is there an extension? */
+ file = appendstr (file, ".", in->comp, (void *) 0);
+
+ debug ("Checking physical location: %s\n", file);
+ if (!CAN_ACCESS (file, R_OK)) {
+ free (file);
+ return NULL;
+ }
+
+ return file;
+}
+
+/* Fill in a mandata structure with information about a file name.
+ * file is the name to examine. info points to the structure to be filled
+ * in.
+ *
+ * Returns either a pointer to the buffer which the fields in info point
+ * into, to be freed by the caller, or NULL on error. The buffer will
+ * contain either three or four null-terminated strings: the directory name,
+ * the base of the file name in that directory, the section extension, and
+ * optionally the compression extension.
+ *
+ * Only the fields name, ext, sec, and comp are filled in by this function.
+ */
+struct mandata *filename_info (const char *file, bool warn_if_bogus)
+{
+ struct mandata *info;
+ char *basename, *dirname;
+ struct compression *comp;
+
+ info = XZALLOC (struct mandata);
+
+ basename = base_name (file);
+
+ /* Bogus files either have (i) no period, ie no extension, (ii)
+ a compression extension, but no sectional extension, (iii)
+ a missmatch between the section they are under and the
+ sectional part of their extension. */
+
+ comp = comp_info (basename, true);
+ if (comp) {
+ info->comp = xstrdup (comp->ext);
+ *(basename + strlen (comp->stem)) = '\0';
+ free (comp->stem);
+ } else
+ info->comp = NULL;
+
+ {
+ char *ext = strrchr (basename, '.');
+ if (!ext) {
+ /* no section extension */
+ if (warn_if_bogus)
+ gripe_bogus_manpage (file);
+ free (basename);
+ free_mandata_struct (info);
+ return NULL;
+ }
+ *ext++ = '\0'; /* set section ext */
+ info->ext = xstrdup (ext);
+ if (!*info->ext) {
+ /* zero-length section extension */
+ if (warn_if_bogus)
+ gripe_bogus_manpage (file);
+ free (basename);
+ free_mandata_struct (info);
+ return NULL;
+ }
+ }
+
+ /* Set section name. */
+ dirname = dir_name (file);
+ info->sec = xstrdup (strrchr (dirname, '/') + 4);
+ free (dirname);
+
+ if (strlen (info->sec) >= 1 && strlen (info->ext) >= 1 &&
+ info->sec[0] != info->ext[0]) {
+ /* mismatch in section */
+ if (warn_if_bogus)
+ gripe_bogus_manpage (file);
+ free (basename);
+ free_mandata_struct (info);
+ return NULL;
+ }
+
+ info->name = xstrdup (basename);
+
+ return info;
+}
+
+/* Free a mandata structure and its elements. */
+void free_mandata_struct (struct mandata *pinfo)
+{
+ if (pinfo) {
+ free (pinfo->name);
+ free (pinfo->ext);
+ free (pinfo->sec);
+ free (pinfo->pointer);
+ free (pinfo->comp);
+ free (pinfo->filter);
+ free (pinfo->whatis);
+ }
+ free (pinfo);
+}
diff --git a/lib/filenames.h b/lib/filenames.h
new file mode 100644
index 00000000..66bc48aa
--- /dev/null
+++ b/lib/filenames.h
@@ -0,0 +1,56 @@
+/*
+ * filenames.h: Interface to composing and dissecting man page file names
+ *
+ * Copyright (C) 2001-2022 Colin Watson.
+ *
+ * This file is part of man-db.
+ *
+ * man-db is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * man-db is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with man-db; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef MAN_FILENAMES_H
+#define MAN_FILENAMES_H
+
+#include <stdbool.h>
+
+#include "timespec.h"
+
+struct mandata {
+ /* Name of page, if not equal to the key. */
+ char *name;
+ /* Filename extension without compression extension. */
+ char *ext;
+ /* Section name/number. */
+ char *sec;
+ /* ID (i.e. type) of this entry. */
+ char id;
+ /* ID-related file pointer. */
+ char *pointer;
+ /* Compression extension. */
+ char *comp;
+ /* Filters needed for the page. */
+ char *filter;
+ /* Whatis description for the page. */
+ char *whatis;
+ /* Modification time for file. */
+ struct timespec mtime;
+};
+
+extern char *make_filename (const char *path, const char *name,
+ struct mandata *in, const char *type);
+extern struct mandata *filename_info (const char *file, bool warn_if_bogus);
+extern void free_mandata_struct (struct mandata *pinfo);
+
+#endif /* MAN_FILENAMES_H */
diff --git a/lib/sandbox.c b/lib/sandbox.c
index bfda5e30..f891e533 100644
--- a/lib/sandbox.c
+++ b/lib/sandbox.c
@@ -83,7 +83,7 @@ struct man_sandbox {
};
#ifdef HAVE_LIBSECCOMP
-static int seccomp_filter_unavailable = 0;
+static bool seccomp_filter_unavailable = false;
static void gripe_seccomp_filter_unavailable (void)
{
@@ -231,7 +231,7 @@ static bool can_load_seccomp (void)
* files. Confining these further requires additional tools that can do
* path-based filtering or similar, such as AppArmor.
*/
-static scmp_filter_ctx make_seccomp_filter (int permissive)
+static scmp_filter_ctx make_seccomp_filter (bool permissive)
{
scmp_filter_ctx ctx;
mode_t mode_mask = S_ISUID | S_ISGID | S_IXUSR | S_IXGRP | S_IXOTH;
@@ -244,7 +244,8 @@ static scmp_filter_ctx make_seccomp_filter (int permissive)
if (!can_load_seccomp ())
return NULL;
- debug ("initialising seccomp filter (permissive: %d)\n", permissive);
+ debug ("initialising seccomp filter (permissive: %d)\n",
+ (int) permissive);
ctx = seccomp_init (SCMP_ACT_ERRNO (ENOSYS));
if (!ctx)
fatal (errno, "can't initialise seccomp filter");
@@ -583,8 +584,8 @@ man_sandbox *sandbox_init (void)
man_sandbox *sandbox = XZALLOC (man_sandbox);
#ifdef HAVE_LIBSECCOMP
- sandbox->ctx = make_seccomp_filter (0);
- sandbox->permissive_ctx = make_seccomp_filter (1);
+ sandbox->ctx = make_seccomp_filter (false);
+ sandbox->permissive_ctx = make_seccomp_filter (true);
#else /* !HAVE_LIBSECCOMP */
sandbox->dummy = 0;
#endif /* HAVE_LIBSECCOMP */
@@ -593,7 +594,7 @@ man_sandbox *sandbox_init (void)
}
#ifdef HAVE_LIBSECCOMP
-static void _sandbox_load (man_sandbox *sandbox, int permissive) {
+static void _sandbox_load (man_sandbox *sandbox, bool permissive) {
if (can_load_seccomp ()) {
scmp_filter_ctx ctx;
@@ -604,7 +605,7 @@ static void _sandbox_load (man_sandbox *sandbox, int permissive) {
if (!ctx)
return;
debug ("loading seccomp filter (permissive: %d)\n",
- permissive);
+ (int) permissive);
if (seccomp_load (ctx) < 0) {
if (errno == EINVAL || errno == EFAULT) {
/* The kernel doesn't give us particularly
@@ -619,7 +620,7 @@ static void _sandbox_load (man_sandbox *sandbox, int permissive) {
*/
gripe_seccomp_filter_unavailable ();
/* Don't try this again. */
- seccomp_filter_unavailable = 1;
+ seccomp_filter_unavailable = true;
} else
fatal (errno, "can't load seccomp filter");
}
@@ -627,7 +628,7 @@ static void _sandbox_load (man_sandbox *sandbox, int permissive) {
}
#else /* !HAVE_LIBSECCOMP */
static void _sandbox_load (man_sandbox *sandbox MAYBE_UNUSED,
- int permissive MAYBE_UNUSED)
+ bool permissive MAYBE_UNUSED)
{
}
#endif /* HAVE_LIBSECCOMP */
@@ -637,7 +638,7 @@ void sandbox_load (void *data)
{
man_sandbox *sandbox = data;
- _sandbox_load (sandbox, 0);
+ _sandbox_load (sandbox, false);
}
/* Enter a sandbox for processing untrusted data, allowing limited file
@@ -647,7 +648,7 @@ void sandbox_load_permissive (void *data)
{
man_sandbox *sandbox = data;
- _sandbox_load (sandbox, 1);
+ _sandbox_load (sandbox, true);
}
/* Free a sandbox for processing untrusted data. */
diff --git a/lib/security.c b/lib/security.c
index ab17da91..92cccc39 100644
--- a/lib/security.c
+++ b/lib/security.c
@@ -140,7 +140,6 @@ void drop_effective_privs (void)
}
priv_drop_count++;
- debug ("++priv_drop_count = %d\n", priv_drop_count);
#endif /* MAN_OWNER */
}
@@ -153,7 +152,6 @@ void regain_effective_privs (void)
#ifdef MAN_OWNER
if (priv_drop_count) {
priv_drop_count--;
- debug ("--priv_drop_count = %d\n", priv_drop_count);
if (priv_drop_count)
return;
}
diff --git a/lib/security.h b/lib/security.h
index fdfadc4d..3edf50b4 100644
--- a/lib/security.h
+++ b/lib/security.h
@@ -23,7 +23,9 @@
*/
#include <stdbool.h>
-#include <pwd.h>
+#ifdef MAN_OWNER
+# include <pwd.h>
+#endif /* MAN_OWNER */
/* security.c */
extern void drop_effective_privs (void);
diff --git a/lib/tempfile.c b/lib/tempfile.c
index f4a291c1..5d8847c6 100644
--- a/lib/tempfile.c
+++ b/lib/tempfile.c
@@ -25,21 +25,32 @@
#endif /* HAVE_CONFIG_H */
#include <assert.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include "attribute.h"
#include "xvasprintf.h"
#include "manconfig.h"
#include "tempfile.h"
+static bool ATTRIBUTE_PURE running_setid (void)
+{
+#ifdef HAVE_GETUID
+ return getuid () != geteuid () || getgid () != getegid ();
+#else /* !HAVE_GETUID */
+ return false;
+#endif /* HAVE_GETUID */
+}
+
static const char *path_search (void)
{
const char *dir = NULL;
- if (getuid () == geteuid () && getgid () == getegid ()) {
+ if (running_setid ()) {
dir = getenv ("TMPDIR");
if (!dir || !CAN_ACCESS (dir, W_OK))
dir = NULL;
diff --git a/lib/util.c b/lib/util.c
index c9c16d1b..28a4487b 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -36,6 +36,7 @@
#endif /* HAVE_CONFIG_H */
#include <assert.h>
+#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@ -154,7 +155,7 @@ char *escape_shell (const char *unesc)
/* Remove a directory and all files in it. Only recurse beyond that if
* RECURSE is set.
*/
-int remove_directory (const char *directory, int recurse)
+int remove_directory (const char *directory, bool recurse)
{
DIR *handle = opendir (directory);
struct dirent *entry;
diff --git a/lib/util.h b/lib/util.h
index 48c98440..aec8d179 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -22,10 +22,12 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdbool.h>
+
extern int is_changed (const char *fa, const char *fb);
extern int is_directory (const char *path);
extern char *escape_shell (const char *unesc);
-extern int remove_directory (const char *directory, int recurse);
+extern int remove_directory (const char *directory, bool recurse);
extern char *trim_spaces (const char *s);
extern char *lang_dir (const char *filename);
extern void init_locale (void);