fix sudo.enable=false Is invalid (#8388)
parent
d9129297ab
commit
806333a11c
|
|
@ -124,10 +124,12 @@ public abstract class AbstractCommandExecutor {
|
|||
// merge error information to standard output stream
|
||||
processBuilder.redirectErrorStream(true);
|
||||
|
||||
// setting up user to run commands
|
||||
command.add("sudo");
|
||||
command.add("-u");
|
||||
command.add(taskRequest.getTenantCode());
|
||||
// if sudo.enable=true,setting up user to run commands
|
||||
if (OSUtils.isSudoEnable()) {
|
||||
command.add("sudo");
|
||||
command.add("-u");
|
||||
command.add(taskRequest.getTenantCode());
|
||||
}
|
||||
command.add(commandInterpreter());
|
||||
command.addAll(Collections.emptyList());
|
||||
command.add(commandFile);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.dolphinscheduler.plugin.task.util;
|
||||
|
||||
import org.apache.dolphinscheduler.plugin.task.api.ShellExecutor;
|
||||
import org.apache.dolphinscheduler.spi.utils.PropertyUtils;
|
||||
import org.apache.dolphinscheduler.spi.utils.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -40,6 +41,15 @@ public class OSUtils {
|
|||
return StringUtils.isEmpty(tenantCode) ? command : "sudo -u " + tenantCode + " " + command;
|
||||
}
|
||||
|
||||
/**
|
||||
* use sudo or not
|
||||
*
|
||||
* @return true is use sudo
|
||||
*/
|
||||
public static boolean isSudoEnable() {
|
||||
return PropertyUtils.getBoolean("sudo.enable", Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* whether is macOS
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue