improved how to clear and set basic environment variables in http-svr.c
This commit is contained in:
parent
8f7dcbe479
commit
21d51cbbf9
@ -347,7 +347,6 @@ pdfdir = @pdfdir@
|
|||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
program_transform_name = @program_transform_name@
|
program_transform_name = @program_transform_name@
|
||||||
psdir = @psdir@
|
psdir = @psdir@
|
||||||
runstatedir = @runstatedir@
|
|
||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
@ -337,7 +337,6 @@ pdfdir = @pdfdir@
|
|||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
program_transform_name = @program_transform_name@
|
program_transform_name = @program_transform_name@
|
||||||
psdir = @psdir@
|
psdir = @psdir@
|
||||||
runstatedir = @runstatedir@
|
|
||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
14
mio/configure
vendored
14
mio/configure
vendored
@ -770,7 +770,6 @@ infodir
|
|||||||
docdir
|
docdir
|
||||||
oldincludedir
|
oldincludedir
|
||||||
includedir
|
includedir
|
||||||
runstatedir
|
|
||||||
localstatedir
|
localstatedir
|
||||||
sharedstatedir
|
sharedstatedir
|
||||||
sysconfdir
|
sysconfdir
|
||||||
@ -862,7 +861,6 @@ datadir='${datarootdir}'
|
|||||||
sysconfdir='${prefix}/etc'
|
sysconfdir='${prefix}/etc'
|
||||||
sharedstatedir='${prefix}/com'
|
sharedstatedir='${prefix}/com'
|
||||||
localstatedir='${prefix}/var'
|
localstatedir='${prefix}/var'
|
||||||
runstatedir='${localstatedir}/run'
|
|
||||||
includedir='${prefix}/include'
|
includedir='${prefix}/include'
|
||||||
oldincludedir='/usr/include'
|
oldincludedir='/usr/include'
|
||||||
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
||||||
@ -1115,15 +1113,6 @@ do
|
|||||||
| -silent | --silent | --silen | --sile | --sil)
|
| -silent | --silent | --silen | --sile | --sil)
|
||||||
silent=yes ;;
|
silent=yes ;;
|
||||||
|
|
||||||
-runstatedir | --runstatedir | --runstatedi | --runstated \
|
|
||||||
| --runstate | --runstat | --runsta | --runst | --runs \
|
|
||||||
| --run | --ru | --r)
|
|
||||||
ac_prev=runstatedir ;;
|
|
||||||
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
|
|
||||||
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
|
|
||||||
| --run=* | --ru=* | --r=*)
|
|
||||||
runstatedir=$ac_optarg ;;
|
|
||||||
|
|
||||||
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
||||||
ac_prev=sbindir ;;
|
ac_prev=sbindir ;;
|
||||||
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
||||||
@ -1261,7 +1250,7 @@ fi
|
|||||||
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
||||||
datadir sysconfdir sharedstatedir localstatedir includedir \
|
datadir sysconfdir sharedstatedir localstatedir includedir \
|
||||||
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
||||||
libdir localedir mandir runstatedir
|
libdir localedir mandir
|
||||||
do
|
do
|
||||||
eval ac_val=\$$ac_var
|
eval ac_val=\$$ac_var
|
||||||
# Remove trailing slashes.
|
# Remove trailing slashes.
|
||||||
@ -1414,7 +1403,6 @@ Fine tuning of the installation directories:
|
|||||||
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
||||||
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
||||||
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
||||||
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
|
|
||||||
--libdir=DIR object code libraries [EPREFIX/lib]
|
--libdir=DIR object code libraries [EPREFIX/lib]
|
||||||
--includedir=DIR C header files [PREFIX/include]
|
--includedir=DIR C header files [PREFIX/include]
|
||||||
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
||||||
|
@ -379,7 +379,6 @@ pdfdir = @pdfdir@
|
|||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
program_transform_name = @program_transform_name@
|
program_transform_name = @program_transform_name@
|
||||||
psdir = @psdir@
|
psdir = @psdir@
|
||||||
runstatedir = @runstatedir@
|
|
||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
@ -1267,7 +1267,7 @@ static int cgi_peer_capture_request_header (mio_htre_t* req, const mio_bch_t* ke
|
|||||||
|
|
||||||
static int cgi_peer_on_fork (mio_dev_pro_t* pro, void* fork_ctx)
|
static int cgi_peer_on_fork (mio_dev_pro_t* pro, void* fork_ctx)
|
||||||
{
|
{
|
||||||
/*mio_t* mio = pro->mio;*/ /* in this callback, the pro device is not fully up. however, the mio field is guaranteed to be available */
|
mio_t* mio = pro->mio; /* in this callback, the pro device is not fully up. however, the mio field is guaranteed to be available */
|
||||||
cgi_peer_fork_ctx_t* fc = (cgi_peer_fork_ctx_t*)fork_ctx;
|
cgi_peer_fork_ctx_t* fc = (cgi_peer_fork_ctx_t*)fork_ctx;
|
||||||
mio_oow_t content_length;
|
mio_oow_t content_length;
|
||||||
const mio_bch_t* qparam;
|
const mio_bch_t* qparam;
|
||||||
@ -1277,22 +1277,32 @@ static int cgi_peer_on_fork (mio_dev_pro_t* pro, void* fork_ctx)
|
|||||||
|
|
||||||
qparam = mio_htre_getqparam(fc->req);
|
qparam = mio_htre_getqparam(fc->req);
|
||||||
|
|
||||||
path = getenv("PATH");
|
path = mio_dupbcstr(mio, getenv("PATH"), MIO_NULL);
|
||||||
lang = getenv("LANG");
|
lang = mio_dupbcstr(mio, getenv("LANG"), MIO_NULL);
|
||||||
#if defined(HAVE_CLEARENV)
|
#if defined(HAVE_CLEARENV)
|
||||||
clearenv ();
|
clearenv ();
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
extern char** environ;
|
extern char** environ;
|
||||||
|
/* environ = NULL; this crashed this program on NetBSD */
|
||||||
if (environ) environ[0] = '\0';
|
if (environ) environ[0] = '\0';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (path) setenv ("PATH", path, 1);
|
if (path)
|
||||||
if (lang) setenv ("LANG", lang, 1);
|
{
|
||||||
|
setenv ("PATH", path, 1);
|
||||||
|
mio_freemem (mio, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lang)
|
||||||
|
{
|
||||||
|
setenv ("LANG", lang, 1);
|
||||||
|
mio_freemem (mio, lang);
|
||||||
|
}
|
||||||
|
|
||||||
setenv ("GATEWAY_INTERFACE", "CGI/1.1", 1);
|
setenv ("GATEWAY_INTERFACE", "CGI/1.1", 1);
|
||||||
|
|
||||||
mio_fmttobcstr (pro->mio, tmp, MIO_COUNTOF(tmp), "HTTP/%d.%d", (int)mio_htre_getmajorversion(fc->req), (int)mio_htre_getminorversion(fc->req));
|
mio_fmttobcstr (mio, tmp, MIO_COUNTOF(tmp), "HTTP/%d.%d", (int)mio_htre_getmajorversion(fc->req), (int)mio_htre_getminorversion(fc->req));
|
||||||
setenv ("SERVER_PROTOCOL", tmp, 1);
|
setenv ("SERVER_PROTOCOL", tmp, 1);
|
||||||
|
|
||||||
setenv ("DOCUMENT_ROOT", fc->docroot, 1);
|
setenv ("DOCUMENT_ROOT", fc->docroot, 1);
|
||||||
@ -1316,22 +1326,22 @@ static int cgi_peer_on_fork (mio_dev_pro_t* pro, void* fork_ctx)
|
|||||||
}
|
}
|
||||||
setenv ("SERVER_SOFTWARE", fc->cli->htts->server_name, 1);
|
setenv ("SERVER_SOFTWARE", fc->cli->htts->server_name, 1);
|
||||||
|
|
||||||
mio_skadtobcstr (pro->mio, &fc->cli->sck->localaddr, tmp, MIO_COUNTOF(tmp), MIO_SKAD_TO_BCSTR_ADDR);
|
mio_skadtobcstr (mio, &fc->cli->sck->localaddr, tmp, MIO_COUNTOF(tmp), MIO_SKAD_TO_BCSTR_ADDR);
|
||||||
setenv ("SERVER_ADDR", tmp, 1);
|
setenv ("SERVER_ADDR", tmp, 1);
|
||||||
|
|
||||||
gethostname (tmp, MIO_COUNTOF(tmp)); /* if this fails, i assume tmp contains the ip address set by mio_skadtobcstr() above */
|
gethostname (tmp, MIO_COUNTOF(tmp)); /* if this fails, i assume tmp contains the ip address set by mio_skadtobcstr() above */
|
||||||
setenv ("SERVER_NAME", tmp, 1);
|
setenv ("SERVER_NAME", tmp, 1);
|
||||||
|
|
||||||
mio_skadtobcstr (pro->mio, &fc->cli->sck->localaddr, tmp, MIO_COUNTOF(tmp), MIO_SKAD_TO_BCSTR_PORT);
|
mio_skadtobcstr (mio, &fc->cli->sck->localaddr, tmp, MIO_COUNTOF(tmp), MIO_SKAD_TO_BCSTR_PORT);
|
||||||
setenv ("SERVER_PORT", tmp, 1);
|
setenv ("SERVER_PORT", tmp, 1);
|
||||||
|
|
||||||
mio_skadtobcstr (pro->mio, &fc->cli->sck->remoteaddr, tmp, MIO_COUNTOF(tmp), MIO_SKAD_TO_BCSTR_ADDR);
|
mio_skadtobcstr (mio, &fc->cli->sck->remoteaddr, tmp, MIO_COUNTOF(tmp), MIO_SKAD_TO_BCSTR_ADDR);
|
||||||
setenv ("REMOTE_ADDR", tmp, 1);
|
setenv ("REMOTE_ADDR", tmp, 1);
|
||||||
|
|
||||||
mio_skadtobcstr (pro->mio, &fc->cli->sck->remoteaddr, tmp, MIO_COUNTOF(tmp), MIO_SKAD_TO_BCSTR_PORT);
|
mio_skadtobcstr (mio, &fc->cli->sck->remoteaddr, tmp, MIO_COUNTOF(tmp), MIO_SKAD_TO_BCSTR_PORT);
|
||||||
setenv ("REMOTE_PORT", tmp, 1);
|
setenv ("REMOTE_PORT", tmp, 1);
|
||||||
|
|
||||||
if (mio_becs_init(&dbuf, pro->mio, 256) >= 0)
|
if (mio_becs_init(&dbuf, mio, 256) >= 0)
|
||||||
{
|
{
|
||||||
mio_htre_walkheaders (fc->req, cgi_peer_capture_request_header, &dbuf);
|
mio_htre_walkheaders (fc->req, cgi_peer_capture_request_header, &dbuf);
|
||||||
/* [NOTE] trailers are not available when this cgi resource is started. let's not call mio_htre_walktrailers() */
|
/* [NOTE] trailers are not available when this cgi resource is started. let's not call mio_htre_walktrailers() */
|
||||||
@ -1541,7 +1551,7 @@ static void* thr_state_run_func (void* arg)
|
|||||||
|
|
||||||
int mio_svc_htts_dothr (mio_svc_htts_t* htts, mio_dev_sck_t* csck, mio_htre_t* req, mio_svc_htts_thr_func_t func)
|
int mio_svc_htts_dothr (mio_svc_htts_t* htts, mio_dev_sck_t* csck, mio_htre_t* req, mio_svc_htts_thr_func_t func)
|
||||||
{
|
{
|
||||||
mio_t* mio = htts->mio;
|
/*mio_t* mio = htts->mio;*/
|
||||||
// mio_svc_htts_cli_t* cli = mio_dev_sck_getxtn(csck);
|
// mio_svc_htts_cli_t* cli = mio_dev_sck_getxtn(csck);
|
||||||
thr_state_t* thr_state = MIO_NULL;
|
thr_state_t* thr_state = MIO_NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user