diff options
author | Martin Pitt <martinpitt@users.noreply.github.com> | 2017-04-29 21:19:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-29 21:19:24 +0200 |
commit | 815e542b7caee5166668180c8014e29bfe3bf1f8 (patch) | |
tree | afba4ca09ba29a81ef8f0d8a1850df011a62d36f /src/tmpfiles/tmpfiles.c | |
parent | 5b3cc0c86aeddd4615e7e28e79aa89e5b77a6507 (diff) | |
parent | d8c92e8bc7351f553936b5235e1922c18ebd817a (diff) |
Merge pull request #5809 from keszybz/glob-safe
Implement `safe_glob` that ignores "." and ".."
Diffstat (limited to 'src/tmpfiles/tmpfiles.c')
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index ed6a9adaa6..36488c9a5c 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -1093,19 +1093,14 @@ static int item_do_children(Item *i, const char *path, action_t action) { static int glob_item(Item *i, action_t action, bool recursive) { _cleanup_globfree_ glob_t g = { - .gl_closedir = (void (*)(void *)) closedir, - .gl_readdir = (struct dirent *(*)(void *)) readdir, .gl_opendir = (void *(*)(const char *)) opendir_nomod, - .gl_lstat = lstat, - .gl_stat = stat, }; int r = 0, k; char **fn; - errno = 0; - k = glob(i->path, GLOB_NOSORT|GLOB_BRACE|GLOB_ALTDIRFUNC, NULL, &g); - if (k != 0 && k != GLOB_NOMATCH) - return log_error_errno(errno ?: EIO, "glob(%s) failed: %m", i->path); + k = safe_glob(i->path, GLOB_NOSORT|GLOB_BRACE, &g); + if (k < 0 && k != -ENOENT) + return log_error_errno(k, "glob(%s) failed: %m", i->path); STRV_FOREACH(fn, g.gl_pathv) { k = action(i, *fn); |