-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: tar and local exporter running with privileges
TODO: need to cross-check that there is no way the SeBackupPrivilege can be abused/exploited. WIP: how best to handle the files to be exclused without touching `fsutil`. Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
- Loading branch information
1 parent
3d789eb
commit 2a25c5b
Showing
10 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package local | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/tonistiigi/fsutil" | ||
) | ||
|
||
func writeTar(ctx context.Context, fs fsutil.FS, w io.WriteCloser) error { | ||
return fsutil.WriteTar(ctx, fs, w) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package local | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/Microsoft/go-winio" | ||
"github.com/tonistiigi/fsutil" | ||
) | ||
|
||
func writeTar(ctx context.Context, fs fsutil.FS, w io.WriteCloser) error { | ||
// Windows rootfs has a few special metadata files that | ||
// require extra privileges to be accessed. | ||
privileges := []string{winio.SeBackupPrivilege} | ||
return winio.RunWithPrivileges(privileges, func() error { | ||
return fsutil.WriteTar(ctx, fs, w) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package filesync | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"github.com/tonistiigi/fsutil" | ||
) | ||
|
||
func sendDiffCopy(stream Stream, fs fsutil.FS, progress progressCb) error { | ||
return errors.WithStack(fsutil.Send(stream.Context(), stream, fs, progress)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package filesync | ||
|
||
import ( | ||
"github.com/Microsoft/go-winio" | ||
"github.com/pkg/errors" | ||
"github.com/tonistiigi/fsutil" | ||
) | ||
|
||
func sendDiffCopy(stream Stream, fs fsutil.FS, progress progressCb) error { | ||
// adding one SeBackupPrivilege to the process so as to be able | ||
// to run the subsequent goroutines in fsutil.Send that need | ||
// to copy over special Windows metadata files. | ||
// TODO(profnandaa): need to cross-check that this cannot be | ||
// exploited in any way. | ||
winio.EnableProcessPrivileges([]string{winio.SeBackupPrivilege}) | ||
defer winio.DisableProcessPrivileges([]string{winio.SeBackupPrivilege}) | ||
return errors.WithStack(fsutil.Send(stream.Context(), stream, fs, progress)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.