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.
This commit is contained in:
parent
8afea39c60
commit
a153f43b4e
1 changed files with 17 additions and 4 deletions
|
@ -359,7 +359,6 @@ printer_rename (const gchar *old_name,
|
||||||
cups_job_t *jobs = NULL;
|
cups_job_t *jobs = NULL;
|
||||||
GDBusConnection *bus;
|
GDBusConnection *bus;
|
||||||
const char *printer_location = NULL;
|
const char *printer_location = NULL;
|
||||||
const char *ppd_filename = NULL;
|
|
||||||
const char *printer_info = NULL;
|
const char *printer_info = NULL;
|
||||||
const char *printer_uri = NULL;
|
const char *printer_uri = NULL;
|
||||||
const char *device_uri = NULL;
|
const char *device_uri = NULL;
|
||||||
|
@ -371,6 +370,8 @@ printer_rename (const gchar *old_name,
|
||||||
gboolean printer_shared = FALSE;
|
gboolean printer_shared = FALSE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
http_t *http;
|
http_t *http;
|
||||||
|
gchar *ppd_link;
|
||||||
|
gchar *ppd_filename = NULL;
|
||||||
gchar **sheets = NULL;
|
gchar **sheets = NULL;
|
||||||
gchar **users_allowed = NULL;
|
gchar **users_allowed = NULL;
|
||||||
gchar **users_denied = 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);
|
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
if (!bus)
|
if (!bus)
|
||||||
|
@ -582,8 +591,12 @@ printer_rename (const gchar *old_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ppd_filename)
|
if (ppd_link)
|
||||||
g_unlink (ppd_filename);
|
{
|
||||||
|
g_unlink (ppd_link);
|
||||||
|
g_free (ppd_link);
|
||||||
|
g_free (ppd_filename);
|
||||||
|
}
|
||||||
|
|
||||||
num_dests = cupsGetDests (&dests);
|
num_dests = cupsGetDests (&dests);
|
||||||
dest = cupsGetDest (new_name, NULL, num_dests, dests);
|
dest = cupsGetDest (new_name, NULL, num_dests, dests);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue