*** fakechroot-2.8/src/libfakechroot.c 2008-07-25 14:50:52.000000000 +0100 --- fakechroot-dev/src/libfakechroot.c 2009-03-10 17:54:15.000000000 +0000 *************** *** 360,366 **** /* static int (*next_execlp) (const char *file, const char *arg, ...) = NULL; */ /* static int (*next_execv) (const char *path, char *const argv []) = NULL; */ static int (*next_execve) (const char *filename, char *const argv [], char *const envp[]) = NULL; ! static int (*next_execvp) (const char *file, char *const argv []) = NULL; #ifdef HAVE_FCHMODAT static int (*next_fchmodat) (int dirfd, const char *path, mode_t mode, int flag) = NULL; #endif --- 360,367 ---- /* static int (*next_execlp) (const char *file, const char *arg, ...) = NULL; */ /* static int (*next_execv) (const char *path, char *const argv []) = NULL; */ static int (*next_execve) (const char *filename, char *const argv [], char *const envp[]) = NULL; ! /* static int (*next_execvp) (const char *file, char *const argv []) = NULL; */ ! static int (*next_system) (const char *command) = NULL; #ifdef HAVE_FCHMODAT static int (*next_fchmodat) (int dirfd, const char *path, mode_t mode, int flag) = NULL; #endif *************** *** 629,635 **** /* nextsym(execlp, "execlp"); */ /* nextsym(execv, "execv"); */ nextsym(execve, "execve"); ! nextsym(execvp, "execvp"); #ifdef HAVE_FCHMODAT nextsym(fchmodat, "fchmodat"); #endif --- 630,637 ---- /* nextsym(execlp, "execlp"); */ /* nextsym(execv, "execv"); */ nextsym(execve, "execve"); ! nextsym(system, "system"); ! /* nextsym(execvp, "execvp"); */ #ifdef HAVE_FCHMODAT nextsym(fchmodat, "fchmodat"); #endif *************** *** 1419,1426 **** va_end (args); expand_chroot_path(file, fakechroot_path, fakechroot_ptr, fakechroot_buf); ! if (next_execvp == NULL) fakechroot_init(); ! return next_execvp (file, (char *const *) argv); } --- 1421,1427 ---- va_end (args); expand_chroot_path(file, fakechroot_path, fakechroot_ptr, fakechroot_buf); ! return execve(file, (char *const *) argv,environ); } *************** *** 1430,1435 **** --- 1431,1445 ---- return execve (path, argv, environ); } + int system(const char *command) { + + const char **newargv = alloca (4 * sizeof (const char *)); + newargv[0]="/bin/sh"; + newargv[1]="-c"; + newargv[2]=command; + newargv[3]=NULL; + return execve("/bin/sh",newargv,environ); + } /* #include */ int execve (const char *filename, char *const argv [], char *const envp[]) *************** *** 1462,1471 **** return -1; } - if (next_execve == NULL) fakechroot_init(); - if (hashbang[0] != '#' || hashbang[1] != '!') ! return next_execve(filename, argv, envp); hashbang[i] = hashbang[i+1] = 0; for (i = j = 2; (hashbang[i] == ' ' || hashbang[i] == '\t') && i < FAKECHROOT_MAXPATH; i++, j++); --- 1472,1479 ---- return -1; } if (hashbang[0] != '#' || hashbang[1] != '!') ! return execve_ld(filename, argv, envp); hashbang[i] = hashbang[i+1] = 0; for (i = j = 2; (hashbang[i] == ' ' || hashbang[i] == '\t') && i < FAKECHROOT_MAXPATH; i++, j++); *************** *** 1495,1503 **** newargv[n] = 0; ! return next_execve(newfilename, (char *const *)newargv, envp); } /* #include */ int execvp (const char *file, char *const argv []) --- 1503,1541 ---- newargv[n] = 0; ! return execve_ld(newfilename, (char *const *)newargv, envp); } + /* This routine modifies the default interpretor used for programm execution */ + int execve_ld (const char *filename, char *const argv [], char *const envp[]) { + + size_t argv_max = 1024; + const char **newargv = alloca (argv_max * sizeof (const char *)); + + char *ld_path; + + if (next_execve == NULL) fakechroot_init(); + + ld_path = getenv("FAKECHROOT_LD"); + + if (ld_path == NULL) { + next_execve(filename,argv,envp); + } + + newargv[0] = argv[0]; + newargv[1] = filename; + int n=1; + int i; + + for (i = 1; argv[i-1] != NULL && i */ int execvp (const char *file, char *const argv [])