Skip to content

Commit

Permalink
Added uncompress+file checks
Browse files Browse the repository at this point in the history
Having an old enough version of "file" and no "uncompress" program
installed can cause rpmbuild as root to crash and mangle rpmdb.

So let's check for uncompress and the version of file, and if the
latter is too old and the former is absent, refuse to build rpm
targets.

Closes: #12071
Closes: #12168

Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
  • Loading branch information
rincebrain committed Jun 1, 2021
1 parent 8d5f211 commit 9396035
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
9 changes: 9 additions & 0 deletions config/rpm.am
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ rpm-local:
"*** re-run configure, and try again.\n"; \
exit 1; \
fi; \
if test "0${FILE_MAJOR}" -eq "5" -a "0${FILE_MINOR}" -lt "37"; then \
if test "${HAVE_UNCOMPRESS}" = "no"; then \
echo -e "\n" \
"*** Required util ${UNCOMPRESS} missing. Please install the\n" \
"*** package for your distribution which provides ${UNCOMPRESS},\n" \
"*** re-run configure, and try again.\n"; \
exit 1; \
fi; \
fi; \
mkdir -p $(rpmbuild)/TMP && \
mkdir -p $(rpmbuild)/BUILD && \
mkdir -p $(rpmbuild)/RPMS && \
Expand Down
23 changes: 23 additions & 0 deletions config/zfs-build.m4
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ dnl #
AC_DEFUN([ZFS_AC_RPM], [
RPM=rpm
RPMBUILD=rpmbuild
UNCOMPRESS=uncompress
FILE=file
AC_MSG_CHECKING([whether $RPM is available])
AS_IF([tmp=$($RPM --version 2>/dev/null)], [
Expand All @@ -298,6 +300,21 @@ AC_DEFUN([ZFS_AC_RPM], [
AC_MSG_RESULT([$HAVE_RPMBUILD])
])
AC_MSG_CHECKING([whether $UNCOMPRESS is available])
AS_IF([$(which $UNCOMPRESS >/dev/null 2>/dev/null)], [
HAVE_UNCOMPRESS=yes
AC_MSG_RESULT([$HAVE_UNCOMPRESS])
],[
HAVE_UNCOMPRESS=no
AC_MSG_RESULT([$HAVE_UNCOMPRESS])
])
AC_MSG_CHECKING([what version $FILE is])
FILE_VERSION=$($FILE -v | head -n 1 | $EGREP -o '[[0-9.]]+')
FILE_MAJOR=$(echo $FILE_VERSION | $AWK -F'.' '{ print $[1] }')
FILE_MINOR=$(echo $FILE_VERSION | $AWK -F'.' '{ print $[2] }')
AC_MSG_RESULT([$FILE_VERSION])
RPM_DEFINE_COMMON='--define "$(DEBUG_ZFS) 1"'
RPM_DEFINE_COMMON=${RPM_DEFINE_COMMON}' --define "$(DEBUGINFO_ZFS) 1"'
RPM_DEFINE_COMMON=${RPM_DEFINE_COMMON}' --define "$(DEBUG_KMEM_ZFS) 1"'
Expand Down Expand Up @@ -375,6 +392,12 @@ AC_DEFUN([ZFS_AC_RPM], [
AC_SUBST(RPMBUILD)
AC_SUBST(RPMBUILD_VERSION)
AC_SUBST(UNCOMPRESS)
AC_SUBST(HAVE_UNCOMPRESS)
AC_SUBST(FILE_MAJOR)
AC_SUBST(FILE_MINOR)
AC_SUBST(RPM_SPEC_DIR)
AC_SUBST(RPM_DEFINE_UTIL)
AC_SUBST(RPM_DEFINE_KMOD)
Expand Down
7 changes: 7 additions & 0 deletions rpm/generic/zfs-dkms.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ Obsoletes: spl-dkms
Provides: %{module}-kmod = %{version}
AutoReqProv: no

%if (0 < 0%{?fedora} && 0%{?fedora} <= 30) || (0 < 0%{?rhel} && 0%{?rhel} <= 9) || (0 < 0%{?centos} && 0%{?centos} <= 9)
# We don't need it, but if this isn't installed, rpmbuild as root can
# crash+corrupt rpmdb
# See issue #12071
BuildRequires: ncompress
%endif

%description
This package contains the dkms ZFS kernel modules.

Expand Down
7 changes: 7 additions & 0 deletions rpm/generic/zfs-kmod.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ BuildRequires: gcc, make
BuildRequires: elfutils-libelf-devel
%endif

%if (0 < 0%{?fedora} && 0%{?fedora} <= 30) || (0 < 0%{?rhel} && 0%{?rhel} <= 9) || (0 < 0%{?centos} && 0%{?centos} <= 9)
# We don't need it, but if this isn't installed, rpmbuild as root can
# crash+corrupt rpmdb
# See issue #12071
BuildRequires: ncompress
%endif

# The developments headers will conflict with the dkms packages.
Conflicts: %{module}-dkms

Expand Down
7 changes: 7 additions & 0 deletions rpm/generic/zfs.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ BuildRequires: openssl-devel
%if 0%{?fedora} >= 28 || 0%{?rhel} >= 8 || 0%{?centos} >= 8
BuildRequires: libtirpc-devel
%endif
%if (0 < 0%{?fedora} && 0%{?fedora} <= 30) || (0 < 0%{?rhel} && 0%{?rhel} <= 9) || (0 < 0%{?centos} && 0%{?centos} <= 9)
# We don't need it, but if this isn't installed, rpmbuild as root can
# crash+corrupt rpmdb
# See issue #12071
BuildRequires: ncompress
%endif

Requires: openssl
%if 0%{?_systemd}
BuildRequires: systemd
Expand Down

0 comments on commit 9396035

Please sign in to comment.