Compared to md5(1) with [-h hashfile], xxhsum(1) has no option to write
to anything but standard output.
Dropping "rpath" later can be done, but needs more patching and testing.
Works for me, tests pass.
Feedback? Objcetion? OK?
Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/xxhash/Makefile,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile
--- Makefile 23 Jul 2023 04:29:44 -0000 1.13
+++ Makefile 17 Aug 2023 01:19:55 -0000
@@ -4,18 +4,20 @@ GH_ACCOUNT = Cyan4973
GH_PROJECT = xxHash
GH_TAGNAME = v0.8.2
PKGNAME = ${DISTNAME:L}
+REVISION = 0
SHARED_LIBS = xxhash 0.3 # 0.8.1
CATEGORIES = sysutils
-HOMEPAGE = https://cyan4973.github.io/xxHash/
+HOMEPAGE = https://xxhash.com
MAINTAINER = Bjorn Ketelaars <[email protected]>
# BSD 2-Clause
PERMIT_PACKAGE = Yes
+# uses pledge()
WANTLIB = c
MAKE_FLAGS = CC="${CC}" \
Index: patches/patch-cli_xsum_os_specific_c
===================================================================
RCS file: patches/patch-cli_xsum_os_specific_c
diff -N patches/patch-cli_xsum_os_specific_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-cli_xsum_os_specific_c 17 Aug 2023 01:41:40 -0000
@@ -0,0 +1,27 @@
+Use pledge(2), xxhsum(1) only ever reads files or stdin.
+
+Index: cli/xsum_os_specific.c
+--- cli/xsum_os_specific.c.orig
++++ cli/xsum_os_specific.c
+@@ -69,6 +69,9 @@ static int XSUM_IS_CONSOLE(FILE* stdStream)
+ || defined(__DJGPP__) \
+ || defined(__MSYS__) \
+ || defined(__HAIKU__)
++# ifdef __OpenBSD__
++# include <err.h>
++# endif
+ # include <unistd.h> /* isatty */
+ # define XSUM_IS_CONSOLE(stdStream) isatty(fileno(stdStream))
+ #elif defined(MSDOS) || defined(OS2)
+@@ -135,6 +138,11 @@ static int XSUM_stat(const char* infilename, XSUM_stat
+ #ifndef XSUM_NO_MAIN
+ int main(int argc, const char* argv[])
+ {
++#ifdef __OpenBSD__
++ if (pledge("stdio rpath", NULL) == -1)
++ err(1, "pledge");
++#endif
++
+ return XSUM_main(argc, argv);
+ }
+ #endif
Index: patches/patch-tests_sanity_test_c
===================================================================
RCS file: patches/patch-tests_sanity_test_c
diff -N patches/patch-tests_sanity_test_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-tests_sanity_test_c 17 Aug 2023 01:41:40 -0000
@@ -0,0 +1,17 @@
+Use pledge(2), the sanity test does even not read files.
+
+Index: tests/sanity_test.c
+--- tests/sanity_test.c.orig
++++ tests/sanity_test.c
+@@ -639,6 +639,11 @@ int main(int argc, const char* argv[])
+ (void) argc;
+ (void) argv;
+
++#ifdef __OpenBSD__
++ if (pledge("stdio", NULL) == -1)
++ err(1, "pledge");
++#endif
++
+ {
+ /* XXH32 */
+ size_t const n = sizeof(XSUM_XXH32_testdata) /
sizeof(XSUM_XXH32_testdata[0]);