Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Fix a bug setting argv[0+X] on the child PBI in the container
Browse files Browse the repository at this point in the history
Fixes an issue with wine starting its 'wineloader' application
  • Loading branch information
Kris Moore committed Jan 13, 2014
1 parent 58ffcd7 commit a31a662
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src-sh/pbi-manager/pbime/pbime.c
Expand Up @@ -85,7 +85,9 @@ main(int argc, char *argv[])
char mountscript[4096]; char mountscript[4096];
char pipetemplate[] = "/tmp/.pbi-callback-XXXXXXXXXXXXXXXX"; char pipetemplate[] = "/tmp/.pbi-callback-XXXXXXXXXXXXXXXX";
char *pipedir; char *pipedir;
char *newargv[1024];
char fifoin[MAXPATHLEN]; char fifoin[MAXPATHLEN];
char newlibdir[MAXPATHLEN];
int argoffset; int argoffset;


pid_t listen_pid; pid_t listen_pid;
Expand Down Expand Up @@ -162,12 +164,28 @@ main(int argc, char *argv[])
argoffset=3; argoffset=3;
} }


// Setup the newargv with right stack
for ( int i = argoffset; i<argc; i++)
{
newargv[i-argoffset] = argv[i];
if ( i > 1020 ) {
err(1, "Too many args...");
}
}
newargv[0] = argv[3];

// Make sure 32bit compat is enabled
strncat(newlibdir, "/usr/local", (strlen("/usr/local") ));
strcat(newlibdir, "/lib");
setenv("LD_32_LIBRARY_PATH", newlibdir, 1);


// Fork off the PBI process, and have the parent wait for it to finish // Fork off the PBI process, and have the parent wait for it to finish
app_pid = fork(); app_pid = fork();
if(app_pid == 0) { if(app_pid == 0) {
// Execute the PBI now // Execute the PBI now
if (execvp(argv[3], argv + argoffset) == -1) printf( "newargv[0]: %s \n", newargv[0]);
printf( "newargv[1]: %s \n", newargv[1]);
if (execvp(argv[3], newargv) == -1)
err(1, "execvp(): %s", argv[3]); err(1, "execvp(): %s", argv[3]);
exit(0); exit(0);
} else { } else {
Expand Down

0 comments on commit a31a662

Please sign in to comment.