/*
- * "$Id: client.c,v 1.91.2.97 2005/01/03 18:48:04 mike Exp $"
+ * "$Id$"
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
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 */
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)
* Update stdin/stdout/stderr...
*/
- if (infile > 0)
+ if (infile)
{
close(0);
if (dup(infile) < 0)
/*
- * End of "$Id: client.c,v 1.91.2.97 2005/01/03 18:48:04 mike Exp $".
+ * End of "$Id$".
*/