[CRIU] [PATCH 2/3] Issue #360: Anonymize image files

Harshavardhan Unnibhavi hvubfoss at gmail.com
Tue Jun 25 14:36:51 MSK 2019


On Mon, Jun 24, 2019 at 5:08 PM Pavel Emelianov <xemul at virtuozzo.com> wrote:
>
>
> >  def anonymize(opts):
> > -     pass
> > +     try:
> > +             os.stat(opts['out'])
> > +     except:
> > +             os.mkdir(opts['out'])
> > +
> > +     img_files = os.listdir(opts['in'])
> > +
> > +     for i in img_files:
> > +             temp = {'in':os.path.join(opts['in'], i)}
> >
> > +             try:
> > +                     m, img = pycriu.images.load(inf(temp), anon_info = True)
> > +             except pycriu.images.MagicException as exc:
> > +                     print("Unknown magic %#x.\n"\
> > +                                     "Found a raw image, continuing ..."% exc.magic, file=sys.stderr)
> > +                     continue
> > +
> >
> >  explorers = { 'ps': explore_ps, 'fds': explore_fds, 'mems': explore_mems, 'rss': explore_rss }
> >
> > diff --git a/lib/py/images/images.py b/lib/py/images/images.py
> > index 7a9b9da6..a411ffc4 100644
> > --- a/lib/py/images/images.py
> > +++ b/lib/py/images/images.py
> > @@ -528,7 +528,7 @@ def __rhandler(f):
> >
> >       return m, handler
> >
> > -def load(f, pretty = False, no_payload = False):
> > +def load(f, pretty = False, no_payload = False, anon_info = False):
> >       """
> >       Convert criu image from binary format to dict(json).
> >       Takes a file-like object to read criu image from.
> > @@ -541,6 +541,9 @@ def load(f, pretty = False, no_payload = False):
> >       image['magic'] = m
> >       image['entries'] = handler.load(f, pretty, no_payload)
> >
> > +     if anon_info:
> > +             return m, image
>
> Please, don't do this, as the value of "m" is available as "image['magic']" already, so your above
> code line
>
>     m, img = pycriu.images.load(inf(temp), anon_info = True)
>
> would look like
>
>     img = pycriu.images.load(inf(temp))
>     m = img['magic']
>
Thanks, I will change it and send a revised v2 patch.
> -- Pavel

-- Harsha


More information about the CRIU mailing list