From 241f4b274a75cf37bdb1b0658b2bebca4fe61547 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: May 25 2017 13:29:56 +0000 Subject: import rear-1.17.2-9.el7_3 --- diff --git a/SOURCES/0002-Changed-BACKUP_CAP-to-NETFS_RESTORE_CAPABILITIES.patch b/SOURCES/0002-Changed-BACKUP_CAP-to-NETFS_RESTORE_CAPABILITIES.patch new file mode 100644 index 0000000..66aeba1 --- /dev/null +++ b/SOURCES/0002-Changed-BACKUP_CAP-to-NETFS_RESTORE_CAPABILITIES.patch @@ -0,0 +1,17 @@ +diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf +index 5389a07..a5152a2 100644 +--- a/usr/share/rear/conf/default.conf ++++ b/usr/share/rear/conf/default.conf +@@ -614,6 +614,9 @@ NETFS_PREFIX="$HOSTNAME" + # empty means only keep current backup + NETFS_KEEP_OLD_BACKUP_COPY= + ++# Specify if rear should try to backup capabilities (y/n) default (n). ++NETFS_RESTORE_CAPABILITIES=n ++ + ## + # BACKUP=RSYNC method + ## +-- +1.8.3.1 + diff --git a/SOURCES/0003-Added-knowledge-about-NVME-SSD-disks-in-script-20_pa.patch b/SOURCES/0003-Added-knowledge-about-NVME-SSD-disks-in-script-20_pa.patch new file mode 100644 index 0000000..2f4cb27 --- /dev/null +++ b/SOURCES/0003-Added-knowledge-about-NVME-SSD-disks-in-script-20_pa.patch @@ -0,0 +1,26 @@ +From e7043b6951705edb2abd87031868591502e9a688 Mon Sep 17 00:00:00 2001 +From: Gratien D'haese +Date: Mon, 7 Mar 2016 11:40:26 +0100 +Subject: [PATCH] Added knowledge about NVME SSD disks in script + 20_partition_layout.sh - issue #787 + +--- + usr/share/rear/layout/save/GNU/Linux/20_partition_layout.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usr/share/rear/layout/save/GNU/Linux/20_partition_layout.sh b/usr/share/rear/layout/save/GNU/Linux/20_partition_layout.sh +index a5458d9..9724aee 100644 +--- a/usr/share/rear/layout/save/GNU/Linux/20_partition_layout.sh ++++ b/usr/share/rear/layout/save/GNU/Linux/20_partition_layout.sh +@@ -250,7 +250,7 @@ Log "Saving disk partitions." + # format: disk + for disk in /sys/block/* ; do + blockd=${disk#/sys/block/} +- if [[ $blockd = hd* || $blockd = sd* || $blockd = cciss* || $blockd = vd* || $blockd = xvd* ]] ; then ++ if [[ $blockd = hd* || $blockd = sd* || $blockd = cciss* || $blockd = vd* || $blockd = xvd* || $blockd = dasd* || $blockd = nvme* ]] ; then + devname=$(get_device_name $disk) + devsize=$(get_disk_size ${disk#/sys/block/}) + +-- +1.8.3.1 + diff --git a/SOURCES/0004-correcting-variable-name-and-making-it-an-array.patch b/SOURCES/0004-correcting-variable-name-and-making-it-an-array.patch new file mode 100644 index 0000000..87cef81 --- /dev/null +++ b/SOURCES/0004-correcting-variable-name-and-making-it-an-array.patch @@ -0,0 +1,25 @@ +From 2f7e6e09a3934b431daea2b44750143b16d22922 Mon Sep 17 00:00:00 2001 +From: jmazanek +Date: Fri, 27 Jan 2017 09:36:42 +0100 +Subject: [PATCH] -correcting variable name and making it an array + +--- + usr/share/rear/prep/default/95_check_missing_programs.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usr/share/rear/prep/default/95_check_missing_programs.sh b/usr/share/rear/prep/default/95_check_missing_programs.sh +index e7f7ea7..3204016 100644 +--- a/usr/share/rear/prep/default/95_check_missing_programs.sh ++++ b/usr/share/rear/prep/default/95_check_missing_programs.sh +@@ -3,7 +3,7 @@ + # so we need to double check before leaving the prep stage. + + # check for requirements, do we have all required binaries ? +-MISSING_PROGRS=() ++declare -a MISSING_PROGS + for f in "${REQUIRED_PROGS[@]}" ; do + if ! has_binary "$f"; then + MISSING_PROGS=( "${MISSING_PROGS[@]}" "$f" ) +-- +1.8.3.1 + diff --git a/SOURCES/31_include_cap_uitls.sh b/SOURCES/31_include_cap_uitls.sh new file mode 100644 index 0000000..244abf5 --- /dev/null +++ b/SOURCES/31_include_cap_uitls.sh @@ -0,0 +1,4 @@ +# include utilities needed to set capabilities +if is_true "$NETFS_RESTORE_CAPABILITIES" ; then + REQUIRED_PROGS=("${REQUIRED_PROGS[@]}" setcap getcap) +fi diff --git a/SOURCES/51_set_capabilities.sh b/SOURCES/51_set_capabilities.sh new file mode 100644 index 0000000..43d03ed --- /dev/null +++ b/SOURCES/51_set_capabilities.sh @@ -0,0 +1,13 @@ +# restore capabilities if capabilities are in the backup + if is_true "$NETFS_RESTORE_CAPABILITIES" ; then + if test -s $VAR_DIR/recovery/capabilities ; then + Log "Restoring Capabilities." + while IFS="=" read file cap ; do + file="${file% }" + cap="${cap# }" + setcap "${cap}" "${TARGET_FS_ROOT}/${file}" 2>/dev/null || Log "Error while setting capabilties to \"${file}\"" + done < <(cat $VAR_DIR/recovery/capabilities) + else + Log "No saved capabilities found" + fi + fi diff --git a/SOURCES/61_save_capabilities.sh b/SOURCES/61_save_capabilities.sh new file mode 100644 index 0000000..f118723 --- /dev/null +++ b/SOURCES/61_save_capabilities.sh @@ -0,0 +1,5 @@ +# save all found capapilities to file + +if is_true "$NETFS_RESTORE_CAPABILITIES" ; then + getcap -r / 2>/dev/null | grep -v $ISO_DIR > $VAR_DIR/recovery/capabilities || Log "Error while saving capabilities to file." +fi diff --git a/SOURCES/is_true.patch b/SOURCES/is_true.patch new file mode 100644 index 0000000..098ddd5 --- /dev/null +++ b/SOURCES/is_true.patch @@ -0,0 +1,283 @@ +--- /usr/share/rear/lib/global-functions.sh 2015-09-03 15:43:01.000000000 +0200 ++++ /usr/share/rear/lib/global-functions.sh 2017-01-06 12:02:52.000000000 +0100 +@@ -2,27 +2,14 @@ + # + # global functions for Relax-and-Recover + # +-# Relax-and-Recover is free software; you can redistribute it and/or modify +-# it under the terms of the GNU General Public License as published by +-# the Free Software Foundation; either version 2 of the License, or +-# (at your option) any later version. +- +-# Relax-and-Recover is distributed in the hope that it will be useful, +-# but WITHOUT ANY WARRANTY; without even the implied warranty of +-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-# GNU General Public License for more details. +- +-# You should have received a copy of the GNU General Public License +-# along with Relax-and-Recover; if not, write to the Free Software +-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +-# +-# ++# This file is part of Relax-and-Recover, licensed under the GNU General ++# Public License. Refer to the included COPYING for full text of license. + + function read_and_strip_file () { + # extracts content from config files. In other words: strips the comments and new lines +- if test -s "$1" ; then +- sed -e '/^[[:space:]]/d;/^$/d;/^#/d' "$1" +- fi ++ if test -s "$1" ; then ++ sed -e '/^[[:space:]]/d;/^$/d;/^#/d' "$1" ++ fi + } + + function is_numeric () { +@@ -34,27 +21,143 @@ + fi + } + ++# two explicit functions to be able to test explicitly for true and false (see issue #625) ++# because "tertium non datur" (cf. https://en.wikipedia.org/wiki/Law_of_excluded_middle) ++# does not hold for variables because variables could be unset or have empty value ++# and to test if a variable is true or false its value is tested by that functions ++# but the variable may not have a real value (i.e. be unset or have empty value): ++ ++function is_true () { ++ # the argument is usually the value of a variable which needs to be tested ++ # only if there is explicitly a 'true' value then is_true returns true ++ # so that an unset variable or an empty value is not true: ++ case "$1" in ++ ([tT] | [yY] | [yY][eE][sS] | [tT][rR][uU][eE] | 1) ++ return 0 ;; ++ esac ++ return 1 ++} ++ ++function is_false () { ++ # the argument is usually the value of a variable which needs to be tested ++ # only if there is explicitly a 'false' value then is_false returns true ++ # so that an unset variable or an empty value is not false ++ # caution: for unset or empty variables is_false is false ++ case "$1" in ++ ([fF] | [nN] | [nN][oO] | [fF][aA][lL][sS][eE] | 0) ++ return 0 ;; ++ esac ++ return 1 ++} ++ + ###### + ### Functions for dealing with URLs + ###### ++# URL is the most common form of URI ++# see https://en.wikipedia.org/wiki/Uniform_Resource_Identifier ++# where a generic URI is of the form ++# scheme:[//[user:password@]host[:port]][/]path[?query][#fragment] ++# e.g. for BACKUP_URL=sshfs://user@host/G/rear/ ++# url_scheme = 'sshfs' , url_host = 'user@host' , url_hostname = 'host' , url_username = 'user' , url_path = '/G/rear/' ++# e.g. for BACKUP_URL=usb:///dev/sdb1 ++# url_scheme = 'usb' , url_host = '' , url_hostname = '' , url_username = '' , url_path = '/dev/sdb1' ++# FIXME: the ulr_* functions are not safe against special characters ++# for example they break when the password contains spaces ++# but on the other hand permitted characters for values in a URI ++# are ASCII letters, digits, dot, hyphen, underscore, and tilde ++# and any other character must be percent-encoded (in particular the ++# characters : / ? # [ ] @ are reserved as delimiters of URI components ++# and must be percent-encoded when used in the value of a URI component) ++# so that what is missing is support for percent-encoded characters ++# but user-friendly support for percent-encoded characters is not possible ++# cf. http://bugzilla.opensuse.org/show_bug.cgi?id=561626#c7 + +-url_scheme() { ++function url_scheme() { + local url=$1 ++ # the scheme is the leading part up to '://' + local scheme=${url%%://*} + # rsync scheme does not have to start with rsync:// it can also be scp style ++ # see the comments in usr/share/rear/prep/RSYNC/default/100_check_rsync.sh + echo $scheme | grep -q ":" && echo rsync || echo $scheme + } + +-url_host() { ++function url_host() { ++ local url=$1 ++ local url_without_scheme=${url#*//} ++ # the authority part is the part after the scheme (e.g. 'host' or 'user@host') ++ # i.e. after 'scheme://' all up to but excluding the next '/' ++ # which means it breaks if there is a username that contains a '/' ++ # which should not happen because a POSIX-compliant username ++ # should have only characters from the portable filename character set ++ # which is ASCII letters, digits, dot, hyphen, and underscore ++ # (a hostname must not contain a '/' see RFC 952 and RFC 1123) ++ local authority_part=${url_without_scheme%%/*} ++ # for backward compatibility the url_host function returns the whole authority part ++ # see https://github.com/rear/rear/issues/856 ++ # to get only hostname or username use the url_hostname and url_username functions ++ echo $authority_part ++} ++ ++function url_hostname() { + local url=$1 +- local host=${url#*//} +- echo ${host%%/*} ++ local url_without_scheme=${url#*//} ++ local authority_part=${url_without_scheme%%/*} ++ # if authority_part contains a '@' we assume the 'user@host' format and ++ # then we remove the 'user@' part (i.e. all up to and including the last '@') ++ # so that it also works when the username contains a '@' ++ # like 'john@doe' in BACKUP_URL=sshfs://john@doe@host/G/rear/ ++ # (a hostname must not contain a '@' see RFC 952 and RFC 1123) ++ local host_and_port=${authority_part##*@} ++ # if host_and_port contains a ':' we assume the 'host:port' format and ++ # then we remove the ':port' part (i.e. all from and including the last ':') ++ # so that it even works when the hostname contains a ':' (in spite of RFC 952 and RFC 1123) ++ echo ${host_and_port%:*} + } + +-url_path() { ++function url_username() { + local url=$1 +- local path=${url#*//} +- echo /${path#*/} ++ local url_without_scheme=${url#*//} ++ local authority_part=${url_without_scheme%%/*} ++ # authority_part must contain a '@' when a username is specified ++ echo $authority_part | grep -q '@' || return 0 ++ # we remove the '@host' part (i.e. all from and including the last '@') ++ # so that it also works when the username contains a '@' ++ # like 'john@doe' in BACKUP_URL=sshfs://john@doe@host/G/rear/ ++ # (a hostname must not contain a '@' see RFC 952 and RFC 1123) ++ local user_and_password=${authority_part%@*} ++ # if user_and_password contains a ':' we assume the 'user:password' format and ++ # then we remove the ':password' part (i.e. all from and including the first ':') ++ # so that it works when the password contains a ':' ++ # (a POSIX-compliant username should not contain a ':') ++ echo $user_and_password | grep -q ':' && echo ${user_and_password%%:*} || echo $user_and_password ++} ++ ++function url_password() { ++ local url=$1 ++ local url_without_scheme=${url#*//} ++ local authority_part=${url_without_scheme%%/*} ++ # authority_part must contain a '@' when a username is specified ++ echo $authority_part | grep -q '@' || return 0 ++ # we remove the '@host' part (i.e. all from and including the last '@') ++ # so that it also works when the username contains a '@' ++ # like 'john@doe' in BACKUP_URL=sshfs://john@doe@host/G/rear/ ++ # (a hostname must not contain a '@' see RFC 952 and RFC 1123) ++ local user_and_password=${authority_part%@*} ++ # user_and_password must contain a ':' when a password is specified ++ echo $user_and_password | grep -q ':' || return 0 ++ # we remove the 'user:' part (i.e. all up to and including the first ':') ++ # so that it works when the password contains a ':' ++ # (a POSIX-compliant username should not contain a ':') ++ echo ${user_and_password#*:} ++} ++ ++function url_path() { ++ local url=$1 ++ local url_without_scheme=${url#*//} ++ # the path is all from and including the first '/' in url_without_scheme ++ # i.e. the whole rest after the authority part so that ++ # it may contain an optional trailing '?query' and '#fragment' ++ echo /${url_without_scheme#*/} + } + + backup_path() { +@@ -76,7 +179,7 @@ + path="${TMP_DIR}/isofs${path}" + fi + ;; +- (*) # nfs, cifs, usb, a.o. need a temporary mount-path ++ (*) # nfs, cifs, usb, a.o. need a temporary mount-path + path="${BUILD_DIR}/outputfs/${NETFS_PREFIX}" + ;; + esac +@@ -93,7 +196,7 @@ + (file) # type file needs a local path (must be mounted by user) + path="$path/${OUTPUT_PREFIX}" + ;; +- (*) # nfs, cifs, usb, a.o. need a temporary mount-path ++ (*) # nfs, cifs, usb, a.o. need a temporary mount-path + path="${BUILD_DIR}/outputfs/${OUTPUT_PREFIX}" + ;; + esac +@@ -129,7 +232,8 @@ + ;; + (cifs) + if [ x"$options" = x"$defaultoptions" ];then +- mount_cmd="mount $v -o $options,guest //$(url_host $url)$(url_path $url) $mountpoint" ++ # defaultoptions contains noatime which is not valid for cifs (issue #752) ++ mount_cmd="mount $v -o rw,guest //$(url_host $url)$(url_path $url) $mountpoint" + else + mount_cmd="mount $v -o $options //$(url_host $url)$(url_path $url) $mountpoint" + fi +@@ -137,19 +241,48 @@ + (usb) + mount_cmd="mount $v -o $options $(url_path $url) $mountpoint" + ;; +- (sshfs) +- mount_cmd="sshfs $(url_host $url):$(url_path $url) $mountpoint -o $options" ++ (sshfs) ++ local authority=$( url_host $url ) ++ test "$authority" || Error "Cannot run 'sshfs' because no authority '[user@]host' found in URL '$url'." ++ local path=$( url_path $url ) ++ test "$path" || Error "Cannot run 'sshfs' because no path found in URL '$url'." ++ # ensure the fuse kernel module is loaded because sshfs is based on FUSE ++ lsmod | grep -q '^fuse' || modprobe $verbose fuse || Error "Cannot run 'sshfs' because 'fuse' kernel module is not loadable." ++ mount_cmd="sshfs $authority:$path $mountpoint -o $options" ++ ;; ++ (ftpfs) ++ local hostname=$( url_hostname $url ) ++ test "$hostname" || Error "Cannot run 'curlftpfs' because no hostname found in URL '$url'." ++ local path=$( url_path $url ) ++ test "$path" || Error "Cannot run 'curlftpfs' because no path found in URL '$url'." ++ local username=$( url_username $url ) ++ # ensure the fuse kernel module is loaded because ftpfs (via CurlFtpFS) is based on FUSE ++ lsmod | grep -q '^fuse' || modprobe $verbose fuse || Error "Cannot run 'curlftpfs' because 'fuse' kernel module is not loadable." ++ if test "$username" ; then ++ local password=$( url_password $url ) ++ if test "$password" ; then ++ # single quoting is a must for the password ++ mount_cmd="curlftpfs $verbose -o user='$username:$password' ftp://$hostname$path $mountpoint" ++ else ++ # also single quoting for the plain username so that it also works for non-POSIX-compliant usernames ++ # (a POSIX-compliant username should only contain ASCII letters, digits, dot, hyphen, and underscore) ++ mount_cmd="curlftpfs $verbose -o user='$username' ftp://$hostname$path $mountpoint" ++ fi ++ else ++ mount_cmd="curlftpfs $verbose ftp://$hostname$path $mountpoint" ++ fi ++ ;; ++ (davfs) ++ mount_cmd="mount $v -t davfs http://$(url_host $url)$(url_path $url) $mountpoint" + ;; +- (davfs) +- mount_cmd="mount $v -t davfs http://$(url_host $url)$(url_path $url) $mountpoint" +- ;; + (*) + mount_cmd="mount $v -t $(url_scheme $url) -o $options $(url_host $url):$(url_path $url) $mountpoint" + ;; + esac + + Log "Mounting with '$mount_cmd'" +- $mount_cmd >&2 ++ # eval is required when mount_cmd contains single quoted stuff (e.g. see the above mount_cmd for curlftpfs) ++ eval $mount_cmd >&2 + StopIfError "Mount command '$mount_cmd' failed." + + AddExitTask "umount -f $v '$mountpoint' >&2" +@@ -182,7 +315,7 @@ + # and delete only the just used cache + #rm -rf /var/cache/davfs2/** + rm -rf /var/cache/davfs2/*outputfs* +- ++ + ;; + (var) + local var=$(url_host $url) +@@ -228,3 +361,4 @@ + Log "Unmounting '$mountpoint' failed." + return 1 + } ++ diff --git a/SOURCES/rearbin.patch b/SOURCES/rearbin.patch new file mode 100644 index 0000000..6c4fbae --- /dev/null +++ b/SOURCES/rearbin.patch @@ -0,0 +1,10 @@ +--- /usr/sbin/rear 2015-09-03 15:43:01.000000000 +0200 ++++ /usr/sbin/rear 2017-02-23 13:15:59.504794464 +0100 +@@ -46,6 +46,7 @@ + VAR_DIR="$REAR_DIR_PREFIX/var/lib/rear" + LOG_DIR="$REAR_DIR_PREFIX/var/log/rear" + CMD_OPTS=( "$@" ) ++readonly TARGET_FS_ROOT="/mnt/local" + + # initialize defaults + STEPBYSTEP= diff --git a/SPECS/rear.spec b/SPECS/rear.spec index 8bba5db..6a51956 100644 --- a/SPECS/rear.spec +++ b/SPECS/rear.spec @@ -2,7 +2,7 @@ Summary: Relax-and-Recover is a Linux disaster recovery and system migration tool Name: rear Version: 1.17.2 -Release: 7%{?dist} +Release: 9%{?dist} License: GPLv3 Group: Applications/File URL: http://relax-and-recover.org/ @@ -10,10 +10,20 @@ URL: http://relax-and-recover.org/ # as GitHub stopped with download section we need to go back to Sourceforge for downloads Source0: https://sourceforge.net/projects/rear/files/rear/1.17/%{version}/rear-%{version}.tar.gz Source1: 36_teaming.sh +Source2: 31_include_cap_uitls.sh +Source3: 51_set_capabilities.sh +Source4: 61_save_capabilities.sh Patch0: rear-grep-fix.patch Patch1: rear-teaming-interface.patch Patch2: uuid_xfs.patch +Patch3: 0002-Changed-BACKUP_CAP-to-NETFS_RESTORE_CAPABILITIES.patch +Patch4: 0003-Added-knowledge-about-NVME-SSD-disks-in-script-20_pa.patch +Patch5: 0004-correcting-variable-name-and-making-it-an-array.patch +Patch6: is_true.patch +Patch7: rearbin.patch BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) +ExcludeArch: s390x +ExcludeArch: s390 ### Dependencies on all distributions Requires: binutils @@ -93,10 +103,15 @@ fi %prep %setup -q - +#touch usr/share/rear/prep/GNU/Linux/31_include_cap_uitls.sh %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 echo "30 1 * * * root /usr/sbin/rear checklayout || /usr/sbin/rear mkrescue" >rear.cron @@ -112,6 +127,9 @@ echo "30 1 * * * root /usr/sbin/rear checklayout || /usr/sbin/rear mkrescue" >re %{__install} -Dp -m0644 rear.cron %{buildroot}%{_sysconfdir}/cron.d/rear #%{__install} -Dp -m0644 etc/udev/rules.d/62-rear-usb.rules %{buildroot}%{_sysconfdir}/udev/rules.d/62-rear-usb.rules cp %{SOURCE1} %{buildroot}%{_datadir}/rear/rescue/GNU/Linux/36_teaming.sh +cp %{SOURCE2} %{buildroot}%{_datadir}/rear/prep/GNU/Linux/31_include_cap_uitls.sh +cp %{SOURCE3} %{buildroot}%{_datadir}/rear/restore/NETFS/default/51_set_capabilities.sh +cp %{SOURCE4} %{buildroot}%{_datadir}/rear/rescue/NETFS/default/61_save_capabilities.sh %clean %{__rm} -rf %{buildroot} @@ -127,6 +145,11 @@ cp %{SOURCE1} %{buildroot}%{_datadir}/rear/rescue/GNU/Linux/36_teaming.sh %{_sbindir}/rear %changelog +* Wed Jan 25 2017 Jakub Mazanek - 1.17.2-8 +- Adding backup of Linux capabilities +- Adding knowledge about NVME disks +Resolves: #1434519 + * Tue Dec 13 2016 Jakub Mazanek - 1.17.2-7 - Correcting UUID creation on xfs filesystem Resolves: #1404167