]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemusecuritytest: Don't call real virFileExists in mock
authorJim Fehlig <jfehlig@suse.com>
Mon, 8 Apr 2024 18:40:42 +0000 (12:40 -0600)
committerJim Fehlig <jfehlig@suse.com>
Mon, 8 Apr 2024 20:40:02 +0000 (14:40 -0600)
Calling the real virFileExists in qemusecuritymock.c can cause a
segfault in qemusecuritytest. No segfaults are noticed when calling
access(2) instead of virFileExists.

Fixes: 4ed5ade753d8f1136cdbf17ddfe1d9093bcd933d
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
tests/qemusecuritymock.c

index a7bb1f8bea9c392674a911b8e95a7333ea3dcac4..dc8a893e9d55ff7f7021db4320152f4aca0af321 100644 (file)
@@ -66,7 +66,6 @@ static int (*real_close)(int fd);
 static int (*real_setfilecon_raw)(const char *path, const char *context);
 static int (*real_getfilecon_raw)(const char *path, char **context);
 #endif
-static bool (*real_virFileExists)(const char *file);
 
 
 /* Global mutex to avoid races */
@@ -124,7 +123,6 @@ init_syms(void)
     VIR_MOCK_REAL_INIT(setfilecon_raw);
     VIR_MOCK_REAL_INIT(getfilecon_raw);
 #endif
-    VIR_MOCK_REAL_INIT(virFileExists);
 
     /* Intentionally not calling init_hash() here */
 }
@@ -389,7 +387,7 @@ bool virFileExists(const char *path)
     VIR_LOCK_GUARD lock = virLockGuardLock(&m);
 
     if (getenv(ENVVAR) == NULL)
-        return real_virFileExists(path);
+        return access(path, F_OK) == 0;
 
     init_hash();
     if (virHashHasEntry(chown_paths, path))