-const char jcc_rcs[] = "$Id: jcc.c,v 1.77 2002/03/07 03:52:06 oes Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.78 2002/03/08 21:35:04 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.78 2002/03/08 21:35:04 oes
+ * Added optional group supplement to --user option. Will now use default group of user if no group given
+ *
* Revision 1.77 2002/03/07 03:52:06 oes
* - Fixed compiler warnings etc
* - Improved handling of failed DNS lookups
#define IS_ENABLED_AND IS_TOGGLED_ON_AND IS_NOT_FORCED_AND
char buf[BUFFER_SIZE];
- char *hdr, *p, *req;
+ char *hdr;
+ char *p;
+ char *req;
fd_set rfds;
- int n, maxfd, server_body;
+ int n;
+ jb_socket maxfd;
+ int server_body;
int ms_iis5_hack = 0;
int byte_count = 0;
const struct forward_spec * fwd;
struct http_request *http;
- size_t len; /* for buffer sizes */
+ int len; /* for buffer sizes */
#ifdef FEATURE_KILL_POPUPS
int block_popups; /* bool, 1==will block popups */
int block_popups_now = 0; /* bool, 1==currently blocking popups */
)
{
/* Write the answer to the client */
- if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ if (write_socket(csp->cfd, rsp->head, rsp->head_length)
+ || write_socket(csp->cfd, rsp->body, rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
csp->sfd = forwarded_connect(fwd, http, csp);
- if (csp->sfd < 0)
+ if (csp->sfd == JB_INVALID_SOCKET)
{
log_error(LOG_LEVEL_CONNECT, "connect to: %s failed: %E",
http->hostport);
/* Write the answer to the client */
if(rsp)
{
- if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ if (write_socket(csp->cfd, rsp->head, rsp->head_length)
+ || write_socket(csp->cfd, rsp->body, rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
* (along with anything else that may be in the buffer)
*/
- len = strlen(hdr);
-
- if ((write_socket(csp->sfd, hdr, len) != len)
- || (flush_socket(csp->sfd, csp ) < 0))
+ if (write_socket(csp->sfd, hdr, strlen(hdr))
+ || (flush_socket(csp->sfd, csp) < 0))
{
log_error(LOG_LEVEL_CONNECT, "write header to: %s failed: %E",
http->hostport);
if(rsp)
{
- if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ if (write_socket(csp->cfd, rsp->head, rsp->head_length)
+ || write_socket(csp->cfd, rsp->body, rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 2\n",
csp->ip_addr_str, http->ocmd);
- if (write_socket(csp->cfd, CSUCCEED, sizeof(CSUCCEED)-1) < 0)
+ if (write_socket(csp->cfd, CSUCCEED, sizeof(CSUCCEED)-1))
{
freez(hdr);
return;
break; /* "game over, man" */
}
- if (write_socket(csp->sfd, buf, len) != len)
+ if (write_socket(csp->sfd, buf, len))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
return;
if(rsp)
{
- if ((write_socket(csp->cfd, rsp->head, rsp->head_length) != rsp->head_length)
- || (write_socket(csp->cfd, rsp->body, rsp->content_length) != rsp->content_length))
+ if (write_socket(csp->cfd, rsp->head, rsp->head_length)
+ || write_socket(csp->cfd, rsp->body, rsp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
}
log_error(LOG_LEVEL_FATAL, "Out of memory parsing server header");
}
- len = strlen(hdr);
-
- if ((write_socket(csp->cfd, hdr, len) != len)
- || (write_socket(csp->cfd, p != NULL ? p : csp->iob->cur, csp->content_length) != (int)csp->content_length))
+ if (write_socket(csp->cfd, hdr, strlen(hdr))
+ || write_socket(csp->cfd, p != NULL ? p : csp->iob->cur, csp->content_length))
{
log_error(LOG_LEVEL_ERROR, "write modified content to client failed: %E");
return;
len = strlen(hdr);
byte_count += len;
- if (((write_socket(csp->cfd, hdr, len) != len)
- || (len = flush_socket(csp->cfd, csp) < 0)))
+ if (write_socket(csp->cfd, hdr, len)
+ || (len = flush_socket(csp->cfd, csp) < 0))
{
log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E");
}
else
{
- if (write_socket(csp->cfd, buf, len) != len)
+ if (write_socket(csp->cfd, buf, len))
{
log_error(LOG_LEVEL_ERROR, "write to client failed: %E");
return;
log_error(LOG_LEVEL_FATAL, "Out of memory parsing server header");
}
- len = strlen(hdr);
-
- /* write the server's (modified) header to
- * the client (along with anything else that
- * may be in the buffer)
- */
-
#ifdef FEATURE_KILL_POPUPS
/* Start blocking popups if appropriate. */
content_filter = gif_deanimate_response;
}
-
/*
* Only write if we're not buffering for content modification
*/
- if (!content_filter && ((write_socket(csp->cfd, hdr, len) != len)
- || (len = flush_socket(csp->cfd, csp) < 0)))
+ if (!content_filter)
{
- log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E");
-
- /* the write failed, so don't bother
- * mentioning it to the client...
- * it probably can't hear us anyway.
+ /* write the server's (modified) header to
+ * the client (along with anything else that
+ * may be in the buffer)
*/
- freez(hdr);
- return;
- }
- if(!content_filter) byte_count += len;
+ len = strlen(hdr);
+
+ if (write_socket(csp->cfd, hdr, len)
+ || (len = flush_socket(csp->cfd, csp) < 0))
+ {
+ log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E");
+
+ /* the write failed, so don't bother
+ * mentioning it to the client...
+ * it probably can't hear us anyway.
+ */
+ freez(hdr);
+ return;
+ }
+
+ byte_count += len;
+ }
/* we're finished with the server's header */
chat(csp);
close_socket(csp->cfd);
- if (csp->sfd >= 0)
+ if (csp->sfd != JB_INVALID_SOCKET)
{
close_socket(csp->sfd);
}
* Returns : Port that was opened.
*
*********************************************************************/
-static int bind_port_helper(struct configuration_spec * config)
+static jb_socket bind_port_helper(struct configuration_spec * config)
{
- int bfd;
+ int result;
+ jb_socket bfd;
if ( (config->haddr != NULL)
&& (config->haddr[0] == '1')
config->hport, config->haddr);
}
- bfd = bind_port(config->haddr, config->hport);
+ result = bind_port(config->haddr, config->hport, &bfd);
- if (bfd < 0)
+ if (result < 0)
{
- switch(bfd)
+ switch(result)
{
case -3 :
log_error(LOG_LEVEL_FATAL, "can't bind to %s:%d: "
}
/* shouldn't get here */
- return -1;
+ return JB_INVALID_SOCKET;
}
config->need_bind = 0;
static void listen_loop(void)
{
struct client_state *csp = NULL;
- int bfd;
+ jb_socket bfd;
struct configuration_spec * config;
config = load_config();
}
csp->flags |= CSP_FLAG_ACTIVE;
- csp->sfd = -1;
+ csp->sfd = JB_INVALID_SOCKET;
csp->config = config = load_config();