aboutsummaryrefslogtreecommitdiff
path: root/exec_request.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-11-20 02:04:00 +0700
committerShulhan <ms@kilabit.info>2023-11-20 02:04:00 +0700
commit45af2385eb98994e91792e77e6912b1b74ebb677 (patch)
treeadcea778840969a5b008e7b2e3caa323388abb45 /exec_request.go
parent24cb59b547cbbb0a36b0aa54ad5ec13b6c095a8d (diff)
downloadawwan-45af2385eb98994e91792e77e6912b1b74ebb677.tar.xz
all: do not changes the Script path in the response of HTTP Execute
Previously, the ExecRequest from HTTP Execute endpoint changes the Script value to the absolute script path in the system. This changes fix this issue to minimize inconsistency between request and response.
Diffstat (limited to 'exec_request.go')
-rw-r--r--exec_request.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/exec_request.go b/exec_request.go
index dbacc65..fb3b2c1 100644
--- a/exec_request.go
+++ b/exec_request.go
@@ -54,7 +54,7 @@ func NewExecRequest(mode, script, lineRange string) (req *ExecRequest, err error
req.lineRange = parseLineRange(lineRange)
- err = req.init()
+ err = req.init(`.`)
if err != nil {
return nil, fmt.Errorf(`NewRequest: %w`, err)
}
@@ -78,7 +78,7 @@ func (req *ExecRequest) close() {
}
// init initialize multi loggers to write all output.
-func (req *ExecRequest) init() (err error) {
+func (req *ExecRequest) init(workDir string) (err error) {
if req.mlog == nil {
var (
namedStdout = mlog.NewNamedWriter(`stdout`, os.Stdout)
@@ -91,12 +91,15 @@ func (req *ExecRequest) init() (err error) {
)
}
- req.scriptPath = filepath.Clean(req.Script)
+ req.scriptPath = filepath.Join(workDir, req.Script)
+ req.scriptPath = filepath.Clean(req.scriptPath)
req.scriptPath, err = filepath.Abs(req.scriptPath)
if err != nil {
return err
}
+ req.lineRange = parseLineRange(req.LineRange)
+
// Create log file to record all input and output for audit in the
// future.
var fileLog = req.scriptPath + `.log`