/*
- * "$Id: client.c,v 1.91.2.95 2004/09/12 18:50:10 mike Exp $"
+ * "$Id$"
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
* Attn: CUPS Licensing Information
* Easy Software Products
* 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636-3142 USA
+ * Hollywood, Maryland 20636 USA
*
* Voice: (301) 373-9600
* EMail: cups-info@cups.org
return;
}
-
+
/*
* Get the hostname or format the IP address as needed...
*/
val = 1;
setsockopt(con->http.fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
-#ifdef FD_CLOEXEC
/*
* Close this file on all execs...
*/
- fcntl(con->http.fd, F_SETFD, FD_CLOEXEC);
-#endif /* FD_CLOEXEC */
+ fcntl(con->http.fd, F_SETFD, fcntl(con->http.fd, F_GETFD) | FD_CLOEXEC);
/*
* Add the socket to the select() input mask.
httpPrintf(HTTP(con), "\r\n");
EncryptClient(con);
-
- status = IsAuthorized(con);
#else
if (!SendError(con, HTTP_NOT_IMPLEMENTED))
return (CloseClient(con));
#endif /* HAVE_SSL */
}
- if (status != HTTP_OK)
+ if ((status = IsAuthorized(con)) != HTTP_OK)
{
LogMessage(L_DEBUG2, "ReadClient: Unauthorized request for %s...\n",
con->uri);
SetStringf(&con->filename, "%s/%08x", RequestRoot, request_id ++);
con->file = open(con->filename, O_WRONLY | O_CREAT | O_TRUNC, 0640);
-#ifdef FD_CLOEXEC
- /*
- * Close this file when starting other processes...
- */
-
- fcntl(con->file, F_SETFD, FD_CLOEXEC);
-#endif /* FD_CLOEXEC */
-
LogMessage(L_DEBUG2, "ReadClient: %d REQUEST %s=%d", con->http.fd,
con->filename, con->file);
SetStringf(&con->filename, "%s/%08x", RequestRoot, request_id ++);
con->file = open(con->filename, O_WRONLY | O_CREAT | O_TRUNC, 0640);
-#ifdef FD_CLOEXEC
- /*
- * Close this file when starting other processes...
- */
-
- fcntl(con->file, F_SETFD, FD_CLOEXEC);
-#endif /* FD_CLOEXEC */
-
LogMessage(L_DEBUG2, "ReadClient: %d REQUEST %s=%d", con->http.fd,
con->filename, con->file);
if (con->file < 0)
return (0);
-#ifdef FD_CLOEXEC
- /*
- * Close this file when starting other processes...
- */
-
- fcntl(con->file, F_SETFD, FD_CLOEXEC);
-#endif /* FD_CLOEXEC */
+ fcntl(con->file, F_SETFD, fcntl(con->file, F_GETFD) | FD_CLOEXEC);
con->pipe_pid = 0;
con->file);
FD_CLR(con->file, InputSet);
}
-
+
if (con->pipe_pid)
kill(con->pipe_pid, SIGTERM);
- LogMessage(L_DEBUG2, "WriteClient() %d Closing data file %d.",
+ LogMessage(L_DEBUG2, "WriteClient: %d Closing data file %d.",
con->http.fd, con->file);
close(con->file);
if (con->filename)
{
- LogMessage(L_DEBUG2, "WriteClient() %d Removing temp file %s",
+ LogMessage(L_DEBUG2, "WriteClient: %d Removing temp file %s",
con->http.fd, con->filename);
unlink(con->filename);
ClearString(&con->filename);
* Get the username and password from the Digest attributes...
*/
- if (httpGetSubField(&(con->http), HTTP_FIELD_WWW_AUTHENTICATE, "username",
+ if (httpGetSubField(&(con->http), HTTP_FIELD_AUTHORIZATION, "username",
value))
strlcpy(con->username, value, sizeof(con->username));
- if (httpGetSubField(&(con->http), HTTP_FIELD_WWW_AUTHENTICATE, "response",
+ if (httpGetSubField(&(con->http), HTTP_FIELD_AUTHORIZATION, "response",
value))
- strlcpy(con->password, value, sizeof(con->password) - 1);
+ strlcpy(con->password, value, sizeof(con->password));
}
LogMessage(L_DEBUG2, "decode_auth: %d username=\"%s\"",
}
+/*
+ * 'get_file()' - Get a filename and state info.
+ */
+
static char * /* O - Real filename */
get_file(client_t *con, /* I - Client connection */
struct stat *filestats, /* O - File information */
*/
while ((path = strstr(path, "/..")) != NULL)
+ {
if (!path[3] || path[3] == '/')
return (0);
+ path ++;
+ }
+
/*
* If we haven't found any relative paths, return 1 indicating an
* absolute path...
locale_encodings[con->language->encoding]);
else
strcpy(lang, "LANG=C");
-
+
sprintf(ipp_port, "IPP_PORT=%d", LocalPort);
#ifdef AF_INET6
if (con->http.hostaddr.addr.sa_family == AF_INET6)
* Create a pipe for the output...
*/
- if (cupsdPipe(fds))
+ if (cupsdOpenPipe(fds))
{
ClearString(&query_string);
* Update stdin/stdout/stderr...
*/
- if (infile > 0)
+ if (infile)
{
close(0);
if (dup(infile) < 0)
LogMessage(L_ERROR, "Unable to fork for CGI %s - %s", argv[0],
strerror(errno));
- close(fds[0]);
- close(fds[1]);
+ cupsdClosePipe(fds);
pid = 0;
}
else
/*
- * End of "$Id: client.c,v 1.91.2.95 2004/09/12 18:50:10 mike Exp $".
+ * End of "$Id$".
*/