diff --git a/CHANGELOG.md b/CHANGELOG.md index f2b72ef94..4929c9f7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The poststart hooks are now executed after starting the user-specified process, fixing a runtime-spec conformance issue. (#4347, #5186) +### Added ### +- `runc version` and `runc features` now provide version information about + libpathrs when runc is built with the `libpathrs` build tag. (#5291) + ### Changed ### - runc now depends on [libpathrs v0.2.5] or later, and attempting to build with older versions will cause compilation errors. (#5291) diff --git a/features.go b/features.go index 46c0f202f..ebcff1f94 100644 --- a/features.go +++ b/features.go @@ -96,6 +96,10 @@ var featuresCommand = &cli.Command{ feat.Annotations[runcfeatures.AnnotationLibseccompVersion] = fmt.Sprintf("%d.%d.%d", major, minor, patch) } + if v := pathrsVersionString(); v != "" { + feat.Annotations[runcfeatures.AnnotationLibpathrsVersion] = v + } + enc := json.NewEncoder(cmd.Writer) enc.SetIndent("", " ") return enc.Encode(feat) diff --git a/features_libpathrs.go b/features_libpathrs.go new file mode 100644 index 000000000..d4cd17c6d --- /dev/null +++ b/features_libpathrs.go @@ -0,0 +1,15 @@ +//go:build libpathrs + +package main + +import ( + "cyphar.com/go-pathrs" +) + +func pathrsVersionString() string { + info, err := pathrs.LibraryVersion() + if err != nil { + panic(err) // should never happen + } + return info.VersionString +} diff --git a/features_pathrslite.go b/features_pathrslite.go new file mode 100644 index 000000000..a28f17960 --- /dev/null +++ b/features_pathrslite.go @@ -0,0 +1,7 @@ +//go:build !libpathrs + +package main + +func pathrsVersionString() string { + return "" +} diff --git a/go.mod b/go.mod index 9c214f867..a006470fd 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/opencontainers/runc go 1.25.0 require ( + cyphar.com/go-pathrs v0.2.5 github.com/checkpoint-restore/go-criu/v8 v8.3.0 github.com/containerd/console v1.0.5 github.com/coreos/go-systemd/v22 v22.7.0 @@ -28,7 +29,6 @@ require ( ) require ( - cyphar.com/go-pathrs v0.2.5 // indirect github.com/aperturerobotics/protobuf-go-lite v0.14.0 // indirect github.com/cilium/ebpf v0.17.3 // indirect ) diff --git a/main.go b/main.go index 3ee1009ae..ad1a61092 100644 --- a/main.go +++ b/main.go @@ -52,6 +52,10 @@ func printVersion(c *cli.Command) { if major+minor+micro > 0 { fmt.Fprintf(w, "libseccomp: %d.%d.%d\n", major, minor, micro) } + + if v := pathrsVersionString(); v != "" { + fmt.Fprintf(w, "libpathrs: %s\n", v) + } } const ( diff --git a/types/features/features.go b/types/features/features.go index a81893c8d..a44b7353f 100644 --- a/types/features/features.go +++ b/types/features/features.go @@ -22,4 +22,7 @@ const ( // AnnotationLibseccompVersion is the version of libseccomp, e.g., "2.5.1". // Note that the runtime MAY support seccomp even when this annotation is not present. AnnotationLibseccompVersion = "io.github.seccomp.libseccomp.version" + + // AnnotationLibpathrsVersion is the runtime version of libpathrs. + AnnotationLibpathrsVersion = "com.cyphar.pathrs.libpathrs.version" )