mirror of https://github.com/nealey/eris.git
Quit setting environment variables to NULL
This commit is contained in:
parent
4ee3918c15
commit
ef5bf33e3e
20
cgi.c
20
cgi.c
|
@ -7,20 +7,20 @@ sigchld(int sig)
|
||||||
static void
|
static void
|
||||||
cgi_child(const char *relpath)
|
cgi_child(const char *relpath)
|
||||||
{
|
{
|
||||||
setenv("GATEWAY_INTERFACE", "CGI/1.1", 1);
|
env("GATEWAY_INTERFACE", "CGI/1.1");
|
||||||
setenv("SERVER_SOFTWARE", FNORD, 1);
|
env("SERVER_SOFTWARE", FNORD);
|
||||||
setenv("REQUEST_URI", path, 1);
|
env("REQUEST_URI", path);
|
||||||
setenv("SERVER_NAME", host, 1);
|
env("SERVER_NAME", host);
|
||||||
setenv("SCRIPT_NAME", relpath, 1);
|
env("SCRIPT_NAME", relpath);
|
||||||
setenv("REMOTE_ADDR", remote_ip, 1);
|
env("REMOTE_ADDR", remote_ip);
|
||||||
setenv("REMOTE_PORT", remote_port, 1);
|
env("REMOTE_PORT", remote_port);
|
||||||
setenv("REMOTE_IDENT", remote_ident, 1);
|
env("REMOTE_IDENT", remote_ident);
|
||||||
if (content_length) {
|
if (content_length) {
|
||||||
char cl[20];
|
char cl[20];
|
||||||
|
|
||||||
snprintf(cl, sizeof cl, "%llu", (unsigned long long) content_length);
|
snprintf(cl, sizeof cl, "%llu", (unsigned long long) content_length);
|
||||||
setenv("CONTENT_LENGTH", cl, 1);
|
env("CONTENT_LENGTH", cl);
|
||||||
setenv("CONTENT_TYPE", content_type, 1);
|
env("CONTENT_TYPE", content_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
execl(relpath, relpath, NULL);
|
execl(relpath, relpath, NULL);
|
||||||
|
|
18
eris.c
18
eris.c
|
@ -172,6 +172,14 @@ badrequest(long code, const char *httpcomment, const char *message)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
env(const char *k, const char *v)
|
||||||
|
{
|
||||||
|
if (v) {
|
||||||
|
setenv(k, v, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#include "cgi.c"
|
#include "cgi.c"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -467,7 +475,7 @@ find_serve_file(char *relpath)
|
||||||
|
|
||||||
if ((p = strstr(relpath, ".cgi"))) {
|
if ((p = strstr(relpath, ".cgi"))) {
|
||||||
p += 4;
|
p += 4;
|
||||||
setenv("PATH_INFO", p, 1);
|
env("PATH_INFO", p);
|
||||||
*p = 0;
|
*p = 0;
|
||||||
if (! stat(relpath, &st)) {
|
if (! stat(relpath, &st)) {
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -520,7 +528,7 @@ handle_request()
|
||||||
|
|
||||||
if (docgi) {
|
if (docgi) {
|
||||||
p[-2] = 0;
|
p[-2] = 0;
|
||||||
setenv("REQUEST_METHOD", request, 1);
|
env("REQUEST_METHOD", request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Interpret path into fspath. */
|
/* Interpret path into fspath. */
|
||||||
|
@ -569,7 +577,7 @@ handle_request()
|
||||||
*(p++) = 0; /* NULL-terminate path */
|
*(p++) = 0; /* NULL-terminate path */
|
||||||
|
|
||||||
if (docgi && query_string) {
|
if (docgi && query_string) {
|
||||||
setenv("QUERY_STRING", query_string, 1);
|
env("QUERY_STRING", query_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,7 +595,7 @@ handle_request()
|
||||||
keepalive = 0;
|
keepalive = 0;
|
||||||
}
|
}
|
||||||
if (docgi) {
|
if (docgi) {
|
||||||
setenv("SERVER_PROTOCOL", p, 1);
|
env("SERVER_PROTOCOL", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read header fields */
|
/* Read header fields */
|
||||||
|
@ -635,7 +643,7 @@ handle_request()
|
||||||
|
|
||||||
/* Set up CGI environment variables */
|
/* Set up CGI environment variables */
|
||||||
if (docgi) {
|
if (docgi) {
|
||||||
setenv(cgi_name, val, 1);
|
env(cgi_name, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* By default, re-use buffer space */
|
/* By default, re-use buffer space */
|
||||||
|
|
Loading…
Reference in New Issue