Backup and restore setuid/setgid/sticky bits

A user discovered that restic does not restore setuid/setgid/sticky file
attributes. This commit fixes that. The mode is stored in the Go format
as an uint32: https://golang.org/pkg/os/#FileMode
This commit is contained in:
Alexander Neumann
2015-12-20 19:45:36 +01:00
parent 55d9c5f80c
commit f49cb62812
2 changed files with 38 additions and 4 deletions
+2 -1
View File
@@ -67,10 +67,11 @@ func (node Node) Tree() *Tree {
// NodeFromFileInfo returns a new node from the given path and FileInfo.
func NodeFromFileInfo(path string, fi os.FileInfo) (*Node, error) {
mask := os.ModePerm | os.ModeType | os.ModeSetuid | os.ModeSetgid | os.ModeSticky
node := &Node{
path: path,
Name: fi.Name(),
Mode: fi.Mode() & (os.ModePerm | os.ModeType),
Mode: fi.Mode() & mask,
ModTime: fi.ModTime(),
}