summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-12-21 14:54:11 -0800
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-12-21 21:35:31 -0800
commit7dc0dafef1d241d396f215c506ec2d4f7d8e3a24 (patch)
tree23e107b5e7aa82b719d5dbc926c72def0a7c7e4f
parent4c256c0e9c4fe61990343c8bcf2e352c83d76e69 (diff)
XQuartz: Run applications via '/bin/sh -c ...' to support users who expect shell parsing
(cherry picked from commit 67455e716e3ecffd528930479192785958d37988)
-rw-r--r--hw/xquartz/X11Controller.m30
-rw-r--r--hw/xquartz/mach-startup/bundle-main.c32
2 files changed, 11 insertions, 51 deletions
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 7222f463b..9b30fa6bb 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -314,36 +314,16 @@ BOOL xquartz_resetenv_display = NO;
- (void) launch_client:(NSString *)filename
{
- const char *command = [filename UTF8String];
int child1, child2 = 0;
int status;
- char newcommand[1024];
- char *newargv[1024];
+ const char *newargv[4];
char buf[128];
- size_t newargc;
char *s;
- if(strlen(command) > 1023) {
- fprintf(stderr, "Error: command is too long: %s\n", command);
- return;
- }
-
- strlcpy(newcommand, command, 1024);
-
- for(newargc=0, s=newcommand; *s; newargc++) {
- for(; *s && *s == ' '; s++);
- if(!*s)
- break;
-
- newargv[newargc] = s;
- for(; *s && *s != ' '; s++);
-
- if(*s) {
- *s='\0';
- s++;
- }
- }
- newargv[newargc] = NULL;
+ newargv[0] = [X11App prefs_get_string:@PREFS_LOGIN_SHELL default:"/bin/sh"];
+ newargv[1] = "-c";
+ newargv[2] = [filename UTF8String];
+ newargv[3] = NULL;
s = getenv("DISPLAY");
if (xquartz_resetenv_display || s == NULL || s[0] == 0) {
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 7677a9a93..fd70f26ed 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -531,33 +531,13 @@ int main(int argc, char **argv, char **envp) {
}
static int execute(const char *command) {
- char newcommand[1024];
- char *newargv[1024];
- size_t newargc;
- char *s;
- char **p;
-
- if(strlen(command) > 1023) {
- fprintf(stderr, "Error: command is too long: %s\n", command);
- return 1;
- }
-
- strlcpy(newcommand, command, 1024);
+ const char *newargv[4];
+ const char **p;
- for(newargc=0, s=newcommand; *s; newargc++) {
- for(; *s && *s == ' '; s++);
- if(!*s)
- break;
-
- newargv[newargc] = s;
- for(; *s && *s != ' '; s++);
-
- if(*s) {
- *s='\0';
- s++;
- }
- }
- newargv[newargc] = NULL;
+ newargv[0] = command_from_prefs("login_shell", DEFAULT_SHELL);
+ newargv[1] = "-c";
+ newargv[2] = command;
+ newargv[3] = NULL;
fprintf(stderr, "X11.app: Launching %s:\n", command);
for(p=newargv; *p; p++) {