summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAge
* Use Gnulib raise moduleColin Watson2022-02-08
| | | | | | | This can be made slightly more portable (e.g. to MinGW). * bootstrap.conf (gnulib_modules): Add raise. * lib/cleanup.c (sighandler): Call raise rather than kill.
* Fix building on CygwinColin Watson2022-02-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Achim reported that 2.10.0 no longer builds on Cygwin, while 2.9.4 did. This was magnificently obscure, at least to this Unix-head. Initially it appeared to be an issue with inter-library linking between libman and libmandb, but 2.9.4 relied on that too, just slightly less so. The actual problem was that libman only exported `gl_get_setlocale_null_lock` and not all the other symbols it's supposed to export, which is because that was explicitly marked for export and no other symbols were. Building libman with `-Wl,--export-all-symbols` fixes this; libman is intended as an aggregation of various helper functions, including those from Gnulib, and it doesn't make sense to be especially selective since it's only installed as a private library anyway. (I'm still not exactly sure why 2.9.4 didn't do the same thing, but this seems to be a good enough fix.) * configure.ac: Set LIBMAN_EXPORT_LDFLAGS to '-Wl,--export-all-symbols' when linking with GNU ld on Windows platforms. * lib/Makefile.am (libman_la_LDFLAGS): Add $(LIBMAN_EXPORT_LDFLAGS). * src/Makefile.am (LIBMAN): Remove $(top_builddir)/gl/lib/libgnu.la; as a convenience library, this is already incorporated into libman.la, and specifying it again causes multiple-definition errors on Cygwin. * src/tests/Makefile.am (get_mtime_LDADD): Likewise. * NEWS.md: Document this.
* Remove some unused includesColin Watson2022-02-08
| | | | | | * lib/encodings.c: Remove unused #include "pipeline.h". Explicitly include <stdio.h>, previously included implicitly via "pipeline.h". * lib/security.c, lib/util.c: Remove unused #include "pipeline.h".
* Simplify static analysis of fatal errorsColin Watson2022-01-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The usual idiom for fatal error reporting in man-db is `error (FATAL, ...)` (there are a few cases using different exit codes, but they're less common). Unfortunately, there's no easy way to tell the compiler that this call doesn't return, because `error (0, ...)` *does* return. As a result, some call sites required extra work to give the compiler this information, which can sometimes make a difference to static analysis. To simplify this, add a new `fatal` helper function which always exits `FATAL` (i.e. 2) and never returns. This is declared with `_Noreturn` so that the compiler can straightforwardly know what's going on. * bootstrap.conf (gnulib_modules): Add verror. (XGETTEXT_OPTIONS): Add --flag=fatal:2:c-format. * lib/fatal.c, lib/fatal.h: New files. * lib/Makefile.am (libman_la_SOURCES): Add fatal.c and fatal.h. * src/tests/Makefile.am (AM_CPPFLAGS): Add -I$(top_srcdir)/lib. (get_mtime_LDADD): Add $(top_builddir)/lib/libman.la. * lib/pathsearch.c (pathsearch, directory_on_path): Use fatal. * lib/sandbox.c (can_load_seccomp, make_seccomp_filter, _sandbox_load): Likewise. * lib/security.c (gripe_set_euid): Likewise. * lib/xregcomp.c (xregcomp): Likewise. * libdb/db_lookup.c (gripe_corrupt_data, dblookup_pattern): Likewise. * libdb/db_ver.c (dbver_wr): Likewise. * src/accessdb.c (main): Likewise. * src/catman.c (parse_for_sec): Likewise. * src/check_mandirs.c (chown_if_possible): Likewise. * src/man-recode.c (recode): Likewise. * src/man.c (open_cat_stream, format_display, gripe_converting_name): Likewise. * src/manconv.c (add_output): Likewise. * src/manp.c (add_dir_to_path_list): Likewise. * src/tests/get-mtime.c (main): Likewise. * src/whatis.c (do_apropos): Likewise. * src/zsoelim.l (<so>\"?[^ \t\n\"]+\"?): Likewise. * libdb/db_lookup.c (gripe_corrupt_data, gripe_replace_key): Declare as _Noreturn. * src/accessdb.c (main): Remove now-unnecessary assertion. * src/man.c (gripe_converting_name): Remove now-unnecessary abort.
* docs: Move COPYING and COPYING.LIB to top levelColin Watson2022-01-30
| | | | | | | | | I think people are more likely to expect to find them here - I recently even found myself confused by their previous placement. * docs/COPYING, docs/COPYING.LIB: Move to ... * COPYING, COPYING.LIB: ... here, respectively. * lib/README: Update references.
* Avoid libpipeline linkage in libmanColin Watson2022-01-17
| | | | | | | | | | | | | | | Since it's only used by one function, and not all of man-db's tools need libpipeline in their own right (e.g. accessdb), it seems worth pushing this up a layer. * lib/encodings.c (struct conversion_entry, conversion_table, convert_encoding, check_preprocessor_encoding): Move to ... * src/manconv.c: ... here. * lib/encodings.h (check_preprocessor_encoding): Move to ... * src/manconv.h: ... here. * lib/Makefile.am (libman_la_CPPFLAGS): Remove $(libpipeline_CFLAGS). (libman_la_LDFLAGS): Remove $(libpipeline_LIBS). * src/man-recode.c, src/man.c, src/manconv.c: Include manconv.h.
* Pacify cppcheck in check_preprocessor_encodingColin Watson2022-01-17
| | | | | | | * lib/encoding.c (check_preprocessor_encoding): Explicitly initialize directive_end and ppsearch. If directive is non-NULL by the time these are used then they're always initialized, but cppcheck didn't manage to spot that.
* Move some more declarations out of manconfig.hColin Watson2022-01-16
| | | | | | | | | | | | | | | | Header includes should be in the same translation unit as the code that uses them rather than being ambient across the whole project. * include/manconfig.h: Remove obsolete header comment about program paths. * include/manconfig.h: Remove includes of "xvasprintf.h", <stddef.h>, "xalloc.h", and "xstrndup.h", as well as "struct pipeline" declaration. Update all files that relied on these to include/declare them directly instead as needed. * include/manconfig.h (MAN_DB, mkdbname): Move to ... * libdb/mydbm.h: ... here.
* Move appendstr out of manconfig.hColin Watson2022-01-16
| | | | | | | | | | | * include/manconfig.h (appendstr): Move to ... * lib/appendstr.h: ... here (new file). * lib/Makefile.am (libman_la_SOURCES): Add appendstr.h. * lib/README: Update file names. * lib/appendstr.c, libdb/db_delete.c, src/catman.c, src/check_mandirs.c, src/compression.c, src/filenames.c, src/globbing.c, src/man.c, src/manconv_client.c, src/manconv_main.c, src/manp.c, src/straycats.c, src/whatis.c, src/zsoelim.l: Include appendstr.h.
* Move debug-related declarations out of manconfig.hColin Watson2022-01-16
| | | | | | | | | | | | | | | | | * include/manconfig.h (debug_level, init_debug, debug, debug_error): Move to ... * lib/debug.h: ... here (new file). * lib/Makefile.am (libman_la_SOURCES): Add debug.h. * lib/README: Update file names. * lib/debug.c, lib/encodings.c, lib/sandbox.c, lib/security.c, lib/util.c, libdb/db_btree.c, libdb/db_delete.c, libdb/db_gdbm.c, libdb/db_lookup.c, libdb/db_store.c, libdb/db_ver.c, src/accessdb.c, src/catman.c, src/check_mandirs.c, src/descriptions.c, src/descriptions_store.c, src/filenames.c, src/globbing.c, src/globbing_test.c, src/lexgrog_test.c, src/man-recode.c, src/man.c, src/manconv.c, src/manconv_main.c, src/mandb.c, src/manp.c, src/manpath.c, src/straycats.c, src/ult_src.c, src/whatis.c, src/zsoelim.l, src/zsoelim_main.c: Include debug.h.
* Move create_tempdir out of manconfig.hColin Watson2022-01-16
| | | | | | | * include/manconfig.h (create_tempdir): Move to ... * lib/tempfile.h: ... here (new file). * lib/Makefile.am (libman_la_SOURCES): Add tempfile.h. * lib/tempfile.c, src/man.c: Include tempfile.h.
* Move util.c-related declarations out of manconfig.hColin Watson2022-01-16
| | | | | | | | | | | | * include/manconfig.h (is_changed, is_directory, escape_shell, remove_directory, trim_spaces, lang_dir, init_locale): Move to ... * lib/util.h: ... here (new file). * lib/Makefile.am (libman_la_SOURCES): Add util.h. * lib/util.c, src/accessdb.c, src/catman.c, src/check_mandirs.c, src/descriptions.c, src/globbing.c, src/globbing_test.c, src/lexgrog.l, src/lexgrog_test.c, src/man-recode.c, src/man.c, src/manconv_main.c, src/mandb.c, src/manp.c, src/manpath.c, src/straycats.c, src/whatis.c, src/zsoelim_main.c: Include util.h.
* Fix build system following changes to include/*.hColin Watson2022-01-16
| | | | | | | | | | * Makefile.am (noinst_HEADERS): Add include/comp_src.h and include/manconfig.h. * lib/Makefile.am (libman_la_CPPFLAGS): Replace -I$(top_builddir)/include with -I$(top_srcdir)/include. * libdb/Makefile.am (libmandb_la_CPPFLAGS): Likewise. * src/Makefile.am (AM_CPPFLAGS): Likewise. * src/tests/Makefile.am (AM_CPPFLAGS): Likewise.
* Use MAYBE_UNUSED rather than _GL_UNUSEDColin Watson2022-01-09
| | | | | | | | | | | | | | | | | | | | | | We should be using the public name from Gnulib's `attribute.h`. * lib/orderfiles.c (order_files) [!HAVE_LINUX_FIEMAP_H && !HAVE_POSIX_FADVISE]: Use MAYBE_UNUSED rather than _GL_UNUSED. * lib/sandbox.c (_sandbox_load) [!HAVE_LIBSECCOMP]: Likewise. * lib/security.c (drop_privs): Likewise. * libdb/db_ndbm.c (unsorted_nextkey): Likewise. * src/accessdb.c (help_filter): Likewise. * src/check_mandirs.c (chown_if_possible) [!MAN_OWNER]: Likewise. * src/convert.c (close_conv_to_locale): Likewise. * src/decompress.c (decompress_zlib): Likewise. * src/lexgrog_test.c (help_filter): Likewise. * src/man.c (help_filter, squeeze_blank_lines, disable_hyphenation, disable_justification): Likewise. * src/manconv.c (manconv): Likewise. * src/manp.c (free_config_file): Likewise. * src/tests/fspause.c (main): Likewise. * src/whatis.c (help_filter): Likewise. * src/zsoelim_main.c (parse_opt): Likewise.
* Reduce overhead of MAN_DISABLE_SECCOMP=1Colin Watson2022-01-03
| | | | | | | | | | | | | | | If MAN_DISABLE_SECCOMP=1 is set (or if seccomp is otherwise unavailable), then there's no need to call seccomp_init and friends, which can have significant overhead even if we never actually load the resulting filter. Pointed out by Steinar H. Gunderson in https://bugs.debian.org/1003089. * lib/sandbox.c (make_seccomp_filter): Return NULL early if can_load_seccomp returns false. (_sandbox_load): Return early if the relevant context is NULL. (sandbox_free): Only call seccomp_release if the relevant context is non-NULL.
* Assert that some xasprintf calls return non-NULLColin Watson2022-01-02
| | | | | | | | | | | | | | | | | | | | | | | "gcc -fanalyzer" notices that xasprintf can return NULL in some situations (string length > INT_MAX, invalid format string, or multibyte conversion error), and that we weren't handling this in various cases where we use the return value in contexts that require non-NULL values. The situations seem obscure enough for simple asserts to be appropriate. * lib/pathsearch.c (pathsearch): Assert that xasprintf returns non-NULL. * lib/tempfile.c (create_tempdir): Likewise. * lib/util.c (remove_directory): Likewise. * libdb/db_lookup.c (make_multi_key): Likewise. * libdb/db_store.c (make_content, dbstore): Likewise. * src/check_mandirs.c (add_dir_entries, fix_permissions_tree): Likewise. * src/compression.c (comp_file): Likewise. * src/globbing.c (look_for_file): Likewise. * src/man.c (main): Likewise. * src/mandb.c (mandb, purge_catsubdirs): Likewise. * src/manp.c (pathappend): Likewise. * src/ult_src.c (find_include): Likewise. * src/whatis.c (use_grep): Likewise. * src/zsoelim.l (zsoelim_open_file): Likewise.
* Fix path searching crash if getcwd failsColin Watson2022-01-02
| | | | | | | | | | xgetcwd can return NULL if getcwd returns NULL for reasons other than ENOMEM, so we should handle this. Found by "gcc -fanalyzer". * lib/pathsearch.c (pathsearch, directory_on_path): Emit a fatal error if xgetcwd returns NULL. * po/POTFILES.in: Add lib/pathsearch.c. * NEWS: Document this.
* Fix NULL dereference in get_locale_charset callersColin Watson2022-01-02
| | | | | | | * lib/encodings.c (get_canonical_charset_name): Declare argument and return value as non-NULL. (get_locale_charset): Declare return value as non-NULL. Fall back to "ANSI_X3.4-1968" if locale_charset returned NULL or the empty string.
* Add an SC_ALLOW_PERMISSIVE macroColin Watson2022-01-01
| | | | | | | | This plays slightly better with clang-format. * lib/sandbox.c (SC_ALLOW_PERMISSIVE): New macro. (make_seccomp_filter): Use SC_ALLOW_PERMISSIVE instead of forms such as "if (permissive) SC_ALLOW (name);".
* Use Gnulib attribute.h properlyColin Watson2022-01-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | manconfig.h previously used _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM without first including "stdio.h", which caused build failures. We should be using the public names anyway. * bootstrap.conf (gnulib_modules): Add attribute. * include/manconfig.h.in (create_tempdir, appendstr): Use NODISCARD rather than _GL_ATTRIBUTE_NODISCARD. * include/manconfig.h.in (debug, debug_error): Use ATTRIBUTE_FORMAT rather than _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM. * lib/debug.c (vdebug): Likewise. * include/manconfig.h.in (appendstr): Use ATTRIBUTE_SENTINEL rather than _GL_ATTRIBUTE_SENTINEL. * lib/encodings.c (get_page_encoding): Use ATTRIBUTE_MALLOC rather than _GL_ATTRIBUTE_MALLOC. * lib/util.c (trim_spaces): Likewise. * lib/encodings.c (is_roff_device, get_output_encoding, get_less_charset, get_jless_charset): Use ATTRIBUTE_PURE rather than _GL_ATTRIBUTE_PURE. * lib/glcontainers.c (string_equals, string_hash): Likewise. * lib/security.c (running_setuid): Likewise. * src/manp.c (canonicalized_path_equals, canonicalized_path_hash): Likewise. * src/whatis.c (match): Likewise. * libdb/db_lookup.c (dash_if_unset): Use ATTRIBUTE_CONST rather than _GL_ATTRIBUTE_CONST. * libdb/db_store.c (compare_ids): Likewise.
* Pacify pre-commitColin Watson2022-01-01
| | | | * lib/mp.h: Remove trailing whitespace.
* Simplify interface to container iterator macrosColin Watson2022-01-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Gnulib container iterator macros (GL_LIST_FOREACH_* and GL_MAP_FOREACH_*) have to run code both before and after a chunk of user-supplied code. This previously required a START/END macro pair used something like this: GL_LIST_FOREACH_START (names, name) { ... } GL_LIST_FOREACH_END (names); This doesn't look natural in C, and so it was easy to get it wrong. It's possible to do better, at the cost of some tricky macros. Fortunately, Simon Tatham has already done the hard work in https://www.chiark.greenend.org.uk/~sgtatham/mp/, and the necessary header file is MIT-licensed, so we can incorporate it. Now these iterator macros are used more like this, which is a much more natural C style: GL_LIST_FOREACH (names, name) { ... } * lib/mp.h: New file. * lib/Makefile.am (libman_la_SOURCES): Add mp.h. * lib/README: Add mp.h. Rephrase introductory text about licensing to account for an MIT-licensed file. * lib/glcontainers.h (GL_LIST_FOREACH_START, GL_LIST_FOREACH_END): Rewrite as ... (GL_LIST_FOREACH): ... this. Update all callers. (GL_MAP_FOREACH_START, GL_MAP_FOREACH_END): Rewrite as ... (GL_MAP_FOREACH): ... this. Update all callers. * NEWS, README.md, docs/HACKING: Document C99 compiler requirement.
* Simplify some GCC attribute handlingColin Watson2022-01-01
| | | | | | | | | | | | | * include/manconfig.h.in (ATTRIBUTE_FORMAT_PRINTF, ATTRIBUTE_WARN_UNUSED_RESULT, ATTRIBUTE_SENTINEL): Remove in favour of Gnulib-provided macros. (create_tempdir, appendstr): Use _GL_ATTRIBUTE_NODISCARD rather than ATTRIBUTE_WARN_UNUSED_RESULT. (debug, debug_error): Use _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM rather than ATTRIBUTE_FORMAT_PRINTF. (appendstr): Use _GL_ATTRIBUTE_SENTINEL rather than ATTRIBUTE_SENTINEL. * lib/debug.c (vdebug): Use _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM rather than ATTRIBUTE_FORMAT_PRINTF.
* Introduce pre-commitColin Watson2022-01-01
| | | | | | | | | * .pre-commit-config.yaml: New file. * .gitlab-ci.yml (stages): Add bootstrap. (pre-commit): New job. (bootstrap): Move to bootstrap stage. Remove trailing whitespace from all files.
* Fix gcc -Wzero-length-bounds warningColin Watson2020-08-22
| | | | | * lib/orderfiles.c (order_files): Avoid accessing an element of a zero-length array.
* Allow clock_gettime64; return ENOSYS so libcs can engage fallbacksS. Gilles2020-08-22
| | | | | | | | | | | | | libcs such as musl expect ENOSYS to be returned (not EPERM) in their fallback code, so change the seccomp filter to be more agreeable to them. At the same time, clock_gettime is permitted in the filter, so permit clock_gettime64 as well -- it will be needed by 2038 in any case. * lib/sandbox.c (make_seccomp_filter): Set default action to SCMP_ACT_ERRNO (ENOSYS). Allow clock_gettime64. * NEWS: Document this.
* Adjust encoding declarations when recodingColin Watson2019-09-06
| | | | | | | | | | | | | | | * lib/encodings.c (check_preprocessor_encoding): Return a modified encoding declaration in *modified_line if the new to_encoding and modified_line parameters are non-NULL. * lib/encodings.h (check_preprocessor_encoding): Update prototype. * src/man.c (make_roff_command): Pass NULL as to_encoding and modified_line arguments to check_preprocessor_encoding. * src/manconv.c (manconv): Output a modified encoding declaration if necessary. * src/tests/manconv-coding-tags: Adjust for new expected output. Add a test for the case where the coding tag matches the target encoding. * src/tests/manconv-odd-combinations: Adjust for new expected output. * NEWS: Document this.
* Remove unnecessary PP_COOKIE conditionalsColin Watson2019-09-01
| | | | | | | | | PP_COOKIE is always defined, so there's no need for #ifdefs. * lib/encodings.c (check_preprocessor_encoding): Remove PP_COOKIE conditional. * src/man.c (get_preprocessors_from_file): Likewise. * src/zsoelim.l (zsoelim_parse_file): Likewise.
* Improve list iteration helperColin Watson2019-08-31
| | | | | | | | | | | | | * lib/glcontainers.h (GL_LIST_FOREACH_START): Capture the gl_list_node_t in each loop iteration. * src/descriptions_store.c (store_descriptions): Simplify detection of the last loop iteration. * src/manconv.c (manconv): Likewise. * src/manconv_client.c (add_manconv): Likewise. * src/manp.c (create_pathlist): Simplify manual loop iteration that can now be expressed using GL_LIST_FOREACH_START/GL_LIST_FOREACH_END. Simplify detection of the first loop iteration when emitting the final search path as debugging information.
* Add several function attributes suggested by GCCColin Watson2019-08-25
| | | | | | | | | | | | | * lib/debug.c (vdebug): Mark first argument as a printf format string. * lib/encodings.c (get_page_encoding): Mark as malloc-like. (is_roff_device, get_output_encoding, get_less_charset, get_jless_charset): Mark as pure. * lib/glcontainers.c (string_equals, string_hash): Mark as pure. * lib/security.c (running_setuid): Mark as pure. * lib/util.c (trim_spaces): Mark as malloc-like. * libdb/db_lookup.c (dash_if_unset): Mark as const. * libdb/db_store.c (compare_ids): Mark as const. * src/whatis.c (match): Mark as pure.
* Make a couple of functions staticColin Watson2019-08-25
| | | | | * lib/orderfiles.c (compare_physical_offsets): Make static. * src/descriptions.c (page_description_free): Likewise.
* Add some missing includesColin Watson2019-08-25
| | | | | * lib/linelength.c: Include "linelength.h". * lib/orderfiles.c: Include "orderfiles.h".
* Simplify some GCC attribute handlingColin Watson2019-08-24
| | | | | | | | | | | | | | | | | | | | | * lib/orderfiles.c (order_files) [!HAVE_LINUX_FIEMAP_H && !HAVE_POSIX_FADVISE]: Use _GL_UNUSED rather than ATTRIBUTE_UNUSED. * lib/sandbox.c (_sandbox_load) [!HAVE_LIBSECCOMP]: Likewise. * lib/security.c (drop_privs): Likewise. * src/accessdb.c (help_filter): Likewise. * src/check_mandirs.c (chown_if_possible): Likewise. * src/decompress.c (decompress_zlib): Likewise. * src/lexgrog_test.c (help_filter): Likewise. * src/man.c (help_filter, squeeze_blank_lines, disable_hyphenation, disable_justification): Likewise. * src/manconv.c (manconv): Likewise. * src/manp.c (free_config_file): Likewise. * src/tests/fspause.c (main): Likewise. * src/whatis.c (help_filter): Likewise. * src/zsoelim_main.c (parse_opt): Likewise. * include/manconfig.h.in (ATTRIBUTE_UNUSED): Remove in favour of the shorter _GL_UNUSED. (ATTRIBUTE_MALLOC): Remove; it was unused.
* Use C11/Gnulib's _NoreturnColin Watson2019-08-24
| | | | | | | * lib/cleanup.c (sighandler): Declare as _Noreturn. * src/man.c (gripe_converting_name): Use _Noreturn rather than ATTRIBUTE_NORETURN. * include/manconfig.h.in (ATTRIBUTE_NORETURN): Remove.
* Move decompression code out of libmanColin Watson2019-08-22
| | | | | | | | | | | | | | | | | | | | Fixes Savannah bug #56734. * configure.ac: Remove incorrect Darwin workaround. * lib/decompress.c: Move to ... * src/decompress.c: ... here. * lib/decompress.h: Move to ... * src/decompress.h: ... here. * lib/Makefile.am (libman_la_SOURCES): Remove decompress.c and decompress.h. (libman_la_LIBADD): Remove $(LIBCOMPRESS). * lib/README: Remove decompress.*. * lib/encodings.c: Remove unused #include "decompress.h". * src/Makefile.am (lexgrog_LDADD, man_LDADD, manconv_LDADD, mandb_LDADD, zsoelim_LDADD): Add $(LIBCOMPRESS). (lexgrog_SOURCES, man_SOURCES, manconv_SOURCES, mandb_SOURCES, zsoelim_SOURCES): Add decompress.c and decompress.h. * NEWS: Document this.
* Squash warning in order_files stubColin Watson2019-08-22
| | | | | * lib/orderfiles.c [!HAVE_LINUX_FIEMAP_H && !HAVE_POSIX_FADVISE]: Mark dir and basenamesp arguments as unused.
* sandbox: Allow getrandom, used by Hardened MallocColin Watson2019-08-21
| | | | | | | Fixes Savannah bug #56767. * lib/sandbox.c (make_seccomp_filter): Allow getrandom. * NEWS: Document this.
* sandbox: Reorganise using @system-service setColin Watson2019-08-21
| | | | | | | | | systemd defines a @system-service set now which covers some of the ones that were previously isolated here, so reorganise to take account of that. No functional change. * lib/sandbox.c (make_seccomp_filter): Reorganise using systemd's new @system-service set.
* sandbox: Set default action to EPERM, not TRAPColin Watson2019-08-21
| | | | | | | | | Returning EPERM rather than raising SIGSYS is no less secure, and it's more likely that code injected via LD_PRELOAD will be able to recover from this somehow. * lib/sandbox.c (make_seccomp_filter): Set default action to SCMP_ACT_ERRNO (EPERM), not SCMP_ACT_TRAP.
* sandbox: Allow sendmsg in the ESET caseColin Watson2019-08-14
| | | | | | * lib/sandbox.c (make_seccomp_filter): If libesets_pac.so is preloaded, then allow sendmsg. * NEWS: Document this.
* Update syscall lists from systemd bca5a0eaccColin Watson2019-08-03
| | | | | * lib/sandbox.c (make_seccomp_filter): Add rseq (see https://github.com/systemd/systemd/issues/12127).
* Fix warnings when configuring --without-libseccompColin Watson2019-03-03
| | | | | | * lib/sandbox.c (_sandbox_load): Mark sandbox and permissive parameters unused when HAVE_LIBSECCOMP is undefined, to avoid warnings from "gcc -Wunused-parameter".
* Add some missing entries to lib/READMEColin Watson2019-02-05
| | | | * lib/README: Add glcontainers.*, orderfiles.*, and sandbox.*.
* Remove pipeline.* from lib/READMEColin Watson2019-02-05
| | | | | | It's been a separate library since 2010. * lib/README: Remove pipeline.*.
* Inline lower into name_to_keyColin Watson2019-02-05
| | | | | | | | | With only one remaining user, it wasn't pulling its weight. * libdb/db_lookup.c (name_to_key): Inline the implementation of lower. * lib/Makefile.am (libman_la_SOURCES): Remove lower.c and lower.h. * lib/README: Remove lower.*. * lib/lower.c, lib/lower.h: Remove.
* Simplify case-insensitivity in word_fnmatchColin Watson2019-02-05
| | | | | | | | | | | Using FNM_CASEFOLD saves us from having to lower-case the pattern manually, and it also fixes the behaviour of "apropos -w" when given a non-lower-case pattern. * lib/wordfnmatch.c (word_fnmatch): Use isalpha and FNM_CASEFOLD rather than manually lower-casing string or expecting pattern to have already been lower-cased. * NEWS: Document this.
* Use bool for boolean command-line optionsColin Watson2019-02-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/manconfig.h.in (debug_level): Change type to bool. Update all definitions and users. * lib/encodings.c (get_roff_encoding): Change type of "found" to bool. * libdb/db_lookup.c (dblookup_all, dblookup_exact): Change "match_case" parameter type to bool. Update all callers. (dblookup_pattern): Change "match_case", "pattern_regex", and "try_descriptions" parameter types to bool. Update all callers. * libdb/db_storage.h (dblookup_all, dblookup_exact, dblookup_pattern): Update prototypes. * src/descriptions_store.c (store_descriptions): Change types of "found_real_page" and "found_external" to bool. * src/lexgrog_test.c (main): Change types of "some_failed" and "found" to bool. * src/man.c (parse_opt): Change types of "apropos" and "whatis" to bool. (add_roff_line_length): Change "save_cat_p" parameter type to bool *. Update all callers. (make_browser): Change "found_percent_s" type to bool. (display): Change "display_to_stdout" type to bool. (try_db): Change "found_stale" type to bool. (local_man_loop): Change "local_mf" type to bool. (main): Change "found_subpage" type to bool. * src/manp.c (read_config_file): Change "optional" parameter type to bool. Update all callers. * src/manp.h (read_config_file): Update prototype. * src/check_mandirs.c (opt_test, force_rescan): Change types to bool. Update all users. * src/globbing_test.c (match_case, regex_opt, wildcard): Likewise. * src/lexgrog_test.c (parse_man, parse_cat, show_whatis, show_filters): Likewise. * src/man.c (disable_cache, troff, global_apropos, print_where, print_where_cat, catman, local_man_file, findall, update, match_case, regex_opt, wildcard, names_only, no_hyphenation, no_justification, subpages, ascii, save_cat, ditroff, htmlout): Likewise. * src/mandb.c (opt_test, force_rescan, check_for_strays, purge, user, create): Likewise. * src/manp.c (disable_cache): Likewise. * src/manpath.c (cat, global): Likewise. * src/whatis.c (am_apropos, regex_opt, exact, wildcard, require_all, long_output): Likewise.
* Improve sandbox_freeColin Watson2019-02-04
| | | | * lib/sandbox.c (sandbox_free): Free sandbox->permissive_ctx too.
* Add helper functions for common container casesColin Watson2019-02-03
| | | | | | | | | | | | | | | | | | | | | | | | * lib/glcontainers.c (new_string_list, new_string_map, new_string_set): New functions. * lib/glcontainers.h (new_string_list, new_string_map, new_string_set): Add prototypes. * lib/orderfiles.c (order_files): Use new_string_list. * src/check_mandirs.c (test_manfile, add_dir_entries): Likewise. * src/globbing.c (look_for_file, expand_path): Likewise. * src/man.c (get_section_list): Likewise. * src/manp.c (get_scetions, get_manpath_from_path, create_pathlist): Likewise. * src/straycats.c (check_for_stray): Likewise. * libdb/db_gdbm.c (man_gdbm_firstkey): Use new_string_map. * src/check_mandirs.c (test_manfile): Likewise. * src/globbing.c (update_directory_cache): Likewise. * src/man.c (try_db): Likewise. * src/mandb.c (main): Likewise. * libdb/db_btree.c (btree_findkey): Use new_string_set. * src/whatis.c (main): Likewise.
* Replace hashtable with Gnulib containersColin Watson2019-02-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we're using Gnulib's container types anyway, we might as well reduce the maintenance burden of local code, especially since the result tends to be more concise. * bootstrap.conf (gnulib_modules): Add hash-map, hash-set, xmap, and xset. * lib/glcontainers.h (GL_MAP_FOREACH_START, GL_MAP_FOREACH_END): New macros. * lib/orderfiles.c (compare_physical_offsets, order_files): Convert physical_offsets from a hashtable to a gl_map. * libdb/db_btree.c (loop_check_hash): Rename to ... (loop_check): ... this. (btree_findkey): Convert loop_check from a hashtable to a gl_set. * libdb/db_gdbm.c (parent_sortkey_hash): Rename to ... (parent_keys: ... this. (struct sortkey, parent_sortkey_hashtable_free): Remove. (sortkey_hashtable_free): Rename to ... (datum_free): ... this. Adjust for gl_list's expected interface. (sortkey_compare): Rename to ... (datum_compare): ... this. Adjust for gl_list's expected interface. (datum_equals, datum_hash): New functions. (man_gdbm_firstkey, man_gdbm_nextkey, man_gdbm_close): Convert parent_keys from a hashtable to a gl_map, and convert its values from hashtables with manual linking to gl_lists using a hash for fast lookup by key. * src/check_mandirs.c (whatis_hash): Rename to ... (whatis_map): ... this. (struct whatis_hashent): Rename to ... (struct whatis): ... this. (whatis_hashtable_free): Rename to ... (whatis_free): ... this. Adjust for gl_map's expected interface. (test_manfile): Convert whatis_map from a hashtable to a gl_map. * src/globbing.c (struct dirent_hashent): Rename to ... (struct dirent_names): ... this. (dirent_hashtable_free): Rename to ... (dirent_names_free): ... this. Adjust for gl_map's expected interface. (dirent_hash): Rename to ... (dirent_map): ... this. (update_directory_cache): Convert dirent_map from a hashtable to a gl_map. * src/man.c (db_hash): Rename to ... (db_map): ... this. (db_hashtable_free): Remove. (try_db, main): Convert db_map from a hashtable to a gl_map. * src/mandb.c (process_manpath, tried_catdirs_free, purge_catdir, purge_catdirs, main): Convert tried_catdirs from a hashtable to a gl_map. * src/whatis.c (display, main): Convert display_seen from a hashtable to a gl_set. * lib/Makefile.am (libman_la_SOURCES): Remove hashtable.c and hashtable.h. * lib/README: Remove hashtable.*. * lib/hashtable.c, lib/hashtable.h: Remove.