B
blacklight
I'm experiencing a weird behaviour in executing programs in a chroot()
environment. This is the situation.
I have a path like this:
/p +
|--> /p/popen
|--> /p/exe
This is popen.c:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main ( int argc, char *argv[] )
{
FILE *pipe;
char ch;
if (chroot("/p") < 0)
return EXIT_FAILURE;
if (!(pipe = popen("/exe", "r")))
return EXIT_FAILURE;
printf ("RESULT: ");
while (fread(&ch, 1, 1, pipe) > 0)
printf ("%c", ch);
printf ("\n");
pclose(pipe);
return EXIT_SUCCESS;
}
popen() does not fail, but just no character is read. Of course if I do not use
chroot() and i just call popen ("./exe", "r") I have no problem. I also have
tried popen-ing "./exe" and "exe", both without any results. Even calling a
system() on "/exe", "./exe" or "exe" gives no results. So, how do I invoke an
executable file in a chroot() environment?
Thanks,
BlackLight
environment. This is the situation.
I have a path like this:
/p +
|--> /p/popen
|--> /p/exe
This is popen.c:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main ( int argc, char *argv[] )
{
FILE *pipe;
char ch;
if (chroot("/p") < 0)
return EXIT_FAILURE;
if (!(pipe = popen("/exe", "r")))
return EXIT_FAILURE;
printf ("RESULT: ");
while (fread(&ch, 1, 1, pipe) > 0)
printf ("%c", ch);
printf ("\n");
pclose(pipe);
return EXIT_SUCCESS;
}
popen() does not fail, but just no character is read. Of course if I do not use
chroot() and i just call popen ("./exe", "r") I have no problem. I also have
tried popen-ing "./exe" and "exe", both without any results. Even calling a
system() on "/exe", "./exe" or "exe" gives no results. So, how do I invoke an
executable file in a chroot() environment?
Thanks,
BlackLight