[gnome-control-center/gnome-3-6] printers: Resolve symlink when passing a PPD to CUPS



commit 80c1f5a79da01091f93eb48ed686192781852efe
Author: Marek Kasik <mkasik redhat com>
Date:   Thu Oct 18 11:35:14 2012 +0200

    printers: Resolve symlink when passing a PPD to CUPS
    
    root is not able to resolve symlinks in /tmp/ created by ordinary users
    because of a new policy and PPDs got from CUPS are symlinks to /etc/cups/ppd/*
    placed to /tmp/.
    Since we need to pass PPD file of original printer to CUPS when renaming
    a printer we resolve given symlink and pass original filename to the CUPS.

 panels/printers/pp-utils.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/panels/printers/pp-utils.c b/panels/printers/pp-utils.c
index 489e5b1..b34ee5e 100644
--- a/panels/printers/pp-utils.c
+++ b/panels/printers/pp-utils.c
@@ -359,7 +359,6 @@ printer_rename (const gchar *old_name,
   cups_job_t       *jobs = NULL;
   GDBusConnection  *bus;
   const char       *printer_location = NULL;
-  const char       *ppd_filename = NULL;
   const char       *printer_info = NULL;
   const char       *printer_uri = NULL;
   const char       *device_uri = NULL;
@@ -371,6 +370,8 @@ printer_rename (const gchar *old_name,
   gboolean          printer_shared = FALSE;
   GError           *error = NULL;
   http_t           *http;
+  gchar            *ppd_link;
+  gchar            *ppd_filename = NULL;
   gchar           **sheets = NULL;
   gchar           **users_allowed = NULL;
   gchar           **users_denied = NULL;
@@ -526,7 +527,15 @@ printer_rename (const gchar *old_name,
         }
     }
 
-  ppd_filename = cupsGetPPD (old_name);
+  ppd_link = g_strdup (cupsGetPPD (old_name));
+  if (ppd_link)
+    {
+      ppd_filename = g_file_read_link (ppd_link, NULL);
+
+      if (!ppd_filename)
+        ppd_filename = g_strdup (ppd_link);
+    }
+
 
   bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
   if (!bus)
@@ -582,8 +591,12 @@ printer_rename (const gchar *old_name,
         }
     }
 
-  if (ppd_filename)
-    g_unlink (ppd_filename);
+  if (ppd_link)
+    {
+      g_unlink (ppd_link);
+      g_free (ppd_link);
+      g_free (ppd_filename);
+    }
 
   num_dests = cupsGetDests (&dests);
   dest = cupsGetDest (new_name, NULL, num_dests, dests);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]