提交 c6b32d68 编写于 作者: J John Ferlan

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
上级 938368f8
...@@ -2316,10 +2316,11 @@ virFileRemove(const char *path, ...@@ -2316,10 +2316,11 @@ virFileRemove(const char *path,
int ngroups; int ngroups;
/* If not running as root or if a non explicit uid/gid was being used for /* 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) || 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)) if (virFileIsDir(path))
return rmdir(path); return rmdir(path);
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册