From f1ed1a2dff39c731d7a9ff5bba90b6e5e792d897 Mon Sep 17 00:00:00 2001 From: kamil Date: Mon, 11 Mar 2019 16:27:03 +0000 Subject: [PATCH] net/openrsync: import openrsync-0.20190221 Implementation of rsync with a BSD (ISC) license. --- net/openrsync/DESCR | 1 + net/openrsync/Makefile | 19 ++++ net/openrsync/PLIST | 5 ++ net/openrsync/distinfo | 11 +++ net/openrsync/patches/patch-Makefile | 32 +++++++ net/openrsync/patches/patch-extern.h | 19 ++++ net/openrsync/patches/patch-pledge.c | 15 ++++ net/openrsync/patches/patch-recallocarray.c | 99 +++++++++++++++++++++ net/openrsync/patches/patch-unveil.c | 15 ++++ 9 files changed, 216 insertions(+) create mode 100644 net/openrsync/DESCR create mode 100644 net/openrsync/Makefile create mode 100644 net/openrsync/PLIST create mode 100644 net/openrsync/distinfo create mode 100644 net/openrsync/patches/patch-Makefile create mode 100644 net/openrsync/patches/patch-extern.h create mode 100644 net/openrsync/patches/patch-pledge.c create mode 100644 net/openrsync/patches/patch-recallocarray.c create mode 100644 net/openrsync/patches/patch-unveil.c diff --git a/net/openrsync/DESCR b/net/openrsync/DESCR new file mode 100644 index 000000000000..dccaaa50a0db --- /dev/null +++ b/net/openrsync/DESCR @@ -0,0 +1 @@ +Implementation of rsync with a BSD (ISC) license. diff --git a/net/openrsync/Makefile b/net/openrsync/Makefile new file mode 100644 index 000000000000..0d9451f4c4ea --- /dev/null +++ b/net/openrsync/Makefile @@ -0,0 +1,19 @@ +# $NetBSD: Makefile,v 1.1 2019/03/11 16:27:03 kamil Exp $ + +GITHUB_PROJECT= openrsync +GITHUB_TAG= f18392f58d1f0bc72917e3ac3a46be74c194688d +DISTNAME= openrsync-0.20190221 +CATEGORIES= net +MASTER_SITES= ${MASTER_SITE_GITHUB:=kristapsdz/} + +MAINTAINER= pkgsrc-users@NetBSD.org +HOMEPAGE= https://github.com/kristapsdz/openrsync +COMMENT= BSD-licensed implementation of rsync +LICENSE= isc + +WRKSRC= ${WRKDIR}/openrsync-${GITHUB_TAG} + +INSTALL_MAKE_FLAGS+= PREFIX=${PREFIX} +INSTALL_MAKE_FLAGS+= MANDIR=${PREFIX}/${PKGMANDIR} + +.include "../../mk/bsd.pkg.mk" diff --git a/net/openrsync/PLIST b/net/openrsync/PLIST new file mode 100644 index 000000000000..6a5b909b51f1 --- /dev/null +++ b/net/openrsync/PLIST @@ -0,0 +1,5 @@ +@comment $NetBSD: PLIST,v 1.1 2019/03/11 16:27:03 kamil Exp $ +bin/openrsync +man/man1/openrsync.1 +man/man5/rsync.5 +man/man5/rsyncd.5 diff --git a/net/openrsync/distinfo b/net/openrsync/distinfo new file mode 100644 index 000000000000..1ebd3c01612f --- /dev/null +++ b/net/openrsync/distinfo @@ -0,0 +1,11 @@ +$NetBSD: distinfo,v 1.1 2019/03/11 16:27:03 kamil Exp $ + +SHA1 (openrsync-0.20190221-f18392f58d1f0bc72917e3ac3a46be74c194688d.tar.gz) = 5439cc9d8854c36fc7f7cc2db49d5ced4d73f4a5 +RMD160 (openrsync-0.20190221-f18392f58d1f0bc72917e3ac3a46be74c194688d.tar.gz) = d6fd986bbec6c01a5967ab5083a409c1373302e4 +SHA512 (openrsync-0.20190221-f18392f58d1f0bc72917e3ac3a46be74c194688d.tar.gz) = 4c4a5ddda02e577f812a9832b6afb63104f65f76446037ddb30bf40aa0a269e919e100c7a688b5717ed6a10aa0f7698114e5a77021df2d1deb44b87b9aa36a82 +Size (openrsync-0.20190221-f18392f58d1f0bc72917e3ac3a46be74c194688d.tar.gz) = 73171 bytes +SHA1 (patch-Makefile) = ed03f7c75fb958ffa5cb7b046f1871a74711fce0 +SHA1 (patch-extern.h) = c479848ab9741ad563b715c9f10786b22854766f +SHA1 (patch-pledge.c) = 940beb1c5f339221b0252f6fd228fcf848b51042 +SHA1 (patch-recallocarray.c) = 4ba079d9d368680aff56fc0d4a04fcd6778a3aed +SHA1 (patch-unveil.c) = e40ec3d6cd9e2ff032a9704baaa7da9993351fd1 diff --git a/net/openrsync/patches/patch-Makefile b/net/openrsync/patches/patch-Makefile new file mode 100644 index 000000000000..fddaa478e108 --- /dev/null +++ b/net/openrsync/patches/patch-Makefile @@ -0,0 +1,32 @@ +$NetBSD: patch-Makefile,v 1.1 2019/03/11 16:27:03 kamil Exp $ + +Add fallback files with functions missing on !OpenBSD. +Specify -D_OPENBSD_SOURCE to enable OpenBSD APIs on NetBSD. + +--- Makefile.orig 2019-02-21 15:41:00.000000000 +0000 ++++ Makefile +@@ -12,12 +12,15 @@ OBJS = blocks.o \ + md4.o \ + mkpath.o \ + mktemp.o \ ++ pledge.o \ ++ recallocarray.o \ + receiver.o \ + sender.o \ + server.o \ + session.o \ + socket.o \ + symlinks.o \ ++ unveil.o \ + uploader.o + ALLOBJS = $(OBJS) \ + main.o +@@ -27,7 +30,7 @@ MANDIR = $(PREFIX)/man + BINDIR = $(PREFIX)/bin + + # The -O0 is to help with debugging coredumps. +-CFLAGS += -O0 -g -W -Wall -Wextra -Wno-unused-parameter ++CFLAGS += -O0 -g -W -Wall -Wextra -Wno-unused-parameter -D_OPENBSD_SOURCE + + all: openrsync + diff --git a/net/openrsync/patches/patch-extern.h b/net/openrsync/patches/patch-extern.h new file mode 100644 index 000000000000..a9e56646bc75 --- /dev/null +++ b/net/openrsync/patches/patch-extern.h @@ -0,0 +1,19 @@ +$NetBSD: patch-extern.h,v 1.1 2019/03/11 16:27:03 kamil Exp $ + +Add fallback declarations of functions missing on !OpenBSD. + +--- extern.h.orig 2019-02-21 15:41:00.000000000 +0000 ++++ extern.h +@@ -383,6 +383,12 @@ int idents_recv(struct sess *, int, s + void idents_remap(struct sess *, int, struct ident *, size_t); + int idents_send(struct sess *, int, const struct ident *, size_t); + ++#ifndef __OpenBSD__ ++void *recallocarray(void *ptr, size_t oldnmemb, size_t nmemb, size_t size); ++int pledge(const char *promises, const char *execpromises); ++int unveil(const char *path, const char *permissions); ++#endif ++ + __END_DECLS + + #endif /*!EXTERN_H*/ diff --git a/net/openrsync/patches/patch-pledge.c b/net/openrsync/patches/patch-pledge.c new file mode 100644 index 000000000000..2c2d5e9dcf3d --- /dev/null +++ b/net/openrsync/patches/patch-pledge.c @@ -0,0 +1,15 @@ +$NetBSD: patch-pledge.c,v 1.1 2019/03/11 16:27:03 kamil Exp $ + +Add a fallback implementation of OpenBSD specific function. + +--- pledge.c.orig 2019-03-11 16:01:37.907598032 +0000 ++++ pledge.c +@@ -0,0 +1,8 @@ ++#ifndef __OpenBSD__ ++int ++pledge(const char *promises, const char *execpromises) ++{ ++ ++ return 0; ++} ++#endif diff --git a/net/openrsync/patches/patch-recallocarray.c b/net/openrsync/patches/patch-recallocarray.c new file mode 100644 index 000000000000..62fd165bff3a --- /dev/null +++ b/net/openrsync/patches/patch-recallocarray.c @@ -0,0 +1,99 @@ +$NetBSD: patch-recallocarray.c,v 1.1 2019/03/11 16:27:03 kamil Exp $ + +Add a fallback implementation of OpenBSD specific function. + +--- recallocarray.c.orig 2019-03-11 16:01:37.907728248 +0000 ++++ recallocarray.c +@@ -0,0 +1,92 @@ ++#ifndef __OpenBSD__ ++ ++/* $OpenBSD: recallocarray.c,v 1.1 2017/03/06 18:44:21 otto Exp $ */ ++/* ++ * Copyright (c) 2008, 2017 Otto Moerbeek ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++void *(* volatile __internal_explicit_memset_impl)(void *, int, size_t) = memset; ++ ++static void * ++__internal_explicit_bzero(void *b, size_t len) ++{ ++ ++ return (*__internal_explicit_memset_impl)(b, 0, len); ++} ++ ++/* ++ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX ++ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW ++ */ ++#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) ++ ++void * ++recallocarray(void *ptr, size_t oldnmemb, size_t newnmemb, size_t size) ++{ ++ size_t oldsize, newsize; ++ void *newptr; ++ ++ if (ptr == NULL) ++ return calloc(newnmemb, size); ++ ++ if ((newnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && ++ newnmemb > 0 && SIZE_MAX / newnmemb < size) { ++ errno = ENOMEM; ++ return NULL; ++ } ++ newsize = newnmemb * size; ++ ++ if ((oldnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && ++ oldnmemb > 0 && SIZE_MAX / oldnmemb < size) { ++ errno = EINVAL; ++ return NULL; ++ } ++ oldsize = oldnmemb * size; ++ ++ /* ++ * Don't bother too much if we're shrinking just a bit, ++ * we do not shrink for series of small steps, oh well. ++ */ ++ if (newsize <= oldsize) { ++ size_t d = oldsize - newsize; ++ ++ if (d < oldsize / 2 && d < (size_t)getpagesize()) { ++ memset((char *)ptr + newsize, 0, d); ++ return ptr; ++ } ++ } ++ ++ newptr = malloc(newsize); ++ if (newptr == NULL) ++ return NULL; ++ ++ if (newsize > oldsize) { ++ memcpy(newptr, ptr, oldsize); ++ memset((char *)newptr + oldsize, 0, newsize - oldsize); ++ } else ++ memcpy(newptr, ptr, newsize); ++ ++ __internal_explicit_bzero(ptr, oldsize); ++ free(ptr); ++ ++ return newptr; ++} ++#endif diff --git a/net/openrsync/patches/patch-unveil.c b/net/openrsync/patches/patch-unveil.c new file mode 100644 index 000000000000..e79fe22ad870 --- /dev/null +++ b/net/openrsync/patches/patch-unveil.c @@ -0,0 +1,15 @@ +$NetBSD: patch-unveil.c,v 1.1 2019/03/11 16:27:03 kamil Exp $ + +Add a fallback implementation of OpenBSD specific function. + +--- unveil.c.orig 2019-03-11 16:01:37.907822028 +0000 ++++ unveil.c +@@ -0,0 +1,8 @@ ++#ifndef __OpenBSD__ ++int ++unveil(const char *path, const char *permissions) ++{ ++ ++ return 0; ++} ++#endif