From c6b32d6801e17fddb2974859145efc309c0894c9 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Wed, 30 Sep 2015 17:25:34 -0400 Subject: [PATCH] virfile: Add extra check for direct delete in virFileRemove Unlike create options, if the file to be removed is already in the pool, then the uid/gid will come from the pool. If it's the same as the currently running process, then just do the unlink/rmdir directly rather than going through the fork processing unnecessarily --- src/util/virfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 2332589d0..3d7efdc15 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -2316,10 +2316,11 @@ virFileRemove(const char *path, int ngroups; /* If not running as root or if a non explicit uid/gid was being used for - * the file/volume, then use unlink directly + * the file/volume or the explicit uid/gid matches, then use unlink directly */ if ((geteuid() != 0) || - ((uid == (uid_t) -1) && (gid == (gid_t) -1))) { + ((uid == (uid_t) -1) && (gid == (gid_t) -1)) || + (uid == geteuid() && gid == getegid())) { if (virFileIsDir(path)) return rmdir(path); else -- 2.39.5