The expectation on older kernels (< 3.19) was to have the network
namespace always be a directory. This is not true if the network
namespace is bind mounted to a file, and will make the plugin fail
erroneously in such cases. The fix is to remove this assumption
completely and just do a basic check on the file system types being
returned.
Fixes #288
"os"
"path"
"runtime"
- "strings"
"sync"
"syscall"
}
switch stat.Type {
- case PROCFS_MAGIC:
- // Kernel < 3.19
-
- validPathContent := "ns/"
- validName := strings.Contains(nspath, validPathContent)
- if !validName {
- return NSPathNotNSErr{msg: fmt.Sprintf("path %q doesn't contain %q", nspath, validPathContent)}
- }
-
- return nil
- case NSFS_MAGIC:
- // Kernel >= 3.19
-
+ case PROCFS_MAGIC, NSFS_MAGIC:
return nil
default:
return NSPathNotNSErr{msg: fmt.Sprintf("unknown FS magic on %q: %x", nspath, stat.Type)}