]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/client.c
Merge changes from CUPS 1.5svn-r9491.
[thirdparty/cups.git] / scheduler / client.c
index 1d0dcf12eb60cd6933e97e5680b465b3a56741af..7239bdb837bb538d52ac2de25383be6fd2d9ea65 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Client routines for the CUPS scheduler.
  *
- *   Copyright 2007-2010 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   This file contains Kerberos support code, copyright 2006 by
@@ -1368,8 +1368,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
                break;
              }
            }
-
-            if (!WebInterface)
+           else if (!WebInterface)
            {
             /*
              * Web interface is disabled. Show an appropriate message...
@@ -1383,13 +1382,14 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
 
              break;
            }
-           else if ((!strncmp(con->uri, "/admin", 6) &&
-                     strncmp(con->uri, "/admin/conf/", 12) &&
-                     strncmp(con->uri, "/admin/log/", 11)) ||
-                    !strncmp(con->uri, "/printers", 9) ||
-                    !strncmp(con->uri, "/classes", 8) ||
-                    !strncmp(con->uri, "/help", 5) ||
-                    !strncmp(con->uri, "/jobs", 5))
+
+           if ((!strncmp(con->uri, "/admin", 6) &&
+                 strncmp(con->uri, "/admin/conf/", 12) &&
+                 strncmp(con->uri, "/admin/log/", 11)) ||
+                !strncmp(con->uri, "/printers", 9) ||
+                !strncmp(con->uri, "/classes", 8) ||
+                !strncmp(con->uri, "/help", 5) ||
+                !strncmp(con->uri, "/jobs", 5))
            {
             /*
              * Send CGI output...
@@ -4925,8 +4925,18 @@ pipe_command(cupsd_client_t *con,        /* I - Client connection */
 
   sprintf(server_port, "SERVER_PORT=%d", con->serverport);
 
-  snprintf(server_name, sizeof(server_name), "SERVER_NAME=%s",
-           con->servername);
+  if (con->http.fields[HTTP_FIELD_HOST][0])
+  {
+    char *nameptr;                     /* Pointer to ":port" */
+
+    snprintf(server_name, sizeof(server_name), "SERVER_NAME=%s",
+            con->http.fields[HTTP_FIELD_HOST]);
+    if ((nameptr = strrchr(server_name, ':')) != NULL && !strchr(nameptr, ']'))
+      *nameptr = '\0';                 /* Strip trailing ":port" */
+  }
+  else
+    snprintf(server_name, sizeof(server_name), "SERVER_NAME=%s",
+            con->servername);
 
   envc = cupsdLoadEnv(envp, (int)(sizeof(envp) / sizeof(envp[0])));