Description
I am trying to execute a Linux command using executeSystemCommand but it unable to execute
Command:
/bin/sh -c "chown 0777 /var/test/123.sh"
tried to follow this solution but it will just give error 0777: "chown: command not found
https://stackoverflow.com/questions/71204716/how-should-esapi-executesystemcommand-sanitise-the-file-path-properly-to-satisfy
I put the full path of chown, it will also give the error 0777: "/usr/bin/chown: No such file or directory
Code:
Executor executor = ESAPI.executor();
File binSh = new File("/bin/sh").getCanonicalFile();
Codec codec = new UnixCodec();
List params = new ArrayList();
File workdir = new File( "/var");
params.add("-c");
params.add("\"chown");
params.add("0777");
params.add("/var/test/123.sh\"");
ExecuteResult result = executor.executeSystemCommand(binSh, params, workdir, codec, true, false);