From ea901526648c43ef8e961b3d7e051b9ca14b65ca Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Fri, 31 Jul 2009 16:08:09 +0300 Subject: apk: use *at instead of chdir+normal file syscall this way we never change cwd, and relative filenames are always parsed consistently. this also helps filename construction in many places. this patch also changes '--root' to override location of all configuration to be in the new root. previously it depended on the file which one was used. --- src/audit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/audit.c') diff --git a/src/audit.c b/src/audit.c index 76bd492..6191a2c 100644 --- a/src/audit.c +++ b/src/audit.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -42,7 +43,7 @@ static int audit_directory(apk_hash_item item, void *ctx) if (!(actx->type & AUDIT_BACKUP) && (dbd->flags & APK_DBDIRF_PROTECTED)) return 0; - dir = opendir(dbd->name); + dir = fdopendir(openat(db->root_fd, dbd->name, O_RDONLY)); if (dir == NULL) return 0; @@ -53,7 +54,7 @@ static int audit_directory(apk_hash_item item, void *ctx) snprintf(tmp, sizeof(tmp), "%s/%s", dbd->name, de->d_name); - if (apk_file_get_info(tmp, APK_CHECKSUM_NONE, &fi) < 0) + if (apk_file_get_info(db->root_fd, tmp, APK_CHECKSUM_NONE, &fi) < 0) continue; if (!(actx->type & AUDIT_SYSTEM) && @@ -70,7 +71,7 @@ static int audit_directory(apk_hash_item item, void *ctx) dbf = apk_db_file_query(db, bdir, APK_BLOB_STR(de->d_name)); if (dbf != NULL) { if (dbf->csum.type != APK_CHECKSUM_NONE && - apk_file_get_info(tmp, dbf->csum.type, &fi) == 0 && + apk_file_get_info(db->root_fd, tmp, dbf->csum.type, &fi) == 0 && apk_checksum_compare(&fi.csum, &dbf->csum) == 0) continue; -- cgit v1.2.3