Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
songlinfeng
container-toolkit
Commits
717e8cd7
Commit
717e8cd7
authored
Nov 18, 2025
by
songlinfeng
Browse files
rootless must be root
parent
3be6c25c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
cmd/dtk-ctk/rootless/main.go
cmd/dtk-ctk/rootless/main.go
+11
-1
No files found.
cmd/dtk-ctk/rootless/main.go
View file @
717e8cd7
...
@@ -5,7 +5,7 @@ import (
...
@@ -5,7 +5,7 @@ import (
"fmt"
"fmt"
"os"
"os"
"os/exec"
"os/exec"
"os/user"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"
)
)
...
@@ -32,6 +32,7 @@ func (m rootlessCommand) build() *cli.Command {
...
@@ -32,6 +32,7 @@ func (m rootlessCommand) build() *cli.Command {
c
:=
cli
.
Command
{
c
:=
cli
.
Command
{
Name
:
"rootless"
,
Name
:
"rootless"
,
Usage
:
"Provide tools for configuring rootless container runtimes"
,
Usage
:
"Provide tools for configuring rootless container runtimes"
,
Before
:
func
(
ctx
*
cli
.
Context
)
error
{
return
validateGenOptions
(
ctx
)
},
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
return
run
(
ctx
,
&
opts
)
},
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
return
run
(
ctx
,
&
opts
)
},
}
}
...
@@ -48,6 +49,15 @@ func (m rootlessCommand) build() *cli.Command {
...
@@ -48,6 +49,15 @@ func (m rootlessCommand) build() *cli.Command {
return
&
c
return
&
c
}
}
func
validateGenOptions
(
c
*
cli
.
Context
)
error
{
curUser
,
err
:=
user
.
Current
()
if
err
!=
nil
||
curUser
.
Uid
!=
"0"
{
return
fmt
.
Errorf
(
"Permission denied: Not running as root"
)
}
return
nil
}
func
run
(
c
*
cli
.
Context
,
opts
*
options
)
error
{
func
run
(
c
*
cli
.
Context
,
opts
*
options
)
error
{
runtime
:=
opts
.
runtime
runtime
:=
opts
.
runtime
if
runtime
!=
"docker"
&&
runtime
!=
"podman"
{
if
runtime
!=
"docker"
&&
runtime
!=
"podman"
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment