[systemd-devel] tmpfile white listing [PATCH]v2

Lennart Poettering lennart at poettering.net
Tue Apr 26 11:53:09 PDT 2011


On Mon, 25.04.11 14:38, William Douglas (william.r.douglas at gmail.com) wrote:

> Hello all,

heya,
> 
> Below is an updated patch for tmpfile white listing.

Hmm, please don't put patches after the "-- " line in your mails. I have
trouble responding to your patch mail that way, since my mailer cuts off
signatures (i.e. everything after "-- ") automatically on reply.

But a few comments:

I am not sure I understand why we need another hashmap "kept" for
this. The existing two should be fine.

Also, why first explode the list of files matching with glob()? The
fnmatch() pattern matching looks much simpler and safer to me (and
race-free too). You should be able to pass a callback based on the
existing find_glob() call to rm_rf(). Would be simpler and more code to
reuse. For example, you could move            

if (hashmap_get(items, sub_path))
        ....

if (find_glob(globs, sub_path))
        ....

into your protected() function. And replace the current invocations of
the lines above with invocations of protected(). By doing that the
existing code would become easier and shorter and simpler to read, even.

The rm_rf_children() call needs proper cleanup handling when asprintf()
fails due to OOM. You need to release d for example afaics.

Otherwise the patch looks fine to me. If you make these changes I am
happy to merge it.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list