Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion build-scripts/detect-environment
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ detect_os()
exit 42;;
esac

export OS OS_VERSION
# Extract major version from OS_VERSION (e.g. 16.04 -> 16, 7.0 -> 7, 10.2.3 -> 10)
if [ -n "$OS_VERSION" ]; then
OS_VERSION_MAJOR="${OS_VERSION%%.*}"
fi

export OS OS_VERSION OS_VERSION_MAJOR
}

detect_distribution()
Expand Down
14 changes: 12 additions & 2 deletions deps-packaging/rsync/cfbuild-rsync.spec
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
%define rsync_version 3.4.2
%define rsync_version 3.4.3

Summary: CFEngine Build Automation -- rsync
Name: cfbuild-rsync
Version: %{version}
Release: 1
Source0: rsync-%{rsync_version}.tar.gz
Patch0: fix-sys-openat2-undeclared.patch
Patch1: fix-missing-openat2-header.patch
License: MIT
Group: Other
Url: https://cfengine.com
Expand All @@ -18,14 +20,22 @@ AutoReqProv: no
mkdir -p %{_builddir}
%setup -q -n rsync-%{rsync_version}

# RHEL/CentOS 7's kernel-headers lack <linux/openat2.h>; inline the header
# there. Other platforms only need the SYS_openat2 fallback.
if { [ "$OS" = rhel ] || [ "$OS" = centos ]; } && [ "$OS_VERSION_MAJOR" = 7 ]; then
patch -p1 < %{_sourcedir}/fix-missing-openat2-header.patch
else
patch -p1 < %{_sourcedir}/fix-sys-openat2-undeclared.patch
fi

# liblz4, libxxhash, libzstd, and libssl give rsync extra compression
# algorithms, extra checksum algorithms, and allow use of openssl's crypto lib
# for (potentially) faster MD4/MD5 checksums.
./configure --prefix=%{prefix} --with-included-zlib=%{prefix} CPPFLAGS="-I%{prefix}/include" --disable-xxhash --disable-zstd --disable-lz4

%build

make
make

%install

Expand Down
8 changes: 8 additions & 0 deletions deps-packaging/rsync/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ build: build-stamp
build-stamp:
dh_testdir

# Ubuntu 20.04's kernel-headers lack <linux/openat2.h>; inline the
# header there. Other platforms only need the SYS_openat2 fallback.
if [ "$$OS" = ubuntu ] && [ "$$OS_VERSION_MAJOR" = 20 ]; then \
patch -p1 < $(CURDIR)/fix-missing-openat2-header.patch; \
else \
patch -p1 < $(CURDIR)/fix-sys-openat2-undeclared.patch; \
fi

# liblz4, libxxhash, libzstd, and libssl give rsync extra compression
# algorithms, extra checksum algorithms, and allow use of openssl's crypto
# lib for (potentially) faster MD4/MD5 checksums.
Expand Down
2 changes: 1 addition & 1 deletion deps-packaging/rsync/distfiles
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ff10aa2c151cd4b2dbbe6135126dbc854046113d2dfb49572a348233267eb315 rsync-3.4.2.tar.gz
c72e63ca3021cbc80ba86ec30102773f4c5631fbc492b52e773b3958f82a53d3 rsync-3.4.3.tar.gz
62 changes: 62 additions & 0 deletions deps-packaging/rsync/fix-missing-openat2-header.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
RHEL 7 and Ubuntu 20.04 ship kernel-headers that lack <linux/openat2.h>
entirely, so rsync 3.4.3's unconditional include fails to compile. Inline the
header verbatim on these platforms. SYS_openat2 (437 on all Linux
architectures) is likewise absent there. On pre-5.6 kernels openat2 returns
ENOSYS and rsync falls back to the portable per-component open.

This patch is applied only on RHEL 7 / Ubuntu 20.04 (see the spec and
debian/rules); other platforms use fix-sys-openat2-undeclared.patch.

--- a/syscall.c
+++ b/syscall.c
@@ -36,4 +36,49 @@
#ifdef __linux__
#include <sys/syscall.h>
-#include <linux/openat2.h>
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _LINUX_OPENAT2_H
+#define _LINUX_OPENAT2_H
+
+#include <linux/types.h>
+
+/*
+ * Arguments for how openat2(2) should open the target path. If only @flags and
+ * @mode are non-zero, then openat2(2) operates very similarly to openat(2).
+ *
+ * However, unlike openat(2), unknown or invalid bits in @flags result in
+ * -EINVAL rather than being silently ignored. @mode must be zero unless one of
+ * {O_CREAT, O_TMPFILE} are set.
+ *
+ * @flags: O_* flags.
+ * @mode: O_CREAT/O_TMPFILE file mode.
+ * @resolve: RESOLVE_* flags.
+ */
+struct open_how {
+ __u64 flags;
+ __u64 mode;
+ __u64 resolve;
+};
+
+/* how->resolve flags for openat2(2). */
+#define RESOLVE_NO_XDEV 0x01 /* Block mount-point crossings
+ (includes bind-mounts). */
+#define RESOLVE_NO_MAGICLINKS 0x02 /* Block traversal through procfs-style
+ "magic-links". */
+#define RESOLVE_NO_SYMLINKS 0x04 /* Block traversal through all symlinks
+ (implies OEXT_NO_MAGICLINKS) */
+#define RESOLVE_BENEATH 0x08 /* Block "lexical" trickery like
+ "..", symlinks, and absolute
+ paths which escape the dirfd. */
+#define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".."
+ be scoped inside the dirfd
+ (similar to chroot(2)). */
+#define RESOLVE_CACHED 0x20 /* Only complete if resolution can be
+ completed through cached lookup. May
+ return -EAGAIN if that's not
+ possible. */
+
+#endif /* _LINUX_OPENAT2_H */
+#ifndef SYS_openat2
+#define SYS_openat2 437
+#endif
#endif
16 changes: 16 additions & 0 deletions deps-packaging/rsync/fix-sys-openat2-undeclared.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Fall back to defining SYS_openat2 when the running kernel-headers don't
export it from <asm/unistd.h>. See https://github.com/RsyncProject/rsync/issues/900.
The syscall number 437 is correct for all Linux architectures.

--- a/syscall.c
+++ b/syscall.c
@@ -37,6 +37,9 @@
#ifdef __linux__
#include <sys/syscall.h>
#include <linux/openat2.h>
+#ifndef SYS_openat2
+#define SYS_openat2 437
+#endif
#endif

#include "ifuncs.h"