Skip to content

Commit

Permalink
Let pr_system_cb() set the CUPS_SERVERBIN env variable
Browse files Browse the repository at this point in the history
If CUPS_SERVERBIN is not set and FILTER_DIR is set to a path ending
with "/filter", we set CUP_SERVERBIN to the value of FILTER_DIR minus
the "/filter" at the end. This way CUPS filters in the FILTER_DIR,
called by filterExternalCUPS() of cups-filters get an environment as
close as to the one of CUPS as possible.
  • Loading branch information
tillkamppeter committed Oct 18, 2021
1 parent eea77fb commit 1f49862
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pappl-retrofit/pappl-retrofit.c
Expand Up @@ -4286,6 +4286,7 @@ pr_system_cb(int num_options, // I - Number of options
pappl_loglevel_t loglevel; // Log level
int port = 0; // Port number, if any
char *ptr;
char buf[1024];
pappl_soptions_t soptions = PAPPL_SOPTIONS_MULTI_QUEUE |
PAPPL_SOPTIONS_WEB_INTERFACE |
PAPPL_SOPTIONS_WEB_LOG |
Expand Down Expand Up @@ -4390,6 +4391,20 @@ pr_system_cb(int num_options, // I - Number of options
snprintf(global_data->filter_dir, sizeof(global_data->filter_dir),
"/usr/lib/%s/filter", global_data->config->system_package_name);

// Set CUPS_SERVERBIN (only if not already set and if FILTER_DIR ends
// with "/filter"). This gives the best possible environment to the
// CUPS filters when they are called out of the Printer Application.
if (getenv("CUPS_SERVERBIN") == NULL && strlen(global_data->filter_dir) > 7)
{
strncpy(buf, global_data->filter_dir, sizeof(buf));
ptr = buf + strlen(buf) - 7;
if (strcmp(ptr, "/filter") == 0)
{
*ptr = '\0';
setenv("CUPS_SERVERBIN", buf, 1);
}
}

// CUPS Backend dir
if (global_data->config->components & PR_COPTIONS_CUPS_BACKENDS)
{
Expand Down

0 comments on commit 1f49862

Please sign in to comment.