runc: add libpathrs info to --version and features

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
Aleksa Sarai
2026-06-18 10:49:35 +02:00
parent d47bf88349
commit 1e20abef19
7 changed files with 38 additions and 1 deletions

View File

@@ -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)

View File

@@ -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)

15
features_libpathrs.go Normal file
View File

@@ -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
}

7
features_pathrslite.go Normal file
View File

@@ -0,0 +1,7 @@
//go:build !libpathrs
package main
func pathrsVersionString() string {
return ""
}

2
go.mod
View File

@@ -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
)

View File

@@ -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 (

View File

@@ -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"
)