77 "io"
88 "net/http"
99 "os"
10- "os/exec"
1110 "path/filepath"
1211 "sort"
1312 "strings"
@@ -16,18 +15,12 @@ import (
1615 "github.com/containers/common/libnetwork/types"
1716 "github.com/containers/common/pkg/config"
1817 "github.com/containers/podman/v4/libpod/define"
19- "github.com/containers/podman/v4/utils"
2018 "github.com/fsnotify/fsnotify"
2119 spec "github.com/opencontainers/runtime-spec/specs-go"
2220 "github.com/opencontainers/selinux/go-selinux/label"
2321 "github.com/sirupsen/logrus"
2422)
2523
26- // Runtime API constants
27- const (
28- unknownPackage = "Unknown"
29- )
30-
3124// FuncTimer helps measure the execution time of a function
3225// For debug purposes, do not leave in code
3326// used like defer FuncTimer("foo")
@@ -145,57 +138,6 @@ func JSONDeepCopy(from, to interface{}) error {
145138 return json .Unmarshal (tmp , to )
146139}
147140
148- func queryPackageVersion (cmdArg ... string ) string {
149- output := unknownPackage
150- if 1 < len (cmdArg ) {
151- cmd := exec .Command (cmdArg [0 ], cmdArg [1 :]... )
152- if outp , err := cmd .Output (); err == nil {
153- output = string (outp )
154- if cmdArg [0 ] == "/usr/bin/dpkg" {
155- r := strings .Split (output , ": " )
156- queryFormat := `${Package}_${Version}_${Architecture}`
157- cmd = exec .Command ("/usr/bin/dpkg-query" , "-f" , queryFormat , "-W" , r [0 ])
158- if outp , err := cmd .Output (); err == nil {
159- output = string (outp )
160- }
161- }
162- }
163- if cmdArg [0 ] == "/sbin/apk" {
164- prefix := cmdArg [len (cmdArg )- 1 ] + " is owned by "
165- output = strings .Replace (output , prefix , "" , 1 )
166- }
167- }
168- return strings .Trim (output , "\n " )
169- }
170-
171- func packageVersion (program string ) string { // program is full path
172- packagers := [][]string {
173- {"/usr/bin/rpm" , "-q" , "-f" },
174- {"/usr/bin/dpkg" , "-S" }, // Debian, Ubuntu
175- {"/usr/bin/pacman" , "-Qo" }, // Arch
176- {"/usr/bin/qfile" , "-qv" }, // Gentoo (quick)
177- {"/usr/bin/equery" , "b" }, // Gentoo (slow)
178- {"/sbin/apk" , "info" , "-W" }, // Alpine
179- {"/usr/local/sbin/pkg" , "which" , "-q" }, // FreeBSD
180- }
181-
182- for _ , cmd := range packagers {
183- cmd = append (cmd , program )
184- if out := queryPackageVersion (cmd ... ); out != unknownPackage {
185- return out
186- }
187- }
188- return unknownPackage
189- }
190-
191- func programVersion (mountProgram string ) (string , error ) {
192- output , err := utils .ExecCmd (mountProgram , "--version" )
193- if err != nil {
194- return "" , err
195- }
196- return strings .TrimSuffix (output , "\n " ), nil
197- }
198-
199141// DefaultSeccompPath returns the path to the default seccomp.json file
200142// if it exists, first it checks OverrideSeccomp and then default.
201143// If neither exist function returns ""
0 commit comments