Skip to content

Commit cd81f40

Browse files
committed
only sudo if you aren't already the user running the jvm process
this enables usage inside docker containers that don't contain sudo, when running `docker exec` as the user running the jvm process, eg:`docker exec -it --user daemon`
1 parent d9843a0 commit cd81f40

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bin/create-java-perf-map.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fi
3636
[ -d "$JAVA_HOME" ] || (echo "JAVA_HOME directory at '$JAVA_HOME' does not exist." && false)
3737

3838

39-
if [[ "$LINUX" == "1" ]]; then
39+
if [[ "$LINUX" == "1" ]] && [[ $EUID -ne $TARGET_UID ]]; then
4040
sudo rm $PERF_MAP_FILE -f
4141
(cd $PERF_MAP_DIR/out && sudo -u \#$TARGET_UID -g \#$TARGET_GID $JAVA_HOME/bin/java -cp $ATTACH_JAR_PATH:$JAVA_HOME/lib/tools.jar net.virtualvoid.perf.AttachOnce $PID "$OPTIONS")
4242
sudo chown root:root $PERF_MAP_FILE

0 commit comments

Comments
 (0)