]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virfile: Add extra check for direct delete in virFileRemove
authorJohn Ferlan <jferlan@redhat.com>
Wed, 30 Sep 2015 21:25:34 +0000 (17:25 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 5 Oct 2015 12:14:44 +0000 (08:14 -0400)
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

index 2332589d0c4b9703fd88c46cbcf0ac9bc18b7cc4..3d7efdc15e0949f81ba64d1994693ef6e2cbf8f8 100644 (file)
@@ -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