Blob Blame History Raw
From 9a11a1f4de8a26999485148c5a78e160e8880f17 Mon Sep 17 00:00:00 2001
From: Nicolas Fella <nicolas.fella@gmx.de>
Date: Fri, 13 Mar 2020 00:18:01 +0100
Subject: [PATCH 34/44] Fix authentication

Summary:
According to the CUPS code (https://github.com/apple/cups/blob/master/cups/auth.c#L105) cupsDoAuthentication returns 0 on success and -1 on error. The code was assuming the opposite

Now the CUPS password dialog is shown when needed. This is quite often, e.g directly at startup due to getServerSettings() so it might be worth checking if that's really necessary.

BUG: 408512

Test Plan: Open print-manager with a user that is not in a CUPS system group. Privileged operations work after entering a password

Reviewers: dantti, broulik

Reviewed By: dantti

Subscribers: ognarb, rdieter, kde-utils-devel

Differential Revision: https://phabricator.kde.org/D23403
---
 libkcups/KCupsConnection.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libkcups/KCupsConnection.cpp b/libkcups/KCupsConnection.cpp
index 57976b6..784a37c 100644
--- a/libkcups/KCupsConnection.cpp
+++ b/libkcups/KCupsConnection.cpp
@@ -845,11 +845,11 @@ bool KCupsConnection::retry(const char *resource, int operation) const
         // force authentication
         qCDebug(LIBKCUPS) << "Calling cupsDoAuthentication() password_retries:" << password_retries;
         int ret = cupsDoAuthentication(CUPS_HTTP_DEFAULT, "POST", resource);
-        qCDebug(LIBKCUPS) << "Called cupsDoAuthentication(), success:" << (ret == -1 ? true : false);
+        qCDebug(LIBKCUPS) << "Called cupsDoAuthentication(), success:" << (ret == 0);
 
         // If the authentication was successful
         // sometimes just trying to be root works
-        return ret == -1 ? true : false;
+        return ret == 0;
     }
 
     // the action was not forbidden
-- 
2.25.3