Skip to content

Commit

Permalink
Fix runc root not having enough priveleges
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarbashov committed Jun 7, 2021
1 parent 3176999 commit 1610a39
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ ctcli list-releases
## Root Directory File Structure

```
/releases - Previous releases and etc.
/config - Services' configs
/current-release - Current installation
/logs - Logs
/data - app persistent data
/tmp - Temporary directory
/releases - Previous releases and etc.
/config - Services' configs
/current-release - Current installation
/logs - Logs
/data - app persistent data
/runc-root - runc containers root dir
/tmp - Temporary directory
```

## Package structure
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/spf13/cobra"
)

const VERSION int = 5
const VERSION int = 6
const COMMIT string = "%%commit_hash%%"

var versionCmd = &cobra.Command{
Expand Down
4 changes: 4 additions & 0 deletions domain/ctcliDir/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ func GetNewArchiveStdoutLogFilePath(rootDir, app string) string {

func GetCtcliLogFilePath(rootDir string) string {
return path.Join(GetLogsDir(rootDir), "ctcli.log")
}

func GetRuncRoot(rootDir string) string {
return path.Join(rootDir, "runc-root")
}
4 changes: 4 additions & 0 deletions domain/lifetime/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func StartApp(rootDir, appName, appPath, runcPath string) error {

cmd := exec.Command(
runcPath,
"--root",
ctcliDir.GetRuncRoot(rootDir),
"create",
"--bundle",
appPath,
Expand All @@ -84,6 +86,8 @@ func StartApp(rootDir, appName, appPath, runcPath string) error {

cmd = exec.Command(
runcPath,
"--root",
ctcliDir.GetRuncRoot(rootDir),
"start",
runc.GetContainerName(rootDir, appName),
)
Expand Down
5 changes: 5 additions & 0 deletions domain/lifetime/stop.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package lifetime

import (
"ctcli/domain/ctcliDir"
"ctcli/domain/release"
"ctcli/domain/runc"
"ctcli/util"
Expand Down Expand Up @@ -46,6 +47,8 @@ func StopApp(rootDir, appName, runcPath string) error {
if status == "running" {
cmd := exec.Command(
runcPath,
"--root",
ctcliDir.GetRuncRoot(rootDir),
"kill",
runc.GetContainerName(rootDir, appName),
"SIGTERM",
Expand All @@ -60,6 +63,8 @@ func StopApp(rootDir, appName, runcPath string) error {
if status == "running" {
cmd := exec.Command(
runcPath,
"--root",
ctcliDir.GetRuncRoot(rootDir),
"kill",
runc.GetContainerName(rootDir, appName),
"SIGKILL",
Expand Down
7 changes: 7 additions & 0 deletions domain/runc/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runc

import (
"crypto/md5"
"ctcli/domain/ctcliDir"
"ctcli/domain/release"
"fmt"
"github.com/valyala/fastjson"
Expand All @@ -17,6 +18,8 @@ func GetStatus(rootDir string, appName string) string {
runcPath := release.GetCurrentReleaseRuncPath(rootDir)
out, err := exec.Command(
runcPath,
"--root",
ctcliDir.GetRuncRoot(rootDir),
"state",
GetContainerName(rootDir, appName),
).Output()
Expand All @@ -31,6 +34,8 @@ func GetPid(rootDir string, appName string) int {
runcPath := release.GetCurrentReleaseRuncPath(rootDir)
out, err := exec.Command(
runcPath,
"--root",
ctcliDir.GetRuncRoot(rootDir),
"state",
GetContainerName(rootDir, appName),
).Output()
Expand All @@ -55,6 +60,8 @@ func DeleteContainer(rootDir string, appName string) error {
runcPath := release.GetCurrentReleaseRuncPath(rootDir)
err := exec.Command(
runcPath,
"--root",
ctcliDir.GetRuncRoot(rootDir),
"delete",
GetContainerName(rootDir, appName),
).Run()
Expand Down

0 comments on commit 1610a39

Please sign in to comment.