@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus ;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus ;
import org.apache.dolphinscheduler.common.thread.Stopper ;
import org.apache.dolphinscheduler.common.thread.Stopper ;
import org.apache.dolphinscheduler.common.thread.ThreadUtils ;
import org.apache.dolphinscheduler.common.thread.ThreadUtils ;
import org.apache.dolphinscheduler.common.utils.CommonUtils ;
import org.apache.dolphinscheduler.common.utils.HadoopUtils ;
import org.apache.dolphinscheduler.common.utils.HadoopUtils ;
import org.apache.dolphinscheduler.common.utils.LoggerUtils ;
import org.apache.dolphinscheduler.common.utils.LoggerUtils ;
import org.apache.dolphinscheduler.common.utils.OSUtils ;
import org.apache.dolphinscheduler.common.utils.OSUtils ;
@ -84,7 +85,7 @@ public abstract class AbstractCommandExecutor {
* log list
* log list
* /
* /
protected final List < String > logBuffer ;
protected final List < String > logBuffer ;
protected boolean logOutputIsScuccess = false ;
protected boolean logOutputIsScuccess = false ;
/ * *
/ * *
@ -134,9 +135,11 @@ public abstract class AbstractCommandExecutor {
processBuilder . redirectErrorStream ( true ) ;
processBuilder . redirectErrorStream ( true ) ;
// setting up user to run commands
// setting up user to run commands
command . add ( "sudo" ) ;
if ( CommonUtils . isSudoEnable ( ) ) {
command . add ( "-u" ) ;
command . add ( "sudo" ) ;
command . add ( taskExecutionContext . getTenantCode ( ) ) ;
command . add ( "-u" ) ;
command . add ( taskExecutionContext . getTenantCode ( ) ) ;
}
command . add ( commandInterpreter ( ) ) ;
command . add ( commandInterpreter ( ) ) ;
command . addAll ( commandOptions ( ) ) ;
command . addAll ( commandOptions ( ) ) ;
command . add ( commandFile ) ;
command . add ( commandFile ) ;
@ -595,4 +598,4 @@ public abstract class AbstractCommandExecutor {
public void setTaskResultString ( String taskResultString ) {
public void setTaskResultString ( String taskResultString ) {
this . taskResultString = taskResultString ;
this . taskResultString = taskResultString ;
}
}
}
}