|
13 | 13 | import com.termux.shared.data.DataUtils;
|
14 | 14 | import com.termux.shared.data.IntentUtils;
|
15 | 15 | import com.termux.shared.file.TermuxFileUtils;
|
| 16 | +import com.termux.shared.file.filesystem.FileType; |
16 | 17 | import com.termux.shared.models.errors.Errno;
|
17 | 18 | import com.termux.shared.models.errors.Error;
|
18 | 19 | import com.termux.shared.termux.TermuxConstants;
|
@@ -75,8 +76,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
|
75 | 76 | return Service.START_NOT_STICKY;
|
76 | 77 | }
|
77 | 78 |
|
78 |
| - executionCommand.executable = IntentUtils.getStringExtraIfSet(intent, RUN_COMMAND_SERVICE.EXTRA_COMMAND_PATH, null); |
79 |
| - |
| 79 | + String executableExtra = executionCommand.executable = IntentUtils.getStringExtraIfSet(intent, RUN_COMMAND_SERVICE.EXTRA_COMMAND_PATH, null); |
80 | 80 | executionCommand.arguments = IntentUtils.getStringArrayExtraIfSet(intent, RUN_COMMAND_SERVICE.EXTRA_ARGUMENTS, null);
|
81 | 81 |
|
82 | 82 | /*
|
@@ -176,9 +176,17 @@ public int onStartCommand(Intent intent, int flags, int startId) {
|
176 | 176 | }
|
177 | 177 | }
|
178 | 178 |
|
| 179 | + // If the executable passed as the extra was an applet for coreutils/busybox, then we must |
| 180 | + // use it instead of the canonical path above since otherwise arguments would be passed to |
| 181 | + // coreutils/busybox instead and command would fail. Broken symlinks would already have been |
| 182 | + // validated so it should be fine to use it. |
| 183 | + executableExtra = TermuxFileUtils.getExpandedTermuxPath(executableExtra); |
| 184 | + if (FileUtils.getFileType(executableExtra, false) == FileType.SYMLINK) { |
| 185 | + Logger.logVerbose(LOG_TAG, "The executableExtra path \"" + executableExtra + "\" is a symlink so using it instead of the canonical path \"" + executionCommand.executable + "\""); |
| 186 | + executionCommand.executable = executableExtra; |
| 187 | + } |
179 | 188 |
|
180 |
| - |
181 |
| - executionCommand.executableUri = new Uri.Builder().scheme(TERMUX_SERVICE.URI_SCHEME_SERVICE_EXECUTE).path(TermuxFileUtils.getExpandedTermuxPath(executionCommand.executable)).build(); |
| 189 | + executionCommand.executableUri = new Uri.Builder().scheme(TERMUX_SERVICE.URI_SCHEME_SERVICE_EXECUTE).path(executionCommand.executable).build(); |
182 | 190 |
|
183 | 191 | Logger.logVerbose(LOG_TAG, executionCommand.toString());
|
184 | 192 |
|
|
0 commit comments