io: flag for following symlinks on fstat
usually we are interested on the actual file's length. but audit is interested about the link. so add a flag for this and use it in audit.cute-signatures
parent
856181a032
commit
46e9329568
|
@ -88,7 +88,9 @@ size_t apk_ostream_write_string(struct apk_ostream *ostream, const char *string)
|
|||
apk_blob_t apk_blob_from_istream(struct apk_istream *istream, size_t size);
|
||||
apk_blob_t apk_blob_from_file(int atfd, const char *file);
|
||||
|
||||
int apk_file_get_info(int atfd, const char *filename, int checksum,
|
||||
#define APK_FI_NOFOLLOW 0x80000000
|
||||
|
||||
int apk_file_get_info(int atfd, const char *filename, unsigned int flags,
|
||||
struct apk_file_info *fi);
|
||||
int apk_url_download(const char *url, int atfd, const char *file);
|
||||
const char *apk_url_local_file(const char *url);
|
||||
|
|
|
@ -27,7 +27,7 @@ static int audit_file(struct apk_database *db, struct apk_db_file *dbf,
|
|||
{
|
||||
struct apk_file_info fi;
|
||||
|
||||
if (apk_file_get_info(db->root_fd, name, dbf->csum.type, &fi) != 0)
|
||||
if (apk_file_get_info(db->root_fd, name, APK_FI_NOFOLLOW | dbf->csum.type, &fi) != 0)
|
||||
return 1;
|
||||
|
||||
if (dbf->csum.type != APK_CHECKSUM_NONE &&
|
||||
|
@ -62,7 +62,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(db->root_fd, tmp, APK_CHECKSUM_NONE, &fi) < 0)
|
||||
if (apk_file_get_info(db->root_fd, tmp, APK_FI_NOFOLLOW, &fi) < 0)
|
||||
continue;
|
||||
|
||||
if ((dbd->flags & APK_DBDIRF_SYMLINKS_ONLY) &&
|
||||
|
|
8
src/io.c
8
src/io.c
|
@ -463,13 +463,17 @@ err_fd:
|
|||
return APK_BLOB_NULL;
|
||||
}
|
||||
|
||||
int apk_file_get_info(int atfd, const char *filename, int checksum,
|
||||
int apk_file_get_info(int atfd, const char *filename, unsigned int flags,
|
||||
struct apk_file_info *fi)
|
||||
{
|
||||
struct stat64 st;
|
||||
struct apk_bstream *bs;
|
||||
int checksum = flags & 0xffff, atflags = 0;
|
||||
|
||||
if (fstatat64(atfd, filename, &st, AT_SYMLINK_NOFOLLOW) != 0)
|
||||
if (flags & APK_FI_NOFOLLOW)
|
||||
atflags |= AT_SYMLINK_NOFOLLOW;
|
||||
|
||||
if (fstatat64(atfd, filename, &st, atflags) != 0)
|
||||
return -errno;
|
||||
|
||||
*fi = (struct apk_file_info) {
|
||||
|
|
Loading…
Reference in New Issue