]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Java, PHP, Perl, and Python scripts did not work properly (STR
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 12 Apr 2007 20:43:54 +0000 (20:43 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 12 Apr 2007 20:43:54 +0000 (20:43 +0000)
#2342)

scheduler/client.c:
    - is_cgi(): Add space to start of options string so that
      pipe_command() knows to pass the script name as an argument
      instead of as path information.
    - pipe_command(): Add AUTH_TYPE, GATEWAY_INTERFACE, and
      SCRIPT_FILENAME environment variables, and discard leading
      space in option string.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@6453 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES-1.2.txt
scheduler/client.c

index 4bea832db4a60504c8d9893c7e472f38958109d2..482cb6660b23e474018d3a927e709af6b3ec175f 100644 (file)
@@ -3,6 +3,13 @@ CHANGES-1.2.txt
 
 CHANGES IN CUPS V1.2.11
 
+       - Java, PHP, Perl, and Python scripts did not work
+         properly (STR #2342)
+       - The scheduler would take forever to start if the
+         maximum number of file descriptors was set to
+         "unlimited" (STR #2329)
+       - The page-ranges option was incorrectly applied to the
+         banner pages (STR #2336)
        - Fixed some GCC compile warnings (STR #2340)
        - The DBUS notification code was broken for older
          versions of DBUS (STR #2327)
index d977e7a158ed59030c6b0547788cd2300d57a625..134613aed572406a5a39ba4ec14cd94c10ebb843 100644 (file)
@@ -3581,9 +3581,9 @@ is_cgi(cupsd_client_t *con,               /* I - Client connection */
     cupsdSetString(&con->command, CUPS_JAVA);
 
     if (options)
-      cupsdSetStringf(&con->options, "%s %s", filename, options);
+      cupsdSetStringf(&con->options, " %s %s", filename, options);
     else
-      cupsdSetString(&con->options, filename);
+      cupsdSetStringf(&con->options, " %s", filename);
 
     cupsdLogMessage(CUPSD_LOG_DEBUG2,
                     "is_cgi: Returning 1 with command=\"%s\" and options=\"%s\"",
@@ -3602,9 +3602,9 @@ is_cgi(cupsd_client_t *con,               /* I - Client connection */
     cupsdSetString(&con->command, CUPS_PERL);
 
     if (options)
-      cupsdSetStringf(&con->options, "%s %s", filename, options);
+      cupsdSetStringf(&con->options, " %s %s", filename, options);
     else
-      cupsdSetString(&con->options, filename);
+      cupsdSetStringf(&con->options, " %s", filename);
 
     cupsdLogMessage(CUPSD_LOG_DEBUG2,
                     "is_cgi: Returning 1 with command=\"%s\" and options=\"%s\"",
@@ -3623,9 +3623,9 @@ is_cgi(cupsd_client_t *con,               /* I - Client connection */
     cupsdSetString(&con->command, CUPS_PHP);
 
     if (options)
-      cupsdSetStringf(&con->options, "%s %s", filename, options);
+      cupsdSetStringf(&con->options, " %s %s", filename, options);
     else
-      cupsdSetString(&con->options, filename);
+      cupsdSetStringf(&con->options, " %s", filename);
 
     cupsdLogMessage(CUPSD_LOG_DEBUG2,
                     "is_cgi: Returning 1 with command=\"%s\" and options=\"%s\"",
@@ -3644,9 +3644,9 @@ is_cgi(cupsd_client_t *con,               /* I - Client connection */
     cupsdSetString(&con->command, CUPS_PYTHON);
 
     if (options)
-      cupsdSetStringf(&con->options, "%s %s", filename, options);
+      cupsdSetStringf(&con->options, " %s %s", filename, options);
     else
-      cupsdSetString(&con->options, filename);
+      cupsdSetStringf(&con->options, " %s", filename);
 
     cupsdLogMessage(CUPSD_LOG_DEBUG2,
                     "is_cgi: Returning 1 with command=\"%s\" and options=\"%s\"",
@@ -4165,8 +4165,9 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
   int          envc;                   /* Number of environment variables */
   char         argbuf[10240],          /* Argument buffer */
                *argv[100],             /* Argument strings */
-               *envp[MAX_ENV + 18];    /* Environment variables */
-  char         content_length[1024],   /* CONTENT_LENGTH environment variable */
+               *envp[MAX_ENV + 20];    /* Environment variables */
+  char         auth_type[256],         /* AUTH_TYPE environment variable */
+               content_length[1024],   /* CONTENT_LENGTH environment variable */
                content_type[1024],     /* CONTENT_TYPE environment variable */
                http_cookie[32768],     /* HTTP_COOKIE environment variable */
                http_referer[1024],     /* HTTP_REFERER environment variable */
@@ -4176,6 +4177,7 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
                remote_addr[1024],      /* REMOTE_ADDR environment variable */
                remote_host[1024],      /* REMOTE_HOST environment variable */
                remote_user[1024],      /* REMOTE_USER environment variable */
+               script_filename[1024],  /* SCRIPT_FILENAME environment variable */
                script_name[1024],      /* SCRIPT_NAME environment variable */
                server_name[1024],      /* SERVER_NAME environment variable */
                server_port[1024];      /* SERVER_PORT environment variable */
@@ -4228,6 +4230,9 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
   {
     commptr      = argbuf;
     path_info[0] = '\0';
+
+    if (*commptr == ' ')
+      commptr ++;
   }
 
   cupsdLogMessage(CUPSD_LOG_INFO, "commptr=\"%s\"", commptr);
@@ -4302,6 +4307,17 @@ pipe_command(cupsd_client_t *con,        /* I - Client connection */
   * Setup the environment variables as needed...
   */
 
+  if (con->username[0])
+  {
+    snprintf(auth_type, sizeof(auth_type), "AUTH_TYPE=%s",
+             httpGetField(HTTP(con), HTTP_FIELD_AUTHORIZATION));
+
+    if ((uriptr = strchr(auth_type + 10, ' ')) != NULL)
+      *uriptr = '\0';
+  }
+  else
+    auth_type[0] = '\0';
+
   if (con->language)
     snprintf(lang, sizeof(lang), "LANG=%s.UTF-8", con->language->language);
   else
@@ -4318,6 +4334,9 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
   if ((uriptr = strchr(script_name, '?')) != NULL)
     *uriptr = '\0';
 
+  snprintf(script_filename, sizeof(script_filename), "SCRIPT_FILENAME=%s%s",
+           DocumentRoot, script_name + 12);
+
   sprintf(server_port, "SERVER_PORT=%d", con->serverport);
 
   snprintf(server_name, sizeof(server_name), "SERVER_NAME=%s",
@@ -4325,13 +4344,18 @@ pipe_command(cupsd_client_t *con,       /* I - Client connection */
 
   envc = cupsdLoadEnv(envp, (int)(sizeof(envp) / sizeof(envp[0])));
 
+  if (auth_type[0])
+    envp[envc ++] = auth_type;
+
   envp[envc ++] = lang;
   envp[envc ++] = "REDIRECT_STATUS=1";
+  envp[envc ++] = "GATEWAY_INTERFACE=CGI/1.1";
   envp[envc ++] = server_name;
   envp[envc ++] = server_port;
   envp[envc ++] = remote_addr;
   envp[envc ++] = remote_host;
   envp[envc ++] = script_name;
+  envp[envc ++] = script_filename;
 
   if (path_info[0])
     envp[envc ++] = path_info;