* Insert `sudo` only at the beginning of command in deep scan #495 * Fix testcase
This commit is contained in:
		@@ -327,7 +327,6 @@ func getSSHLogger(log ...*logrus.Entry) *logrus.Entry {
 | 
			
		||||
func decorateCmd(c conf.ServerInfo, cmd string, sudo bool) string {
 | 
			
		||||
	if sudo && c.User != "root" && !c.IsContainer() {
 | 
			
		||||
		cmd = fmt.Sprintf("sudo -S %s", cmd)
 | 
			
		||||
		cmd = strings.Replace(cmd, "|", "| sudo ", -1)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// If you are using pipe and you want to detect preprocessing errors, remove comment out
 | 
			
		||||
 
 | 
			
		||||
@@ -63,7 +63,7 @@ func TestDecorateCmd(t *testing.T) {
 | 
			
		||||
			conf:     config.ServerInfo{User: "non-roor"},
 | 
			
		||||
			cmd:      "ls | grep hoge",
 | 
			
		||||
			sudo:     true,
 | 
			
		||||
			expected: "sudo -S ls | sudo  grep hoge",
 | 
			
		||||
			expected: "sudo -S ls | grep hoge",
 | 
			
		||||
		},
 | 
			
		||||
		// -------------docker-------------
 | 
			
		||||
		// root sudo false docker
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user