summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-07-16 16:34:35 +0300
committerTimo Teräs <timo.teras@iki.fi>2012-07-16 16:34:35 +0300
commit0999ec9533688ac54b332b90d238a5801c9ee6f7 (patch)
treec4058f98be32544e6a2716130cf536a7428b5b34
parentea5b08d1d574ae90ad6347a4d2f0a69bb656c7af (diff)
downloadapk-tools-0999ec9533688ac54b332b90d238a5801c9ee6f7.tar.gz
apk-tools-0999ec9533688ac54b332b90d238a5801c9ee6f7.tar.bz2
apk-tools-0999ec9533688ac54b332b90d238a5801c9ee6f7.tar.xz
apk-tools-0999ec9533688ac54b332b90d238a5801c9ee6f7.zip
audit: report new directories in recurse mode too
Add new 'd' flag for it.
-rw-r--r--src/audit.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/audit.c b/src/audit.c
index a3382a3..3631518 100644
--- a/src/audit.c
+++ b/src/audit.c
@@ -103,8 +103,8 @@ static int audit_directory(struct audit_ctx *actx,
struct apk_db_dir *dbd,
struct apk_file_info *fi)
{
- if (dbd == NULL)
- return 'D';
+ if (dbd == NULL || dbd->refs == 1)
+ return actx->recursive ? 'd' : 'D';
if (actx->check_permissions &&
(dbd->mode != 0 || dbd->uid != 0 || dbd->gid != 0)) {
@@ -171,26 +171,19 @@ static int audit_directory_tree_item(void *ctx, int dirfd, const char *name)
} else {
child = apk_db_dir_query(db, bfull);
if (child == NULL)
- recurse = FALSE;
- else
- child = apk_db_dir_ref(child);
+ goto done;
+ child = apk_db_dir_ref(child);
}
reason = audit_directory(actx, db, child, &fi);
if (reason < 0)
goto done;
- if (reason == 'D') {
- if (actx->mode == MODE_SYSTEM)
- goto done;
- if (!actx->recursive)
- recurse = FALSE;
- }
recurse_check:
atctx->path[atctx->pathlen++] = '/';
bfull.len++;
report_audit(actx, reason, bfull, NULL);
- if (recurse) {
+ if (reason != 'D' && recurse) {
atctx->dir = child;
reason = apk_dir_foreach_file(
openat(dirfd, name, O_RDONLY|O_CLOEXEC),