Patch from kaliber: use path of executable instead of the command. Thanks!
this fixes bug #1773 and #1824. I tested only #1773. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24131 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,7 +22,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
status_t __parse_invoke_line(char *invoker, char ***_newArgs,
|
||||
char * const **_oldArgs, int32 *_argCount);
|
||||
char * const **_oldArgs, int32 *_argCount, const char *arg0);
|
||||
status_t __get_next_image_dependency(image_id id, uint32 *cookie,
|
||||
const char **_name);
|
||||
status_t __test_executable(const char *path, char *invoker);
|
||||
|
||||
@@ -33,7 +33,7 @@ load_image(int32 argCount, const char **args, const char **environ)
|
||||
|
||||
if (invoker[0]) {
|
||||
status = __parse_invoke_line(invoker, &newArgs,
|
||||
(char * const **)&args, &argCount);
|
||||
(char * const **)&args, &argCount, args[1]);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ next_argument(char **_start, bool separate)
|
||||
|
||||
status_t
|
||||
__parse_invoke_line(char *invoker, char ***_newArgs,
|
||||
char * const **_oldArgs, int32 *_argCount)
|
||||
char * const **_oldArgs, int32 *_argCount, const char *arg0)
|
||||
{
|
||||
int32 i, count = 0;
|
||||
char *arg = invoker;
|
||||
@@ -169,7 +169,10 @@ __parse_invoke_line(char *invoker, char ***_newArgs,
|
||||
newArgs[i] = arg;
|
||||
}
|
||||
for (i = 0; i < *_argCount; i++) {
|
||||
newArgs[i + count] = (char *)(*_oldArgs)[i];
|
||||
if (i == 0)
|
||||
newArgs[i + count] = arg0;
|
||||
else
|
||||
newArgs[i + count] = (char *)(*_oldArgs)[i];
|
||||
}
|
||||
|
||||
newArgs[i + count] = NULL;
|
||||
|
||||
@@ -72,14 +72,14 @@ execve(const char *path, char * const args[], char * const environment[])
|
||||
|
||||
// test validity of executable + support for scripts
|
||||
{
|
||||
status_t status = __test_executable(args[0], invoker);
|
||||
status_t status = __test_executable(path, invoker);
|
||||
if (status < B_OK) {
|
||||
errno = status;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (invoker[0]) {
|
||||
status = __parse_invoke_line(invoker, &newArgs, &args, &argCount);
|
||||
status = __parse_invoke_line(invoker, &newArgs, &args, &argCount, path);
|
||||
if (status < B_OK) {
|
||||
errno = status;
|
||||
return -1;
|
||||
@@ -94,7 +94,7 @@ execve(const char *path, char * const args[], char * const environment[])
|
||||
// don't care and pass everything to the kernel - it will have to
|
||||
// do the right thing :)
|
||||
|
||||
errno = _kern_exec(path, argCount, args, envCount, environment);
|
||||
errno = _kern_exec(path, argCount, newArgs ? newArgs : args, envCount, environment);
|
||||
// if this call returns, something definitely went wrong
|
||||
|
||||
free(newArgs);
|
||||
|
||||
Reference in New Issue
Block a user