/* old library wrapper */
#include <stdio.h>
#include <sched.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mount.h>
typedef struct {
int argc;
char ** argv;
char ** env;
} args;
int clonelib(args * environ)
{
mount("/cad/cds-libs", "/lib", NULL, MS_BIND, NULL);
/* or whatever path you choose for your compatibility libs,
but make that hardcoded here! */
setuid(getuid()); /* drop privilege */
if(environ->argc == 1) {
environ->argv[0] = "/bin/bash";
execve("/bin/bash", environ->argv, environ->env);
} else {
execve(environ->argv[1], environ->argv+1, environ->env);
}
}
int main(int argc, char** argv, char ** env)
{
pid_t pid;
int status;
args environ = { argc, argv, env };
clone(clonelib, malloc(0x1008)+0x1000, CLONE_NEWNS | SIGCHLD, &environ);
wait(&status);
return status;
}