@ -22,12 +22,12 @@ import org.apache.dolphinscheduler.common.shell.ShellExecutor;
import org.apache.commons.configuration.Configuration ;
import org.apache.commons.configuration.Configuration ;
import java.lang.management.OperatingSystemMXBean ;
import java.io.BufferedReader ;
import java.io.BufferedReader ;
import java.io.FileInputStream ;
import java.io.FileInputStream ;
import java.io.IOException ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.io.InputStreamReader ;
import java.lang.management.ManagementFactory ;
import java.lang.management.ManagementFactory ;
import java.lang.management.OperatingSystemMXBean ;
import java.lang.management.RuntimeMXBean ;
import java.lang.management.RuntimeMXBean ;
import java.math.RoundingMode ;
import java.math.RoundingMode ;
import java.text.DecimalFormat ;
import java.text.DecimalFormat ;
@ -407,12 +407,16 @@ public class OSUtils {
/ * *
/ * *
* get sudo command
* get sudo command
*
* @param tenantCode tenantCode
* @param tenantCode tenantCode
* @param command command
* @param command command
* @return result of sudo execute command
* @return result of sudo execute command
* /
* /
public static String getSudoCmd ( String tenantCode , String command ) {
public static String getSudoCmd ( String tenantCode , String command ) {
return StringUtils . isEmpty ( tenantCode ) ? command : "sudo -u " + tenantCode + " " + command ;
if ( ! CommonUtils . isSudoEnable ( ) | | StringUtils . isEmpty ( tenantCode ) ) {
return command ;
}
return String . format ( "sudo -u %s %s" , tenantCode , command ) ;
}
}
/ * *
/ * *