Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
fec15efe
Commit
fec15efe
authored
Sep 21, 2015
by
Abhi Shah
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14317 from ArtfulCoder/netexec1.1
netexec shellCommand endpoint returns the error if shell command fail…
parents
a5e8b576
e40f1533
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
Makefile
contrib/for-tests/netexec/Makefile
+1
-3
netexec.go
contrib/for-tests/netexec/netexec.go
+14
-3
No files found.
contrib/for-tests/netexec/Makefile
View file @
fec15efe
.PHONY
:
all netexec image push clean
TAG
=
1.
0
TAG
=
1.
1
PREFIX
=
gcr.io/google_containers
all
:
push
TAG
=
1.0
netexec
:
netexec.go
CGO_ENABLED
=
0
GOOS
=
linux go build
-a
-installsuffix
cgo
-ldflags
'-w'
./netexec.go
...
...
contrib/for-tests/netexec/netexec.go
View file @
fec15efe
...
...
@@ -191,9 +191,20 @@ func dialUDP(request string, remoteAddress *net.UDPAddr) (string, error) {
func
shellHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
log
.
Println
(
r
.
FormValue
(
"shellCommand"
))
output
,
err
:=
exec
.
Command
(
shellPath
,
"-c"
,
r
.
FormValue
(
"shellCommand"
))
.
CombinedOutput
()
assertNoError
(
err
)
fmt
.
Fprintf
(
w
,
string
(
output
))
cmdOut
,
err
:=
exec
.
Command
(
shellPath
,
"-c"
,
r
.
FormValue
(
"shellCommand"
))
.
CombinedOutput
()
output
:=
map
[
string
]
string
{}
if
len
(
cmdOut
)
>
0
{
output
[
"output"
]
=
string
(
cmdOut
)
}
if
err
!=
nil
{
output
[
"error"
]
=
fmt
.
Sprintf
(
"%v"
,
err
)
}
bytes
,
err
:=
json
.
Marshal
(
output
)
if
err
==
nil
{
fmt
.
Fprintf
(
w
,
string
(
bytes
))
}
else
{
http
.
Error
(
w
,
fmt
.
Sprintf
(
"response could not be serialized. %v"
,
err
),
http
.
StatusExpectationFailed
)
}
}
func
hostNameHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
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