Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
960a668d
Commit
960a668d
authored
5 years ago
by
Lang Martin
Browse files
Options
Download
Email Patches
Plain Diff
taskrunner getter set Umask for go-getter, setuid test
parent
a72955a7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
client/allocrunner/taskrunner/getter/getter.go
+1
-0
client/allocrunner/taskrunner/getter/getter.go
client/allocrunner/taskrunner/getter/getter_test.go
+39
-0
client/allocrunner/taskrunner/getter/getter_test.go
client/allocrunner/taskrunner/getter/test-fixtures/setuid.tgz
+0
-0
...nt/allocrunner/taskrunner/getter/test-fixtures/setuid.tgz
with
40 additions
and
0 deletions
+40
-0
client/allocrunner/taskrunner/getter/getter.go
+
1
-
0
View file @
960a668d
...
...
@@ -52,6 +52,7 @@ func getClient(src string, mode gg.ClientMode, dst string) *gg.Client {
Dst
:
dst
,
Mode
:
mode
,
Getters
:
getters
,
Umask
:
060000000
,
}
}
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/getter/getter_test.go
+
39
-
0
View file @
960a668d
...
...
@@ -14,6 +14,7 @@ import (
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/stretchr/testify/require"
)
// fakeReplacer is a noop version of taskenv.TaskEnv.ReplaceEnv
...
...
@@ -214,6 +215,44 @@ func TestGetArtifact_Archive(t *testing.T) {
checkContents
(
taskDir
,
expected
,
t
)
}
func
TestGetArtifact_Setuid
(
t
*
testing
.
T
)
{
// Create the test server hosting the file to download
ts
:=
httptest
.
NewServer
(
http
.
FileServer
(
http
.
Dir
(
filepath
.
Dir
(
"./test-fixtures/"
))))
defer
ts
.
Close
()
// Create a temp directory to download into and create some of the same
// files that exist in the artifact to ensure they are overridden
taskDir
,
err
:=
ioutil
.
TempDir
(
""
,
"nomad-test"
)
require
.
NoError
(
t
,
err
)
defer
os
.
RemoveAll
(
taskDir
)
file
:=
"setuid.tgz"
artifact
:=
&
structs
.
TaskArtifact
{
GetterSource
:
fmt
.
Sprintf
(
"%s/%s"
,
ts
.
URL
,
file
),
GetterOptions
:
map
[
string
]
string
{
"checksum"
:
"sha1:e892194748ecbad5d0f60c6c6b2db2bdaa384a90"
,
},
}
require
.
NoError
(
t
,
GetArtifact
(
taskEnv
,
artifact
,
taskDir
))
// Verify the unarchiving overrode files properly.
expected
:=
map
[
string
]
int
{
"public"
:
0666
,
"private"
:
0600
,
"setuid"
:
0755
,
}
for
file
,
perm
:=
range
expected
{
path
:=
filepath
.
Join
(
taskDir
,
"setuid"
,
file
)
s
,
err
:=
os
.
Stat
(
path
)
require
.
NoError
(
t
,
err
)
p
:=
os
.
FileMode
(
perm
)
o
:=
s
.
Mode
()
require
.
Equalf
(
t
,
p
,
o
,
"%s expected %o found %o"
,
file
,
p
,
o
)
}
}
func
TestGetGetterUrl_Queries
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
name
string
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/getter/test-fixtures/setuid.tgz
0 → 100644
+
0
-
0
View file @
960a668d
File added
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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