Skip to content

Commit

Permalink
always do chdir after fork otherwise commands can fail with unreachab…
Browse files Browse the repository at this point in the history
…le location
  • Loading branch information
jreidinger committed Oct 17, 2013
1 parent bb3a672 commit 57fc29a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions agent-any/src/AnyAgent.cc
Expand Up @@ -672,6 +672,10 @@ static FILE* program_stream(const char *s, SCRAgent* agent)
int res = chroot(agent->root());
if (res == -1)
_exit(1);

// Do not allow touch outside of chroot especially `cd ~` can
// cause errors
chdir("/");
}
// lets ignore if it fails, we even cannot log here
setenv ("LC_ALL", "C", 1);
Expand Down
4 changes: 4 additions & 0 deletions agent-system/src/ShellCommand.cc
Expand Up @@ -159,6 +159,10 @@ shellcommand ( const string &target_root, const string &command, const string &t
// y2error ("chroot failed, errno: %d", errno);
_exit(1);
}

// Do not allow touch outside of chroot especially `cd ~` can
// cause errors
chdir("/");
}

ret = system (command.c_str ());
Expand Down

0 comments on commit 57fc29a

Please sign in to comment.