#include
#include
#include
#include
int
main (int argc, char *argv[])
{
int i;
char buf[1024], path[1024];
char *str, *root, *args[512];
/* get FAKE_ROOT */
root = getenv ("FAKE_ROOT");
if (!root) {
fprintf (stderr, "Please set environment FAKE_ROOT!\n");
return -1;
}
/* export PATH */
str = getenv ("PATH");
if (!str) {
fprintf (stderr, "Get environment PATH failed!\n");
return -2;
}
if (NULL == strstr (str, root)) {
strcpy (buf, root);
strcat (buf, "/bin:");
strcat (buf, str);
if (0 != setenv ("PATH", buf, 1)) {
fprintf (stderr, "Set environment PATH failed!\n");
return -3;
}
}
/* export LD_PRELOAD */
strcpy (buf, root);
strcat (buf, "/lib64/libfakemain.so");
if (0 != setenv ("LD_PRELOAD", buf, 1)) {
fprintf (stderr, "Set environment LD_PRELOAD failed!\n");
return -4;
}
/* export LD_LIBRARY_PATH */
strcpy (buf, root);
strcat (buf, "/lib64");
if (0 != setenv ("LD_LIBRARY_PATH", buf, 1)) {
fprintf (stderr, "Set environment LD_LIBRARY_PATH failed!\n");
return -5;
}
/* set new path */
strcpy (path, root);
strcat (path, "/lib64/ld-2.20.so");
args[0] = path;
/* set real program path */
strcpy (buf, root);
strcat (buf, "/bin/");
strcat (buf, argv[0]);
strcat (buf, ".bin");
args[1] = buf;
/* copy arguments */
for (i=1; i
args[i+1] = argv[i];
args[i+1] = NULL;
/* run real program */
return execv (path, args);;
}
#include
#include
#include
#include
int
main (int argc, char *argv[])
{
int i;
char buf[1024], path[1024];
char *str, *root, *args[512];
/* get FAKE_ROOT */
root = getenv ("FAKE_ROOT");
if (!root) {
fprintf (stderr, "Please set environment FAKE_ROOT!\n");
return -1;
}
/* export PATH */
str = getenv ("PATH");
if (!str) {
fprintf (stderr, "Get environment PATH failed!\n");
return -2;
}
if (NULL == strstr (str, root)) {
strcpy (buf, root);
strcat (buf, "/bin:");
strcat (buf, str);
if (0 != setenv ("PATH", buf, 1)) {
fprintf (stderr, "Set environment PATH failed!\n");
return -3;
}
}
/* export LD_PRELOAD */
strcpy (buf, root);
strcat (buf, "/lib64/libfakemain.so");
if (0 != setenv ("LD_PRELOAD", buf, 1)) {
fprintf (stderr, "Set environment LD_PRELOAD failed!\n");
return -4;
}
/* export LD_LIBRARY_PATH */
strcpy (buf, root);
strcat (buf, "/lib64");
if (0 != setenv ("LD_LIBRARY_PATH", buf, 1)) {
fprintf (stderr, "Set environment LD_LIBRARY_PATH failed!\n");
return -5;
}
/* set new path */
strcpy (path, root);
strcat (path, "/lib64/ld-2.20.so");
args[0] = path;
/* set real program path */
strcpy (buf, root);
strcat (buf, "/bin/");
strcat (buf, argv[0]);
strcat (buf, ".bin");
args[1] = buf;
/* copy arguments */
for (i=1; i
args[i+1] = argv[i];
args[i+1] = NULL;
/* run real program */
return execv (path, args);;
}