mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-05 00:15:44 +00:00
pkg/rootless: modernize
Using modernize (aka go fix) from Go 1.26.3, implement the following
changes:
> pkg/rootless/rootless_linux.go:319:30: fmtappendf: Replace []byte(fmt.Sprintf...) with fmt.Appendf (modernize)
> err = os.WriteFile(uidMap, []byte(fmt.Sprintf("%d %d 1\n", 0, os.Geteuid())), 0o666)
> ^
> pkg/rootless/rootless_linux.go:339:30: fmtappendf: Replace []byte(fmt.Sprintf...) with fmt.Appendf (modernize)
> err = os.WriteFile(gidMap, []byte(fmt.Sprintf("%d %d 1\n", 0, os.Getegid())), 0o666)
> ^
> pkg/rootless/rootless_linux.go:381:6: rangeint: for loop can be modernized using range over int (modernize)
> for sig := 0; sig < numSig; sig++ {
> ^
> pkg/rootless/rootless_linux.go:432:24: stringsseq: Ranging over SplitSeq is more efficient (modernize)
> for _, entry := range bytes.Split(data, []byte{0}) {
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
bd7e8bbab3
commit
121948d69e
1 changed files with 4 additions and 4 deletions
|
|
@ -316,7 +316,7 @@ func becomeRootInUserNS(stateDir string) (_ bool, _ int, retErr error) {
|
|||
}
|
||||
logrus.Debugf("write setgroups file exited with 0")
|
||||
|
||||
err = os.WriteFile(uidMap, []byte(fmt.Sprintf("%d %d 1\n", 0, os.Geteuid())), 0o666)
|
||||
err = os.WriteFile(uidMap, fmt.Appendf(nil, "%d %d 1\n", 0, os.Geteuid()), 0o666)
|
||||
if err != nil {
|
||||
return false, -1, fmt.Errorf("cannot write uid_map: %w", err)
|
||||
}
|
||||
|
|
@ -336,7 +336,7 @@ func becomeRootInUserNS(stateDir string) (_ bool, _ int, retErr error) {
|
|||
gidsMapped = err == nil
|
||||
}
|
||||
if !gidsMapped {
|
||||
err = os.WriteFile(gidMap, []byte(fmt.Sprintf("%d %d 1\n", 0, os.Getegid())), 0o666)
|
||||
err = os.WriteFile(gidMap, fmt.Appendf(nil, "%d %d 1\n", 0, os.Getegid()), 0o666)
|
||||
if err != nil {
|
||||
return false, -1, fmt.Errorf("cannot write gid_map: %w", err)
|
||||
}
|
||||
|
|
@ -378,7 +378,7 @@ func becomeRootInUserNS(stateDir string) (_ bool, _ int, retErr error) {
|
|||
|
||||
func waitAndProxySignalsToChild(pid C.int) (bool, int, error) {
|
||||
signals := []os.Signal{}
|
||||
for sig := 0; sig < numSig; sig++ {
|
||||
for sig := range numSig {
|
||||
if sig == int(unix.SIGTSTP) {
|
||||
continue
|
||||
}
|
||||
|
|
@ -429,7 +429,7 @@ func isPauseProcess(pid int) bool {
|
|||
if err != nil {
|
||||
return false
|
||||
}
|
||||
for _, entry := range bytes.Split(data, []byte{0}) {
|
||||
for entry := range bytes.SplitSeq(data, []byte{0}) {
|
||||
if string(entry) == "_PODMAN_PAUSE=1" {
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue