refactor: hardcode sandbox tempdir as /tmp
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
recordVisibleHome = "/home/test"
|
recordVisibleHome = "/home/test"
|
||||||
recordVisibleTmp = "/tmp"
|
|
||||||
recordGitDate = "2024-01-01T00:00:00Z"
|
recordGitDate = "2024-01-01T00:00:00Z"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -60,11 +60,9 @@ func buildRecordShellScript() string {
|
|||||||
var body bytes.Buffer
|
var body bytes.Buffer
|
||||||
if err := recordShellTemplate.Execute(&body, struct {
|
if err := recordShellTemplate.Execute(&body, struct {
|
||||||
VisibleHome string
|
VisibleHome string
|
||||||
VisibleTmp string
|
|
||||||
GitDate string
|
GitDate string
|
||||||
}{
|
}{
|
||||||
VisibleHome: shQuote(recordVisibleHome),
|
VisibleHome: shQuote(recordVisibleHome),
|
||||||
VisibleTmp: shQuote(recordVisibleTmp),
|
|
||||||
GitDate: shQuote(recordGitDate),
|
GitDate: shQuote(recordGitDate),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
panic(fmt.Sprintf("render record shell template: %v", err))
|
panic(fmt.Sprintf("render record shell template: %v", err))
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ exec bwrap \
|
|||||||
--ro-bind / / \
|
--ro-bind / / \
|
||||||
--tmpfs /home \
|
--tmpfs /home \
|
||||||
--bind "$host_home" {{ .VisibleHome }} \
|
--bind "$host_home" {{ .VisibleHome }} \
|
||||||
--bind "$host_tmp" {{ .VisibleTmp }} \
|
--bind "$host_tmp" '/tmp' \
|
||||||
--dev /dev \
|
--dev /dev \
|
||||||
--proc /proc \
|
--proc /proc \
|
||||||
--unshare-pid \
|
--unshare-pid \
|
||||||
@@ -36,7 +36,7 @@ exec bwrap \
|
|||||||
--setenv PATH "$path_env" \
|
--setenv PATH "$path_env" \
|
||||||
--setenv PS1 '$ ' \
|
--setenv PS1 '$ ' \
|
||||||
--setenv TERM 'xterm-256color' \
|
--setenv TERM 'xterm-256color' \
|
||||||
--setenv TMPDIR {{ .VisibleTmp }} \
|
--setenv TMPDIR '/tmp' \
|
||||||
--setenv TZ 'UTC' \
|
--setenv TZ 'UTC' \
|
||||||
--chdir {{ .VisibleHome }} \
|
--chdir {{ .VisibleHome }} \
|
||||||
bash --noprofile --norc -i
|
bash --noprofile --norc -i
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ func TestBuildRecordShellScriptUsesExpectedCommands(t *testing.T) {
|
|||||||
"path_env=${MIRO_RECORD_PATH_ENV:?}",
|
"path_env=${MIRO_RECORD_PATH_ENV:?}",
|
||||||
"HOME=\"$host_home\" GIT_CONFIG_NOSYSTEM=1 git config --global user.name 'Miro Test'",
|
"HOME=\"$host_home\" GIT_CONFIG_NOSYSTEM=1 git config --global user.name 'Miro Test'",
|
||||||
"--bind \"$host_home\" " + shQuote(recordVisibleHome),
|
"--bind \"$host_home\" " + shQuote(recordVisibleHome),
|
||||||
"--bind \"$host_tmp\" " + shQuote(recordVisibleTmp),
|
"--bind \"$host_tmp\" '/tmp'",
|
||||||
"--setenv HOME " + shQuote(recordVisibleHome),
|
"--setenv HOME " + shQuote(recordVisibleHome),
|
||||||
"--setenv PATH \"$path_env\"",
|
"--setenv PATH \"$path_env\"",
|
||||||
"--setenv PS1 '$ '",
|
"--setenv PS1 '$ '",
|
||||||
@@ -234,7 +234,7 @@ func TestRunRecordSessionUsesSandboxedScriptCommand(t *testing.T) {
|
|||||||
"--ro-bind / /",
|
"--ro-bind / /",
|
||||||
"--tmpfs /home",
|
"--tmpfs /home",
|
||||||
"--setenv HOME " + shQuote(recordVisibleHome),
|
"--setenv HOME " + shQuote(recordVisibleHome),
|
||||||
"--setenv TMPDIR " + shQuote(recordVisibleTmp),
|
"--setenv TMPDIR '/tmp'",
|
||||||
"bash --noprofile --norc -i",
|
"bash --noprofile --norc -i",
|
||||||
} {
|
} {
|
||||||
if !strings.Contains(body, want) {
|
if !strings.Contains(body, want) {
|
||||||
|
|||||||
Reference in New Issue
Block a user