1
0
Fork 1
mirror of https://github.com/vbatts/tar-split.git synced 2025-10-04 13:11:01 +00:00

keywords: switch 'xattr' to base64

Rather than an arbitrary election of hashing the xattr value with SHA1
to avoid leaking the value. By going with base64 encoding it allows for
the possibility of restoring a directory with the values stored in the
manifest.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-07-27 17:40:51 -04:00
parent 27459241ae
commit 7e2ed0b70b
2 changed files with 10 additions and 12 deletions

View file

@ -2,7 +2,7 @@ package mtree
import (
"archive/tar"
"crypto/sha1"
"encoding/base64"
"fmt"
"io"
"os"
@ -55,7 +55,7 @@ var (
}
klist := []string{}
for k, v := range hdr.Xattrs {
klist = append(klist, fmt.Sprintf("xattr.%s=%x", k, sha1.Sum([]byte(v))))
klist = append(klist, fmt.Sprintf("xattr.%s=%s", k, base64.StdEncoding.EncodeToString([]byte(v))))
}
return strings.Join(klist, " "), nil
}
@ -70,7 +70,7 @@ var (
if err != nil {
return "", err
}
klist[i] = fmt.Sprintf("xattr.%s=%x", xlist[i], sha1.Sum(data))
klist[i] = fmt.Sprintf("xattr.%s=%s", xlist[i], base64.StdEncoding.EncodeToString(data))
}
return strings.Join(klist, " "), nil
}