Skip to content

Commit 55cfe7e

Browse files
committed
use return error handling in SetupRootless
There is no good reason to use logrus and os.Exit() here, other parts of this function already return the error so do the same. The main podman process will exit then with the normal formatted error message. And also a comment about the last return which doesn't seem right. Signed-off-by: Paul Holzinger <[email protected]>
1 parent 90a03ca commit 55cfe7e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/domain/infra/abi/system_linux.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, noMoveProcess bool,
5959
}
6060
}
6161
}
62+
63+
// return early as we are already re-exec or root here so no need to join the rootless userns.
6264
return nil
6365
}
6466

@@ -81,8 +83,7 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, noMoveProcess bool,
8183
// if there is no pid file, try to join existing containers, and create a pause process.
8284
ctrs, err := ic.Libpod.GetRunningContainers()
8385
if err != nil {
84-
logrus.Error(err.Error())
85-
os.Exit(1)
86+
return err
8687
}
8788

8889
paths := []string{}
@@ -99,11 +100,12 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, noMoveProcess bool,
99100
}
100101
}
101102
if err != nil {
102-
logrus.Error(fmt.Errorf("invalid internal status, try resetting the pause process with %q: %w", os.Args[0]+" system migrate", err))
103-
os.Exit(1)
103+
return fmt.Errorf("invalid internal status, try resetting the pause process with %q: %w", os.Args[0]+" system migrate", err)
104104
}
105105
if became {
106106
os.Exit(ret)
107107
}
108+
// FIXME: should this be an error? If we never re-exec that seems like a big issue here as we
109+
// then call into code paths that expect to be run as uid 0.
108110
return nil
109111
}

0 commit comments

Comments
 (0)