Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUERY_STRING env. variable not beeing set #2173

Closed
michaelrsweet opened this issue Dec 24, 2006 · 2 comments
Closed

QUERY_STRING env. variable not beeing set #2173

michaelrsweet opened this issue Dec 24, 2006 · 2 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.2.7
CUPS.org User: opher

Hello all,
I've written a custom CGI that will accept a query string on it's url.
When I browse to this URL:
https://localhost:631/ojobs.cgi?op=modify-job&job_id=63&job_options=cpi=10+lpi=8
I get no QUERY_STRING environment variable.
(error_log follows)

Thanks,
Opher Shachar.

error_log: (log level = debug2)

D [24/Dec/2006:16:31:42 +0200] cupsdReadClient: 16 GET /ojobs.cgi?op=modify-job&job_id=63&job_options=cpi=10+lpi=8 HTTP/1.1
D [24/Dec/2006:16:31:42 +0200] cupsdReadClient: 16 Browser asked for language "he-il.utf-8"...
d [24/Dec/2006:16:31:42 +0200] cupsdFindBest: uri = "/ojobs.cgi?op=modify-job&job_id=63&job_options=cpi=10+lpi=8"...
[snip]
d [24/Dec/2006:16:31:42 +0200] cupsdFindBest: best = /
[snip]
d [24/Dec/2006:16:31:42 +0200] get_file: 16 filename=/usr/share/doc/cups-1.2.7/ojobs.cgi size=3404
d [24/Dec/2006:16:31:42 +0200] is_cgi(con=0x97e6df0, filename="/usr/share/doc/cups-1.2.7/ojobs.cgi", filestats=0xbf852bd4, type=application/x-httpd-cgi)
d [24/Dec/2006:16:31:42 +0200] is_cgi: Returning 1 with command="/usr/share/doc/cups-1.2.7/ojobs.cgi" and options="op=modify-job&job_id=63&job_options=cpi=10+lpi=8"
d [24/Dec/2006:16:31:42 +0200] pipe_command: command="/usr/share/doc/cups-1.2.7/ojobs.cgi", options="op=modify-job&job_id=63&job_options=cpi=10+lpi=8"
d [24/Dec/2006:16:31:42 +0200] argv[0] = "/usr/share/doc/cups-1.2.7/ojobs.cgi"
d [24/Dec/2006:16:31:42 +0200] argv[1] = "op=modify-job&job_id=63&job_options=cpi=10"
d [24/Dec/2006:16:31:42 +0200] argv[2] = "lpi=8"
d [24/Dec/2006:16:31:42 +0200] pipe_command: argv[0] = "/usr/share/doc/cups-1.2.7/ojobs.cgi"
d [24/Dec/2006:16:31:42 +0200] pipe_command: argv[1] = "op=modify-job&job_id=63&job_options=cpi=10"
d [24/Dec/2006:16:31:42 +0200] pipe_command: argv[2] = "lpi=8"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[0] = "CUPS_CACHEDIR=/var/cache/cups"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[1] = "CUPS_DATADIR=/usr/share/cups"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[2] = "CUPS_DOCROOT=/usr/share/doc/cups-1.2.7"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[3] = "CUPS_FONTPATH=/usr/share/cups/fonts"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[4] = "CUPS_REQUESTROOT=/var/spool/cups"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[5] = "CUPS_SERVERBIN=/usr/lib/cups"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[6] = "CUPS_SERVERROOT=/etc/cups"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[7] = "CUPS_STATEDIR=/var/run/cups"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[8] = "PATH=/usr/lib/cups/filter:/usr/bin:/usr/sbin:/bin:/usr/bin"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[9] = "SERVER_ADMIN=root@fc6.ladpc.co.il"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[10] = "SOFTWARE=CUPS/1.2.7"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[11] = "TMPDIR=/var/spool/cups/tmp"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[12] = "USER=root"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[13] = "CUPS_SERVER=/var/run/cups/cups.sock"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[14] = "CUPS_ENCRYPTION=IfRequested"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[15] = "IPP_PORT=631"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[16] = "LANG=he_IL.UTF-8"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[17] = "REDIRECT_STATUS=1"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[18] = "SERVER_NAME=fc6.iula.org.il"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[19] = "SERVER_PORT=631"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[20] = "REMOTE_ADDR=10.236.42.48"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[21] = "REMOTE_HOST=10.236.42.48"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[22] = "SCRIPT_NAME=/ojobs.cgi"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[23] = "SERVER_PROTOCOL=HTTP/1.1"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[24] = "HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; MathPlayer 2.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; FDM)"
d [24/Dec/2006:16:31:42 +0200] pipe_command: envp[25] = "REQUEST_METHOD=GET"
d [24/Dec/2006:16:31:42 +0200] cupsdStartProcess("/usr/share/doc/cups-1.2.7/ojobs.cgi", 0xbf8454e0, 0xbf84530c, -1, 19, 9)
D [24/Dec/2006:16:31:42 +0200] CGI /usr/share/doc/cups-1.2.7/ojobs.cgi started - PID = 11785
I [24/Dec/2006:16:31:42 +0200] Started "/usr/share/doc/cups-1.2.7/ojobs.cgi" (pid=11785)

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"str2173.patch":

Index: client.c

--- client.c (revision 6197)
+++ client.c (working copy)
@@ -623,6 +623,7 @@
cupsdClearString(&con->filename);
cupsdClearString(&con->command);
cupsdClearString(&con->options);

  • cupsdClearString(&con->query_string);

if (con->request)
{
@@ -788,6 +789,7 @@

cupsdClearString(&con->command);
cupsdClearString(&con->options);

  • cupsdClearString(&con->query_string);

if (con->request)
{
@@ -2703,6 +2705,7 @@

cupsdClearString(&con->command);
cupsdClearString(&con->options);

  • cupsdClearString(&con->query_string);

if (!con->http.keep_alive)
{
@@ -3460,8 +3463,13 @@
*/

if ((options = strchr(con->uri, '?')) != NULL)

  • {
    options ++;
  • if (strchr(options, '='))
  •  cupsdSetStringf(&(con->query_string), "QUERY_STRING=%s", options);
    
  • }

/*

  • Check for known types...
    /
    @@ -4064,7 +4072,6 @@
    http_user_agent[1024], /
    HTTP_USER_AGENT environment variable /
    lang[1024], /
    LANG environment variable /
    path_info[1024], /
    PATH_INFO environment variable */

  •   *query_string,      /* QUERY_STRING env variable */
    remote_addr[1024],  /* REMOTE_ADDR environment variable */
    remote_host[1024],  /* REMOTE_HOST environment variable */
    remote_user[1024],  /* REMOTE_USER environment variable */
    

    @@ -4095,8 +4102,7 @@
    "pipe_command: command="%s", options="%s"",
    command, options ? options : "(null)");

  • argv[0] = command;

  • query_string = NULL;

  • argv[0] = command;

if (options)
strlcpy(argbuf, options, sizeof(argbuf));
@@ -4123,10 +4129,12 @@
path_info[0] = '\0';
}

  • if (*commptr == '?' && con->operation == HTTP_GET)
  • cupsdLogMessage(CUPSD_LOG_INFO, "commptr="%s"", commptr);
  • if (*commptr == '?' && con->operation == HTTP_GET && !con->query_string)
    {
    commptr ++;
  • cupsdSetStringf(&query_string, "QUERY_STRING=%s", commptr);
  • cupsdSetStringf(&(con->query_string), "QUERY_STRING=%s", commptr);
    }

argc = 1;
@@ -4257,18 +4265,15 @@

if (con->operation == HTTP_GET)
{

  • for (i = 0; i < argc; i ++)

- cupsdLogMessage(CUPSD_LOG_DEBUG2, "argv[%d] = "%s"", i, argv[i]);

 envp[envc ++] = "REQUEST_METHOD=GET";
  • if (query_string)

  • if (con->query_string)
    {
    /*

  • Add GET form variables after ?...
    */

  •  envp[envc ++] = query_string;
    
  •  envp[envc ++] = con->query_string;
    

    }
    }
    else
    @@ -4312,8 +4317,6 @@

    if (cupsdOpenPipe(fds))
    {

- cupsdClearString(&query_string);

 cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create pipes for CGI %s - %s",
                 argv[0], strerror(errno));
 return (0);

@@ -4351,8 +4354,6 @@
close(fds[1]);
}

- cupsdClearString(&query_string);

return (pid);
}

Index: client.h

--- client.h (revision 6197)
+++ client.h (working copy)
@@ -41,7 +41,8 @@
/* Localized URL/URI for GET/PUT /
*filename, /
Filename of output file /
*command, /
Command to run */

  •       _options;   /_ Options for command */
    
  •       _options,   /_ Options for command */
    
  •       _query_string;  /_ QUERY_STRING environment variable _/
    
    int file; /_ Input/output file /
    int file_ready; /
    Input ready on file/pipe? /
    int pipe_pid; /
    Pipe process ID (or 0 if not a pipe) */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant