[PATCH 5/7] util: Report errors in all code paths in virPolkitAgentCreate

Martin Kletzander posted 7 patches 4 years, 2 months ago
[PATCH 5/7] util: Report errors in all code paths in virPolkitAgentCreate
Posted by Martin Kletzander 4 years, 2 months ago
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 src/util/virpolkit.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/util/virpolkit.c b/src/util/virpolkit.c
index 3b333547d70b..63bb8133a8aa 100644
--- a/src/util/virpolkit.c
+++ b/src/util/virpolkit.c
@@ -180,8 +180,11 @@ virPolkitAgentCreate(void)
     int outfd = STDOUT_FILENO;
     int errfd = STDERR_FILENO;
 
-    if (!isatty(STDIN_FILENO))
+    if (!isatty(STDIN_FILENO)) {
+        virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
+                       _("Cannot start polkit text agent without a tty"));
         goto error;
+    }
 
     if (virPipe(pipe_fd) < 0)
         goto error;
@@ -205,8 +208,11 @@ virPolkitAgentCreate(void)
     pollfd.fd = pipe_fd[0];
     pollfd.events = POLLHUP;
 
-    if (poll(&pollfd, 1, -1) < 0)
+    if (poll(&pollfd, 1, -1) < 0) {
+        virReportSystemError(errno, "%s",
+                             _("error in poll call"));
         goto error;
+    }
 
     return agent;
 
-- 
2.34.0

Re: [PATCH 5/7] util: Report errors in all code paths in virPolkitAgentCreate
Posted by Ján Tomko 4 years, 2 months ago
On a Sunday in 2021, Martin Kletzander wrote:
>Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
>---
> src/util/virpolkit.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano