On Thu, Aug 17, 2023 at 02:00:52AM +0000, Klemens Nanni wrote:
> 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?
Rebased after the alignment fix.
No objection from bket.
Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/xxhash/Makefile,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile
--- Makefile 17 Aug 2023 06:44:12 -0000 1.15
+++ Makefile 17 Aug 2023 16:23:55 -0000
@@ -4,20 +4,21 @@ COMMENT = extremely fast non-cryptograph
GH_ACCOUNT = Cyan4973
GH_PROJECT = xxHash
GH_TAGNAME = v0.8.2
-REVISION = 0
+REVISION = 1
PKGNAME = ${DISTNAME:L}
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]);