libminijail: add marshalling and scrubbing functions

In order to support arbitrary divisions of labor between minijail_run
and minijail_enter, we need to support serializing the entire minijail
for sharing with the LD_PRELOADed library in a child process.  Instead
of continuing with one-off marshalling, this unify the marshalling code
(as fragile as it is).

In addition, scrubbing features that only apply in the parent or the
child around marshalling and unmarshalling are split out to separate the
logic.

One change did sneak in to support marshalling which was copying/freeing
j->user. I can split this out as a precursor patch if needed.

The next change in the series converts the existing code over and moves it
to communicate over a file descriptor.

BUG=chromium-os:19459
TEST=gmerged and ran minijail0. Internal only changes.

Change-Id: Ib4c157d1d4d4edf6910793ea04880399e539285b
Reviewed-on: http://gerrit.chromium.org/gerrit/7891
Reviewed-by: Elly Jones <[email protected]>
Tested-by: Will Drewry <[email protected]>
3 files changed