|
32 | 32 | import esa.mo.helpertools.helpers.HelperMisc;
|
33 | 33 | import esa.mo.helpertools.misc.Const;
|
34 | 34 | import esa.mo.sm.impl.util.OSValidator;
|
35 |
| -import esa.mo.sm.impl.util.ShellCommander; |
36 | 35 | import java.io.File;
|
37 | 36 | import java.io.FileInputStream;
|
38 | 37 | import java.io.IOException;
|
@@ -126,9 +125,23 @@ public AppsLauncherManager(COMServicesProvider comServices)
|
126 | 125 | }
|
127 | 126 |
|
128 | 127 | if(osValidator.isUnix()){
|
129 |
| - ShellCommander shell = new ShellCommander(); |
130 |
| - String out = shell.runCommandAndGetOutputMessageAndError("sudo --help"); |
131 |
| - sudoAvailable = !out.contains("command not found"); |
| 128 | + try { |
| 129 | + String[] params = new String[]{"sh", "-c", "sudo --help"}; |
| 130 | + Process p = Runtime.getRuntime().exec(params, null, null); |
| 131 | + try { |
| 132 | + boolean terminated = p.waitFor(1, TimeUnit.SECONDS); |
| 133 | + if(terminated){ |
| 134 | + sudoAvailable = (p.exitValue() != 127); |
| 135 | + } |
| 136 | + } catch (InterruptedException ex) { |
| 137 | + Logger.getLogger(AppsLauncherManager.class.getName()).log( |
| 138 | + Level.SEVERE, "The process did no finish yet...", ex); |
| 139 | + sudoAvailable = false; |
| 140 | + } |
| 141 | + } catch (IOException ex) { |
| 142 | + Logger.getLogger(AppsLauncherManager.class.getName()).log( |
| 143 | + Level.SEVERE, "The process could not be executed!", ex); |
| 144 | + } |
132 | 145 | }
|
133 | 146 | }
|
134 | 147 |
|
|
0 commit comments