Skip to content

Commit e650692

Browse files
committed
runc: add libpathrs info to --version and features
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (cherry picked from commit 1e20abe) Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
1 parent c3e97da commit e650692

7 files changed

Lines changed: 38 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased 1.4.z]
88

9+
### Added ###
10+
- `runc version` and `runc features` now provide version information about
11+
libpathrs when runc is built with the `libpathrs` build tag. (#5291, #5328)
12+
913
### Changed ###
1014
- For users making use of the `libpathrs` build tag, runc now depends on
1115
[libpathrs v0.2.5] or later, and attempting to build with older versions will

features.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ var featuresCommand = cli.Command{
9393
feat.Annotations[runcfeatures.AnnotationLibseccompVersion] = fmt.Sprintf("%d.%d.%d", major, minor, patch)
9494
}
9595

96+
if v := pathrsVersionString(); v != "" {
97+
feat.Annotations[runcfeatures.AnnotationLibpathrsVersion] = v
98+
}
99+
96100
enc := json.NewEncoder(context.App.Writer)
97101
enc.SetIndent("", " ")
98102
return enc.Encode(feat)

features_libpathrs.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//go:build libpathrs
2+
3+
package main
4+
5+
import (
6+
"cyphar.com/go-pathrs"
7+
)
8+
9+
func pathrsVersionString() string {
10+
info, err := pathrs.LibraryVersion()
11+
if err != nil {
12+
panic(err) // should never happen
13+
}
14+
return info.VersionString
15+
}

features_pathrslite.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build !libpathrs
2+
3+
package main
4+
5+
func pathrsVersionString() string {
6+
return ""
7+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/opencontainers/runc
33
go 1.24.0
44

55
require (
6+
cyphar.com/go-pathrs v0.2.5
67
github.com/checkpoint-restore/go-criu/v7 v7.2.0
78
github.com/containerd/console v1.0.5
89
github.com/coreos/go-systemd/v22 v22.7.0
@@ -28,7 +29,6 @@ require (
2829
)
2930

3031
require (
31-
cyphar.com/go-pathrs v0.2.5 // indirect
3232
github.com/cilium/ebpf v0.17.3 // indirect
3333
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
3434
github.com/russross/blackfriday/v2 v2.1.0 // indirect

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func printVersion(c *cli.Context) {
4848
if major+minor+micro > 0 {
4949
fmt.Fprintf(w, "libseccomp: %d.%d.%d\n", major, minor, micro)
5050
}
51+
52+
if v := pathrsVersionString(); v != "" {
53+
fmt.Fprintf(w, "libpathrs: %s\n", v)
54+
}
5155
}
5256

5357
const (

types/features/features.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ const (
2222
// AnnotationLibseccompVersion is the version of libseccomp, e.g., "2.5.1".
2323
// Note that the runtime MAY support seccomp even when this annotation is not present.
2424
AnnotationLibseccompVersion = "io.github.seccomp.libseccomp.version"
25+
26+
// AnnotationLibpathrsVersion is the runtime version of libpathrs.
27+
AnnotationLibpathrsVersion = "com.cyphar.pathrs.libpathrs.version"
2528
)

0 commit comments

Comments
 (0)