rpms/cups-pk-helper/devel cups-pk-helper-invalid-job.patch, NONE, 1.1 cups-pk-helper.spec, 1.17, 1.18

Marek Kašík mkasik at fedoraproject.org
Tue Feb 23 13:28:08 UTC 2010


Author: mkasik

Update of /cvs/pkgs/rpms/cups-pk-helper/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv4456

Modified Files:
	cups-pk-helper.spec 
Added Files:
	cups-pk-helper-invalid-job.patch 
Log Message:
* Tue Feb 23 2010 Marek Kasik <mkasik at redhat.com> - 0.0.4-12
- Avoid timeout on job-related methods for invalid jobs
- Make sure to return an error via dbus in case of failure
- Remove a small leak
- Resolves: #548790


cups-pk-helper-invalid-job.patch:
 cups-pk-helper-mechanism.c |   49 ++++++++++++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 11 deletions(-)

--- NEW FILE cups-pk-helper-invalid-job.patch ---
--- cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.c.invalid-job	2010-02-23 13:21:27.000000000 +0100
+++ cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.c	2010-02-23 13:33:08.000000000 +0100
@@ -439,8 +439,11 @@ _cph_mechanism_return_error (CphMechanis
 {
         const char *error;
 
-        if (failed)
+        if (failed) {
                 error = cph_cups_last_status_to_string (mechanism->priv->cups);
+                if (!error || error[0] == '\0')
+                        error = "Unknown error";
+        }
         else
                 error = "";
 
@@ -455,8 +458,11 @@ _cph_mechanism_return_error_and_value (C
 {
         const char *error;
 
-        if (failed)
+        if (failed) {
                 error = cph_cups_last_status_to_string (mechanism->priv->cups);
+                if (!error || error[0] == '\0')
+                        error = "Unknown error";
+        }
         else
                 error = "";
 
@@ -996,18 +1002,25 @@ cph_mechanism_job_cancel (CphMechanism  
                 case CPH_JOB_STATUS_OWNED_BY_USER: {
                         if (!_check_polkit_for_action_v (mechanism, context,
                                                          "job-edit",
-                                                         NULL))
+                                                         NULL)) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
                 case CPH_JOB_STATUS_NOT_OWNED_BY_USER: {
                         if (!_check_polkit_for_action (mechanism, context,
-                                                       "job-not-owned-edit"))
+                                                       "job-not-owned-edit")) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
-                case CPH_JOB_STATUS_INVALID:
+                case CPH_JOB_STATUS_INVALID: {
+                        _cph_mechanism_return_error (mechanism, context, TRUE);
+                        g_free (user_name);
                         return FALSE;
+                }
         }
 
         ret = cph_cups_job_cancel (mechanism->priv->cups, id, user_name);
@@ -1037,18 +1050,25 @@ cph_mechanism_job_restart (CphMechanism 
                 case CPH_JOB_STATUS_OWNED_BY_USER: {
                         if (!_check_polkit_for_action_v (mechanism, context,
                                                          "job-edit",
-                                                         NULL))
+                                                         NULL)) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
                 case CPH_JOB_STATUS_NOT_OWNED_BY_USER: {
                         if (!_check_polkit_for_action (mechanism, context,
-                                                       "job-not-owned-edit"))
+                                                       "job-not-owned-edit")) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
-                case CPH_JOB_STATUS_INVALID:
+                case CPH_JOB_STATUS_INVALID: {
+                        _cph_mechanism_return_error (mechanism, context, TRUE);
+                        g_free (user_name);
                         return FALSE;
+                }
         }
 
         ret = cph_cups_job_restart (mechanism->priv->cups, id, user_name);
@@ -1079,18 +1099,25 @@ cph_mechanism_job_set_hold_until (CphMec
                 case CPH_JOB_STATUS_OWNED_BY_USER: {
                         if (!_check_polkit_for_action_v (mechanism, context,
                                                          "job-edit",
-                                                         NULL))
+                                                         NULL)) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
                 case CPH_JOB_STATUS_NOT_OWNED_BY_USER: {
                         if (!_check_polkit_for_action (mechanism, context,
-                                                       "job-not-owned-edit"))
+                                                       "job-not-owned-edit")) {
+                                g_free (user_name);
                                 return FALSE;
+                        }
                         break;
                 }
-                case CPH_JOB_STATUS_INVALID:
+                case CPH_JOB_STATUS_INVALID: {
+                        _cph_mechanism_return_error (mechanism, context, TRUE);
+                        g_free (user_name);
                         return FALSE;
+                }
         }
 
         ret = cph_cups_job_set_hold_until (mechanism->priv->cups, id, job_hold_until, user_name);


Index: cups-pk-helper.spec
===================================================================
RCS file: /cvs/pkgs/rpms/cups-pk-helper/devel/cups-pk-helper.spec,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -p -r1.17 -r1.18
--- cups-pk-helper.spec	23 Feb 2010 13:24:32 -0000	1.17
+++ cups-pk-helper.spec	23 Feb 2010 13:28:08 -0000	1.18
@@ -1,6 +1,6 @@
 Name:           cups-pk-helper
 Version:        0.0.4
-Release:        11%{?dist}
+Release:        12%{?dist}
 Summary:        A helper that makes system-config-printer use PolicyKit
 
 Group:          System Environment/Base
@@ -16,6 +16,7 @@ Patch4:         cups-pk-helper-ppd-name.
 Patch5:         allow_authentication.patch
 Patch6:         cups-pk-helper-add-printer-ppd-optional.patch
 Patch7:         cups-pk-helper-job-status.patch
+Patch8:         cups-pk-helper-invalid-job.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -53,6 +54,7 @@ interfaces available under control of Po
 %patch5 -p1 -b .allow_auth
 %patch6 -p1 -b .ppd
 %patch7 -p1 -b .job-status
+%patch8 -p1 -b .invalid-job
 
 %build
 # Patch0 modifies configure.ac
@@ -82,6 +84,12 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Tue Feb 23 2010 Marek Kasik <mkasik at redhat.com> - 0.0.4-12
+- Avoid timeout on job-related methods for invalid jobs
+- Make sure to return an error via dbus in case of failure
+- Remove a small leak
+- Resolves: #548790
+
 * Tue Feb 23 2010 Marek Kasik <mkasik at redhat.com> - 0.0.4-11
 - Make cph_cups_job_get_status() efficient
 - Resolves: #548771



More information about the scm-commits mailing list