summaryrefslogtreecommitdiff
path: root/scheduler/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'scheduler/client.c')
-rw-r--r--scheduler/client.c86
1 files changed, 38 insertions, 48 deletions
diff --git a/scheduler/client.c b/scheduler/client.c
index 4d42bcea..75ed7578 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -1,5 +1,5 @@
/*
- * "$Id: client.c 10455 2012-05-07 22:41:30Z mike $"
+ * "$Id: client.c 10834 2013-01-21 15:29:47Z mike $"
*
* Client routines for the CUPS scheduler.
*
@@ -32,7 +32,7 @@
* compare_clients() - Compare two client connections.
* data_ready() - Check whether data is available from a client.
* get_file() - Get a filename and state info.
- * install_conf_file() - Install a configuration file.
+ * install_cupsd_conf() - Install a configuration file.
* is_cgi() - Is the resource a CGI script/program?
* is_path_absolute() - Is a path absolute and free of relative elements
* (i.e. "..").
@@ -95,7 +95,7 @@ static int compare_clients(cupsd_client_t *a, cupsd_client_t *b,
static int data_ready(cupsd_client_t *con);
static char *get_file(cupsd_client_t *con, struct stat *filestats,
char *filename, int len);
-static http_status_t install_conf_file(cupsd_client_t *con);
+static http_status_t install_cupsd_conf(cupsd_client_t *con);
static int is_cgi(cupsd_client_t *con, const char *filename,
struct stat *filestats, mime_type_t *type);
static int is_path_absolute(const char *path);
@@ -1271,7 +1271,8 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
switch (con->http.state)
{
case HTTP_GET_SEND :
- if (!strncmp(con->uri, "/printers/", 10) &&
+ if ((!strncmp(con->uri, "/ppd/", 5) ||
+ !strncmp(con->uri, "/printers/", 10)) &&
!strcmp(con->uri + strlen(con->uri) - 4, ".ppd"))
{
/*
@@ -1281,8 +1282,15 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
con->uri[strlen(con->uri) - 4] = '\0'; /* Drop ".ppd" */
- if ((p = cupsdFindPrinter(con->uri + 10)) != NULL)
+ if (!strncmp(con->uri, "/ppd/", 5))
+ p = cupsdFindPrinter(con->uri + 5);
+ else
+ p = cupsdFindPrinter(con->uri + 10);
+
+ if (p)
+ {
snprintf(con->uri, sizeof(con->uri), "/ppd/%s.ppd", p->name);
+ }
else
{
if (!cupsdSendError(con, HTTP_NOT_FOUND, CUPSD_AUTH_NONE))
@@ -1294,7 +1302,8 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
break;
}
}
- else if ((!strncmp(con->uri, "/printers/", 10) ||
+ else if ((!strncmp(con->uri, "/icons/", 7) ||
+ !strncmp(con->uri, "/printers/", 10) ||
!strncmp(con->uri, "/classes/", 9)) &&
!strcmp(con->uri + strlen(con->uri) - 4, ".png"))
{
@@ -1305,7 +1314,9 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
con->uri[strlen(con->uri) - 4] = '\0'; /* Drop ".png" */
- if (!strncmp(con->uri, "/printers/", 10))
+ if (!strncmp(con->uri, "/icons/", 7))
+ p = cupsdFindPrinter(con->uri + 7);
+ else if (!strncmp(con->uri, "/printers/", 10))
p = cupsdFindPrinter(con->uri + 10);
else
p = cupsdFindClass(con->uri + 9);
@@ -1666,17 +1677,14 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
* Validate the resource name...
*/
- if (strncmp(con->uri, "/admin/conf/", 12) ||
- strchr(con->uri + 12, '/') ||
- strlen(con->uri) == 12)
+ if (strcmp(con->uri, "/admin/conf/cupsd.conf"))
{
/*
- * PUT can only be done to configuration files under
- * /admin/conf...
+ * PUT can only be done to the cupsd.conf file...
*/
cupsdLogMessage(CUPSD_LOG_ERROR,
- "[Client %d] Request for subdirectory \"%s\".",
+ "[Client %d] Disallowed PUT request for \"%s\".",
con->http.fd, con->uri);
if (!cupsdSendError(con, HTTP_FORBIDDEN, CUPSD_AUTH_NONE))
@@ -2044,7 +2052,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
* Install the configuration file...
*/
- status = install_conf_file(con);
+ status = install_cupsd_conf(con);
/*
* Return the status to the client...
@@ -2573,14 +2581,7 @@ cupsdSendHeader(
con->http.hostname);
#ifdef HAVE_GSSAPI
else if (auth_type == CUPSD_AUTH_NEGOTIATE)
- {
-# ifdef AF_LOCAL
- if (_httpAddrFamily(con->http.hostaddr) == AF_LOCAL)
- strlcpy(auth_str, "Basic realm=\"CUPS\"", sizeof(auth_str));
- else
-# endif /* AF_LOCAL */
strlcpy(auth_str, "Negotiate", sizeof(auth_str));
- }
#endif /* HAVE_GSSAPI */
if (con->best && auth_type != CUPSD_AUTH_NEGOTIATE &&
@@ -3301,14 +3302,13 @@ get_file(cupsd_client_t *con, /* I - Client connection */
/*
- * 'install_conf_file()' - Install a configuration file.
+ * 'install_cupsd_conf()' - Install a configuration file.
*/
static http_status_t /* O - Status */
-install_conf_file(cupsd_client_t *con) /* I - Connection */
+install_cupsd_conf(cupsd_client_t *con) /* I - Connection */
{
char filename[1024]; /* Configuration filename */
- mode_t mode; /* Permissions */
cups_file_t *in, /* Input file */
*out; /* Output file */
char buffer[16384]; /* Copy buffer */
@@ -3330,19 +3330,14 @@ install_conf_file(cupsd_client_t *con) /* I - Connection */
* Open the new config file...
*/
- snprintf(filename, sizeof(filename), "%s%s", ServerRoot, con->uri + 11);
- if (!strcmp(con->uri, "/admin/conf/printers.conf"))
- mode = ConfigFilePerm & 0600;
- else
- mode = ConfigFilePerm;
-
- if ((out = cupsdCreateConfFile(filename, mode)) == NULL)
+ if ((out = cupsdCreateConfFile(ConfigurationFile, ConfigFilePerm)) == NULL)
{
cupsFileClose(in);
return (HTTP_SERVER_ERROR);
}
- cupsdLogMessage(CUPSD_LOG_INFO, "Installing config file \"%s\"...", filename);
+ cupsdLogMessage(CUPSD_LOG_INFO, "Installing config file \"%s\"...",
+ ConfigurationFile);
/*
* Copy from the request to the new config file...
@@ -3353,12 +3348,12 @@ install_conf_file(cupsd_client_t *con) /* I - Connection */
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to copy to config file \"%s\": %s",
- filename, strerror(errno));
+ ConfigurationFile, strerror(errno));
cupsFileClose(in);
cupsFileClose(out);
- snprintf(filename, sizeof(filename), "%s%s.N", ServerRoot, con->uri + 11);
+ snprintf(filename, sizeof(filename), "%s.N", ConfigurationFile);
cupsdRemoveFile(filename);
return (HTTP_SERVER_ERROR);
@@ -3370,7 +3365,7 @@ install_conf_file(cupsd_client_t *con) /* I - Connection */
cupsFileClose(in);
- if (cupsdCloseCreatedConfFile(out, filename))
+ if (cupsdCloseCreatedConfFile(out, ConfigurationFile))
return (HTTP_SERVER_ERROR);
/*
@@ -3381,14 +3376,10 @@ install_conf_file(cupsd_client_t *con) /* I - Connection */
cupsdClearString(&con->filename);
/*
- * If the cupsd.conf file was updated, set the NeedReload flag...
+ * Set the NeedReload flag...
*/
- if (!strcmp(con->uri, "/admin/conf/cupsd.conf"))
- NeedReload = RELOAD_CUPSD;
- else
- NeedReload = RELOAD_ALL;
-
+ NeedReload = RELOAD_CUPSD;
ReloadTime = time(NULL);
/*
@@ -3621,7 +3612,6 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
server_name[1024], /* SERVER_NAME environment variable */
server_port[1024]; /* SERVER_PORT environment variable */
ipp_attribute_t *attr; /* attributes-natural-language attribute */
- void *ccache = NULL; /* Kerberos credentials */
/*
@@ -3973,7 +3963,7 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
*/
if (con->username[0])
- cupsdAddCert(pid, con->username, ccache);
+ cupsdAddCert(pid, con->username, con->type);
cupsdLogMessage(CUPSD_LOG_DEBUG, "[CGI] Started %s (PID %d)", command, pid);
@@ -4021,7 +4011,7 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
!strncmp(host, "[::1]:", 6));
}
-#ifdef HAVE_DNSSD
+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
/*
* Check if the hostname is something.local (Bonjour); if so, allow it.
*/
@@ -4040,7 +4030,7 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
!_cups_strcasecmp(end, ".local.") ||
!_cups_strncasecmp(end, ".local.:", 8)))
return (1);
-#endif /* HAVE_DNSSD */
+#endif /* HAVE_DNSSD || HAVE_AVAHI */
/*
* Check if the hostname is an IP address...
@@ -4101,7 +4091,7 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
}
}
-#ifdef HAVE_DNSSD
+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
for (a = (cupsd_alias_t *)cupsArrayFirst(DNSSDAlias);
a;
a = (cupsd_alias_t *)cupsArrayNext(DNSSDAlias))
@@ -4126,7 +4116,7 @@ valid_host(cupsd_client_t *con) /* I - Client connection */
return (1);
}
}
-#endif /* HAVE_DNSSD */
+#endif /* HAVE_DNSSD || HAVE_AVAHI */
/*
* Check for interface hostname matches...
@@ -4228,5 +4218,5 @@ write_pipe(cupsd_client_t *con) /* I - Client connection */
/*
- * End of "$Id: client.c 10455 2012-05-07 22:41:30Z mike $".
+ * End of "$Id: client.c 10834 2013-01-21 15:29:47Z mike $".
*/