File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,10 +67,6 @@ func mkdir(path string, perm os.FileMode) error {
6767 return os .Chmod (path , perm )
6868}
6969
70- func skipFile (* tar.Header ) bool {
71- return false
72- }
73-
7470var (
7571 inUserNS bool
7672 nsOnce sync.Once
@@ -80,15 +76,22 @@ func setInUserNS() {
8076 inUserNS = system .RunningInUserNS ()
8177}
8278
83- // handleTarTypeBlockCharFifo is an OS-specific helper function used by
84- // createTarFile to handle the following types of header: Block; Char; Fifo
85- func handleTarTypeBlockCharFifo (hdr * tar.Header , path string ) error {
86- nsOnce .Do (setInUserNS )
87- if inUserNS {
79+ func skipFile (hdr * tar.Header ) bool {
80+ switch hdr .Typeflag {
81+ case tar .TypeBlock , tar .TypeChar :
8882 // cannot create a device if running in user namespace
89- return nil
83+ nsOnce .Do (setInUserNS )
84+ return inUserNS
85+ default :
86+ return false
9087 }
88+ }
9189
90+ // handleTarTypeBlockCharFifo is an OS-specific helper function used by
91+ // createTarFile to handle the following types of header: Block; Char; Fifo.
92+ // This function must not be called for Block and Char when running in userns.
93+ // (skipFile() should return true for them.)
94+ func handleTarTypeBlockCharFifo (hdr * tar.Header , path string ) error {
9295 mode := uint32 (hdr .Mode & 07777 )
9396 switch hdr .Typeflag {
9497 case tar .TypeBlock :
You can’t perform that action at this time.
0 commit comments