Skip to content

Commit 78647a6

Browse files
xcasparMandssS
authored andcommitted
bugfix: exclude the influence of JAVA_TOOL_OPTIONS variable
Signed-off-by: xcaspar <changjun.xcj@alibaba-inc.com>
1 parent 9e6fb34 commit 78647a6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

exec/jvm/sandbox.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,21 @@ func attach(uid, pid, port string, ctx context.Context, javaHome string) (*spec.
104104
if err != nil {
105105
logrus.Warnf("get current user info failed, %v", err)
106106
}
107-
var response *spec.Response
107+
var command string
108108
if currUser != nil && (currUser.Username == username) {
109-
response = cl.Run(ctx, javaBin, javaArgs)
109+
command = fmt.Sprintf("%s %s", javaBin, javaArgs)
110110
} else {
111111
if currUser != nil {
112112
logrus.Infof("current user name is %s, not equal %s, so use sudo command to execute",
113113
currUser.Username, username)
114114
}
115-
response = cl.Run(ctx, "sudo", fmt.Sprintf("-u %s %s %s", username, javaBin, javaArgs))
115+
command = fmt.Sprintf("sudo -u %s %s %s", username, javaBin, javaArgs)
116116
}
117+
javaToolOptions := os.Getenv("JAVA_TOOL_OPTIONS")
118+
if javaToolOptions != "" {
119+
command = fmt.Sprintf("export JAVA_TOOL_OPTIONS='' && %s", command)
120+
}
121+
response := cl.Run(ctx, "", command)
117122
if !response.Success {
118123
return response, username
119124
}

0 commit comments

Comments
 (0)