From 5ef8b088eebd81dc71791cfa126fc863d3cc7b50 Mon Sep 17 00:00:00 2001 From: CentOS Buildsys Date: Feb 17 2014 20:29:49 +0000 Subject: import xfsdump-3.1.3-5.el7.src.rpm --- diff --git a/SOURCES/xfsdump-3.1.13-partial-stream-xattrs.patch b/SOURCES/xfsdump-3.1.13-partial-stream-xattrs.patch new file mode 100644 index 0000000..8860cc1 --- /dev/null +++ b/SOURCES/xfsdump-3.1.13-partial-stream-xattrs.patch @@ -0,0 +1,54 @@ +commit 0ece1a1c5bd9224a158138ea79bdffdcb7feda68 +Author: Eric Sandeen +Date: Wed Oct 2 18:41:09 2013 +0000 + + xfsdump: handle large, wholly-sparse files + + In restore_extent_group(), we loop over all extent headers for an inode + in the stream, and add up the cumulatively restored size, accounting + for both HOLE and DATA records and advancing restoredsz as we go. + + But for a wholly-sparse file, we have no HOLE header, only + a LAST header, and restoredsz remains at 0. + + This makes it look like it's a partially-restored file, split + across streams because the final restoredsz for this stream is + less than the file size, and we go to partial_reg(), which + allocates one slot in persp->a.parrest[] for this inode. But + we've also called partial_reg() with offset/sz of 0/0, which is + less than the file size so this inode never looks "done." + + Normally partial_check2() would clear the persp->a.parrest[] + slot in the array when the file is fully restored, but in + this case, that is never satisfied. So all stream slots + get filled as we encounter more inodes like this, and we + eventually get: + + "partial_reg: Out of records. Extend attrs applied early." + + Fix this by recognizing that if we hit a LAST header with + no restoredsz set (i.e. the LAST header is the only header), + set restoredsz to EOF (bstatp->bs_size) to indicate that + restoration of this file is complete, skip the call to + partial_reg(), and all is well. + + Signed-off-by: Eric Sandeen + Reviewed-by: Rich Johnston + Signed-off-by: Rich Johnston + +Index: xfsdump-3.1.3/restore/content.c +=================================================================== +--- xfsdump-3.1.3.orig/restore/content.c ++++ xfsdump-3.1.3/restore/content.c +@@ -7516,6 +7516,11 @@ restore_extent_group( drive_t *drivep, + * we are done. + */ + if ( ehdr.eh_type == EXTENTHDR_TYPE_LAST ) { ++ /* For a wholly sparse file, there is no HOLE ++ * record; advance restoredsz to EOF. ++ */ ++ if (!restoredsz) ++ restoredsz = bstatp->bs_size; + break; + } + diff --git a/SOURCES/xfsdump-3.1.13-partial_reg-segfault.patch b/SOURCES/xfsdump-3.1.13-partial_reg-segfault.patch new file mode 100644 index 0000000..fecc921 --- /dev/null +++ b/SOURCES/xfsdump-3.1.13-partial_reg-segfault.patch @@ -0,0 +1,45 @@ +commit 1162bdbcff77ed2341f0a9294db76df80f2f36a3 +Author: Eric Sandeen +Date: Tue Oct 8 22:05:54 2013 +0000 + + xfsdump: avoid segfault in partial_reg() in error case + + If we go down the "/* Should never get here. */" path + in partial_reg(), we issue a warning but then continue + with the function. This calls pi_unlock() twice, + but worse, uses a null isptr: + + if ( ! isptr ) { + ... isptr is never set if we get to ... + /* Should never get here. */ + pi_unlock(); + ... + } + ... + /* Update this drive's entry */ + bsptr = &isptr->is_bs[d_index]; + if (bsptr->endoffset == 0) { + + >From all appearances, because we unlock on that "never get + here" path, it should just be returning after printing the + warning. So add that, and we avoid the segfault. + + The previous fix to partial_reg() should prevent us from + hitting this in the first place. + + Signed-off-by: Eric Sandeen + Reviewed-by: Carlos Maiolino + Signed-off-by: Rich Johnston + +diff --git a/restore/content.c b/restore/content.c +index 54d933c..cc49336 100644 +--- a/restore/content.c ++++ b/restore/content.c +@@ -9007,6 +9007,7 @@ partial_reg( ix_t d_index, + #ifdef DEBUGPARTIALS + dump_partials(); + #endif ++ return; + } + + found: diff --git a/SOURCES/xfsdump-3.1.13-restore-capabilities.patch b/SOURCES/xfsdump-3.1.13-restore-capabilities.patch new file mode 100644 index 0000000..1df4545 --- /dev/null +++ b/SOURCES/xfsdump-3.1.13-restore-capabilities.patch @@ -0,0 +1,189 @@ +From a88c49071dde2539cce6d502effc27501416983a Mon Sep 17 00:00:00 2001 +From: Dave Chinner +Date: Thu, 6 Feb 2014 16:48:39 +1100 +Subject: [PATCH] restore: don't trash file capabilities + +xfsrestore fails to restore file capabilities correctly because it +sets the owner on the file after it has restored the capability +attributes. This results in the kernel stripping the capabilities +when changing the owner of the file and hence the restored file is +not complete. + +Fix this by changing the owner of the file when it is created rather +than after it has been fully restored. This ensures we don't kill +the caps as they are restored after the owner it appropriately set. +This fixes the xfs/296 failure. + +Signed-off-by: Dave Chinner +Reviewed-by: Brian Foster +Signed-off-by: Dave Chinner +--- + restore/content.c | 116 ++++++++++++++++++++++++++++++++++++------------------ + 1 file changed, 77 insertions(+), 39 deletions(-) + +diff --git a/restore/content.c b/restore/content.c +index 158fc88..cfcf94d 100644 +--- a/restore/content.c ++++ b/restore/content.c +@@ -362,6 +362,15 @@ struct stream_context { + char sc_path[2 * MAXPATHLEN]; + intgen_t sc_fd; + intgen_t sc_hsmflags; ++ ++ /* ++ * we have to set the owner before we set extended attributes otherwise ++ * capabilities will not be restored correctly as setting the owner with ++ * fchmod will strip the capability attribute from the file. Hence we ++ * need to do this before restoring xattrs and record it so we don't do ++ * it again on completion of file restoration. ++ */ ++ bool_t sc_ownerset; + }; + + typedef struct stream_context stream_context_t; +@@ -3429,6 +3438,8 @@ applynondirdump( drive_t *drivep, + memset(&strctxp->sc_bstat, 0, sizeof(bstat_t)); + strctxp->sc_path[0] = '\0'; + strctxp->sc_fd = -1; ++ strctxp->sc_ownerset = BOOL_FALSE; ++ + + for ( ; ; ) { + drive_ops_t *dop = drivep->d_opsp; +@@ -3455,6 +3466,7 @@ applynondirdump( drive_t *drivep, + memcpy(&strctxp->sc_bstat, bstatp, sizeof(bstat_t)); + strctxp->sc_path[0] = '\0'; + strctxp->sc_fd = -1; ++ strctxp->sc_ownerset = BOOL_FALSE; + + rv = restore_file( drivep, fhdrp, ehcs, ahcs, path1, path2 ); + +@@ -7351,6 +7363,61 @@ restore_file_cb( void *cp, bool_t linkpr, char *path1, char *path2 ) + } + } + ++/* ++ * Set the file owner and strip suid/sgid if necessary. On failure, it will ++ * close the file descriptor, unlink the file and return -1. On success, ++ * it will mark the stream contexts as having set the owner and return 0. ++ */ ++static int ++set_file_owner( ++ char *path, ++ intgen_t *fdp, ++ stream_context_t *strcxtp) ++{ ++ bstat_t *bstatp = &strcxtp->sc_bstat; ++ mode_t mode = (mode_t)bstatp->bs_mode; ++ int rval; ++ ++ rval = fchown(*fdp, (uid_t)bstatp->bs_uid, (gid_t)bstatp->bs_gid ); ++ if (!rval) ++ goto done; ++ ++ mlog(MLOG_VERBOSE | MLOG_WARNING, ++ _("chown (uid=%u, gid=%u) %s failed: %s\n"), ++ bstatp->bs_uid, bstatp->bs_gid, path, strerror(errno)); ++ ++ if (mode & S_ISUID) { ++ mlog(MLOG_VERBOSE | MLOG_WARNING, ++ _("stripping setuid bit on %s since chown failed\n"), ++ path); ++ mode &= ~S_ISUID; ++ } ++ ++ if ((mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) { ++ mlog(MLOG_VERBOSE | MLOG_WARNING, ++ _("stripping setgid bit on %s since chown failed\n"), ++ path); ++ mode &= ~S_ISGID; ++ } ++ ++ if (mode == (mode_t)bstatp->bs_mode) ++ goto done; ++ ++ rval = fchmod(*fdp, mode); ++ if (rval) { ++ mlog(MLOG_VERBOSE | MLOG_ERROR, ++ _("unable to strip setuid/setgid on %s, unlinking file.\n"), ++ path); ++ unlink(path); ++ close(*fdp); ++ *fdp = -1; ++ return -1; ++ } ++done: ++ strcxtp->sc_ownerset = BOOL_TRUE; ++ return 0; ++} ++ + /* called to begin a regular file. if no path given, or if just toc, + * don't actually write, just read. also get into that situation if + * cannot prepare destination. fd == -1 signifies no write. *statp +@@ -7442,6 +7509,12 @@ restore_reg( drive_t *drivep, + } + } + ++ if (strctxp->sc_ownerset == BOOL_FALSE && persp->a.ownerpr) { ++ rval = set_file_owner(path, fdp, strctxp); ++ if (rval) ++ return BOOL_TRUE; ++ } ++ + if ( persp->a.dstdirisxfspr ) { + + /* set the extended inode flags, except those which must +@@ -7628,45 +7701,10 @@ restore_complete_reg(stream_context_t *strcxtp) + + /* set the owner and group (if enabled) + */ +- if ( persp->a.ownerpr ) { +- rval = fchown( fd, +- ( uid_t )bstatp->bs_uid, +- ( gid_t )bstatp->bs_gid ); +- if ( rval ) { +- mode_t mode = (mode_t)bstatp->bs_mode; +- +- mlog( MLOG_VERBOSE | MLOG_WARNING, +- _("chown (uid=%u, gid=%u) %s failed: %s\n"), +- bstatp->bs_uid, +- bstatp->bs_gid, +- path, +- strerror( errno )); +- +- if ( mode & S_ISUID ) { +- mlog( MLOG_VERBOSE | MLOG_WARNING, +- _("stripping setuid bit on %s " +- "since chown failed\n"), +- path ); +- mode &= ~S_ISUID; +- } +- if ( (mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP) ) { +- mlog( MLOG_VERBOSE | MLOG_WARNING, +- _("stripping setgid bit on %s " +- "since chown failed\n"), +- path ); +- mode &= ~S_ISGID; +- } +- if ( mode != (mode_t)bstatp->bs_mode ) { +- rval = fchmod( fd, mode ); +- if ( rval ) { +- mlog( MLOG_VERBOSE | MLOG_ERROR, +- _("unable to strip setuid/setgid " +- "on %s, unlinking file.\n"), +- path ); +- unlink( path ); +- } +- } +- } ++ if (strcxtp->sc_ownerset == BOOL_FALSE && persp->a.ownerpr) { ++ rval = set_file_owner(path, &fd, strcxtp); ++ if (rval) ++ return BOOL_TRUE; + } + + /* set the permissions/mode +-- +1.8.1 + + diff --git a/SPECS/xfsdump.spec b/SPECS/xfsdump.spec index 9fc4c93..3b029d3 100644 --- a/SPECS/xfsdump.spec +++ b/SPECS/xfsdump.spec @@ -1,7 +1,7 @@ Summary: Administrative utilities for the XFS filesystem Name: xfsdump Version: 3.1.3 -Release: 1%{?dist} +Release: 5%{?dist} # Licensing based on generic "GNU GENERAL PUBLIC LICENSE" # in source, with no mention of version. License: GPL+ @@ -13,6 +13,10 @@ BuildRequires: libtool, gettext, gawk BuildRequires: xfsprogs-devel, libuuid-devel, libattr-devel ncurses-devel Requires: xfsprogs >= 2.6.30, attr >= 2.0.0 +Patch0: xfsdump-3.1.13-partial_reg-segfault.patch +Patch1: xfsdump-3.1.13-partial-stream-xattrs.patch +Patch2: xfsdump-3.1.13-restore-capabilities.patch + %description The xfsdump package contains xfsdump, xfsrestore and a number of other utilities for administering XFS filesystems. @@ -33,6 +37,10 @@ subtrees may be restored from full or partial backups. %prep %setup -q +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 + %build %configure @@ -61,6 +69,20 @@ rm -rf $RPM_BUILD_ROOT %{_sbindir}/* %changelog +* Mon Feb 17 2014 Eric Sandeen 3.1.3-5 +- Preserve file capabilities during xfsrestore (#1013345) + +- Preserve xattrs on multi-part stream restores (#1034014) +* Fri Jan 24 2014 Daniel Mach - 3.1.3-4 +- Mass rebuild 2014-01-24 + +* Fri Dec 27 2013 Daniel Mach - 3.1.3-3 +- Mass rebuild 2013-12-27 + +* Mon Nov 25 2013 Eric Sandeen 3.1.3-2 +- Preserve xattrs on multi-part stream restores (#1034014) +- Prevent segfault on multi-part stream restores (#1034015) + * Mon Oct 07 2013 Eric Sandeen 3.1.3-1 - Update to version 3.1.3 (#1016306)