cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
902636
From 7a1860c83ff042f3e796c449e780ee0528107213 Mon Sep 17 00:00:00 2001
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
Date: Tue, 3 Mar 2020 18:43:08 +0000
902636
Subject: [PATCH 12/18] virtiofsd: Remove fuse_req_getgroups
902636
MIME-Version: 1.0
902636
Content-Type: text/plain; charset=UTF-8
902636
Content-Transfer-Encoding: 8bit
902636
902636
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Message-id: <20200303184314.155564-2-dgilbert@redhat.com>
902636
Patchwork-id: 94122
902636
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/7] virtiofsd: Remove fuse_req_getgroups
902636
Bugzilla: 1797064
902636
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
902636
RH-Acked-by: Ján Tomko <jtomko@redhat.com>
902636
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
902636
Remove fuse_req_getgroups that's unused in virtiofsd; it came in
902636
from libfuse but we don't actually use it.  It was called from
902636
fuse_getgroups which we previously removed (but had left it's header
902636
in).
902636
902636
Coverity had complained about null termination in it, but removing
902636
it is the easiest answer.
902636
902636
Fixes: Coverity CID: 1413117 (String not null terminated)
902636
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
(cherry picked from commit 988717b46b6424907618cb845ace9d69062703af)
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 tools/virtiofsd/fuse.h          | 20 -----------
902636
 tools/virtiofsd/fuse_lowlevel.c | 77 -----------------------------------------
902636
 tools/virtiofsd/fuse_lowlevel.h | 21 -----------
902636
 3 files changed, 118 deletions(-)
902636
902636
diff --git a/tools/virtiofsd/fuse.h b/tools/virtiofsd/fuse.h
902636
index 7a4c713..aba13fe 100644
902636
--- a/tools/virtiofsd/fuse.h
902636
+++ b/tools/virtiofsd/fuse.h
902636
@@ -1007,26 +1007,6 @@ void fuse_exit(struct fuse *f);
902636
 struct fuse_context *fuse_get_context(void);
902636
 
902636
 /**
902636
- * Get the current supplementary group IDs for the current request
902636
- *
902636
- * Similar to the getgroups(2) system call, except the return value is
902636
- * always the total number of group IDs, even if it is larger than the
902636
- * specified size.
902636
- *
902636
- * The current fuse kernel module in linux (as of 2.6.30) doesn't pass
902636
- * the group list to userspace, hence this function needs to parse
902636
- * "/proc/$TID/task/$TID/status" to get the group IDs.
902636
- *
902636
- * This feature may not be supported on all operating systems.  In
902636
- * such a case this function will return -ENOSYS.
902636
- *
902636
- * @param size size of given array
902636
- * @param list array of group IDs to be filled in
902636
- * @return the total number of supplementary group IDs or -errno on failure
902636
- */
902636
-int fuse_getgroups(int size, gid_t list[]);
902636
-
902636
-/**
902636
  * Check if the current request has already been interrupted
902636
  *
902636
  * @return 1 if the request has been interrupted, 0 otherwise
902636
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
902636
index de2e2e0..01c418a 100644
902636
--- a/tools/virtiofsd/fuse_lowlevel.c
902636
+++ b/tools/virtiofsd/fuse_lowlevel.c
902636
@@ -2667,83 +2667,6 @@ int fuse_lowlevel_is_virtio(struct fuse_session *se)
902636
     return !!se->virtio_dev;
902636
 }
902636
 
902636
-#ifdef linux
902636
-int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
902636
-{
902636
-    char *buf;
902636
-    size_t bufsize = 1024;
902636
-    char path[128];
902636
-    int ret;
902636
-    int fd;
902636
-    unsigned long pid = req->ctx.pid;
902636
-    char *s;
902636
-
902636
-    sprintf(path, "/proc/%lu/task/%lu/status", pid, pid);
902636
-
902636
-retry:
902636
-    buf = malloc(bufsize);
902636
-    if (buf == NULL) {
902636
-        return -ENOMEM;
902636
-    }
902636
-
902636
-    ret = -EIO;
902636
-    fd = open(path, O_RDONLY);
902636
-    if (fd == -1) {
902636
-        goto out_free;
902636
-    }
902636
-
902636
-    ret = read(fd, buf, bufsize);
902636
-    close(fd);
902636
-    if (ret < 0) {
902636
-        ret = -EIO;
902636
-        goto out_free;
902636
-    }
902636
-
902636
-    if ((size_t)ret == bufsize) {
902636
-        free(buf);
902636
-        bufsize *= 4;
902636
-        goto retry;
902636
-    }
902636
-
902636
-    ret = -EIO;
902636
-    s = strstr(buf, "\nGroups:");
902636
-    if (s == NULL) {
902636
-        goto out_free;
902636
-    }
902636
-
902636
-    s += 8;
902636
-    ret = 0;
902636
-    while (1) {
902636
-        char *end;
902636
-        unsigned long val = strtoul(s, &end, 0);
902636
-        if (end == s) {
902636
-            break;
902636
-        }
902636
-
902636
-        s = end;
902636
-        if (ret < size) {
902636
-            list[ret] = val;
902636
-        }
902636
-        ret++;
902636
-    }
902636
-
902636
-out_free:
902636
-    free(buf);
902636
-    return ret;
902636
-}
902636
-#else /* linux */
902636
-/*
902636
- * This is currently not implemented on other than Linux...
902636
- */
902636
-int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
902636
-{
902636
-    (void)req;
902636
-    (void)size;
902636
-    (void)list;
902636
-    return -ENOSYS;
902636
-}
902636
-#endif
902636
-
902636
 void fuse_session_exit(struct fuse_session *se)
902636
 {
902636
     se->exited = 1;
902636
diff --git a/tools/virtiofsd/fuse_lowlevel.h b/tools/virtiofsd/fuse_lowlevel.h
902636
index 138041e..8f6d705 100644
902636
--- a/tools/virtiofsd/fuse_lowlevel.h
902636
+++ b/tools/virtiofsd/fuse_lowlevel.h
902636
@@ -1705,27 +1705,6 @@ void *fuse_req_userdata(fuse_req_t req);
902636
 const struct fuse_ctx *fuse_req_ctx(fuse_req_t req);
902636
 
902636
 /**
902636
- * Get the current supplementary group IDs for the specified request
902636
- *
902636
- * Similar to the getgroups(2) system call, except the return value is
902636
- * always the total number of group IDs, even if it is larger than the
902636
- * specified size.
902636
- *
902636
- * The current fuse kernel module in linux (as of 2.6.30) doesn't pass
902636
- * the group list to userspace, hence this function needs to parse
902636
- * "/proc/$TID/task/$TID/status" to get the group IDs.
902636
- *
902636
- * This feature may not be supported on all operating systems.  In
902636
- * such a case this function will return -ENOSYS.
902636
- *
902636
- * @param req request handle
902636
- * @param size size of given array
902636
- * @param list array of group IDs to be filled in
902636
- * @return the total number of supplementary group IDs or -errno on failure
902636
- */
902636
-int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[]);
902636
-
902636
-/**
902636
  * Callback function for an interrupt
902636
  *
902636
  * @param req interrupted request
902636
-- 
902636
1.8.3.1
902636