mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 02:48:55 +00:00
Merge pull request #4104 from philaris/fix_max_uint32_uid_gid_to_zero
in tar dump, convert uid, gid of value -1 to zero
This commit is contained in:
commit
89a8006578
9
changelog/unreleased/issue-4103
Normal file
9
changelog/unreleased/issue-4103
Normal file
@ -0,0 +1,9 @@
|
||||
Bugfix: fix restic dump of tar file with 32-bit binary
|
||||
|
||||
When using a 32-bit build of restic, the `restic dump` command could in some
|
||||
cases create tar files containing negative uid and gid. These files cannot be
|
||||
read by gnu tar. This corner case especially applies to backups from stdin on Windows.
|
||||
We have changed the dump command to create valid tar files in this case.
|
||||
|
||||
https://github.com/restic/restic/issues/4103
|
||||
https://github.com/restic/restic/pull/4104
|
@ -38,6 +38,15 @@ const (
|
||||
cISVTX = 0o1000 // Save text (sticky bit)
|
||||
)
|
||||
|
||||
// in a 32-bit build of restic:
|
||||
// substitute a uid or gid of -1 (which was converted to 2^32 - 1) with 0
|
||||
func tarIdentifier(id uint32) int {
|
||||
if int(id) == -1 {
|
||||
return 0
|
||||
}
|
||||
return int(id)
|
||||
}
|
||||
|
||||
func (d *Dumper) dumpNodeTar(ctx context.Context, node *restic.Node, w *tar.Writer) error {
|
||||
relPath, err := filepath.Rel("/", node.Path)
|
||||
if err != nil {
|
||||
@ -48,8 +57,8 @@ func (d *Dumper) dumpNodeTar(ctx context.Context, node *restic.Node, w *tar.Writ
|
||||
Name: filepath.ToSlash(relPath),
|
||||
Size: int64(node.Size),
|
||||
Mode: int64(node.Mode.Perm()), // cIS* constants are added later
|
||||
Uid: int(node.UID),
|
||||
Gid: int(node.GID),
|
||||
Uid: tarIdentifier(node.UID),
|
||||
Gid: tarIdentifier(node.GID),
|
||||
Uname: node.User,
|
||||
Gname: node.Group,
|
||||
ModTime: node.ModTime,
|
||||
|
Loading…
Reference in New Issue
Block a user