From 8b99f45aba426802f013c4dcf5f8386331ef342c Mon Sep 17 00:00:00 2001 From: "Fish (David B Trout)" Date: Thu, 11 Jul 2002 18:10:16 +0000 Subject: [PATCH] New HTTPROOT control file statement git-svn-id: file:///home/jj/hercules.svn/trunk@963 956126f8-22a0-4046-8f4a-272fa8102e63 --- CHANGES | 1 + config.c | 32 ++++----- config.h.in | 6 ++ configure | 159 ++++++++++++++++++++++++++++++++++++++++++++- hercules.h | 1 + html/hercconf.html | 14 ++++ httpserv.c | 20 +++--- impl.c | 1 + 8 files changed, 202 insertions(+), 32 deletions(-) diff --git a/CHANGES b/CHANGES index d93b695d..212e92da 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,4 @@ +11 Jul 2002 New optional HTTPROOT control file statement - Fish 09 Jul 2002 Minor fix to OPTION_CPU_UTILIZATION to fix FISH_HANG issue - Fish 02 Jul 2002 Fixes to ckdtab in dasdtab.c - Greg Smith 02 Jul 2002 Correct Erase All Unprotected 3270 order - Tomas Fott diff --git a/config.c b/config.c index 00d40973..6c904f27 100644 --- a/config.c +++ b/config.c @@ -81,7 +81,6 @@ static BYTE *operand; /* -> First argument */ static int addargc; /* Number of additional args */ static BYTE *addargv[MAX_ARGS]; /* Additional argument array */ -//#ifdef EXTERNALGUI /*-------------------------------------------------------------------*/ /* Subroutine to parse an argument string. The string that is passed */ /* is modified in-place by inserting null characters at the end of */ @@ -129,7 +128,6 @@ int parse_args (BYTE* p, int maxargc, BYTE** pargv, int* pargc) return *pargc; } -//#endif /*EXTERNALGUI*/ /*-------------------------------------------------------------------*/ /* Subroutine to read a statement from the configuration file */ @@ -199,8 +197,6 @@ int stmtlen; /* Statement length */ if (stmtlen == 0 || buf[0] == '*' || buf[0] == '#') continue; -#if 1 // def EXTERNALGUI - /* Parse the statement just read */ parse_args (buf, MAX_ARGS, addargv, &addargc); @@ -218,23 +214,6 @@ int stmtlen; /* Statement length */ else addargv[i] = NULL; } -#else /*EXTERNALGUI*/ - - /* Split the statement into keyword and first operand */ - keyword = strtok (buf, " \t"); - operand = strtok (NULL, " \t"); - - /* Extract any additional operands */ - for (addargc = 0; addargc < MAX_ARGS && - (addargv[addargc] = strtok (NULL, " \t")) != NULL - && addargv[addargc][0] != '#'; - addargc++); - - /* Clear any unused additional operand pointers */ - for (i = addargc; i < MAX_ARGS; i++) addargv[i] = NULL; - -#endif /*!EXTERNALGUI*/ - break; } /* end while */ @@ -570,6 +549,17 @@ BYTE c; /* Work area for sscanf */ } } + else if (strcasecmp (keyword, "httproot") == 0) + { + if (operand) + sysblk.httproot = strdup(operand); + else + { + logmsg(_("HHS003E Error in %s line %d: Missing argument.\n"), + fname, stmt); + exit(1); + } + } #endif /*defined(OPTION_HTTP_SERVER)*/ else if (strcasecmp (keyword, "cckd") == 0) { diff --git a/config.h.in b/config.h.in index 6d3b8f3d..0d0ba585 100644 --- a/config.h.in +++ b/config.h.in @@ -70,6 +70,12 @@ /* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE +/* Define to 1 if you have the `getresuid' function. */ +#undef HAVE_GETRESUID + +/* Define to 1 if you have the `getreuid' function. */ +#undef HAVE_GETREUID + /* Define if the GNU gettext() function is already present or preinstalled. */ #undef HAVE_GETTEXT diff --git a/configure b/configure index 9a231da2..5de1fbc3 100755 --- a/configure +++ b/configure @@ -8309,8 +8309,76 @@ fi done +echo "$as_me:$LINENO: checking for InitializeCriticalSectionAndSpinCount" >&5 +echo $ECHO_N "checking for InitializeCriticalSectionAndSpinCount... $ECHO_C" >&6 +if test "${ac_cv_func_InitializeCriticalSectionAndSpinCount+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char InitializeCriticalSectionAndSpinCount (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char InitializeCriticalSectionAndSpinCount (); +char (*f) (); -for ac_func in setresuid setreuid +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_InitializeCriticalSectionAndSpinCount) || defined (__stub___InitializeCriticalSectionAndSpinCount) +choke me +#else +f = InitializeCriticalSectionAndSpinCount; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_InitializeCriticalSectionAndSpinCount=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_func_InitializeCriticalSectionAndSpinCount=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_InitializeCriticalSectionAndSpinCount" >&5 +echo "${ECHO_T}$ac_cv_func_InitializeCriticalSectionAndSpinCount" >&6 + + +# If we have setresuid AND getresuid, we can do setuid stuff + + +for ac_func in setresuid getresuid do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -8381,10 +8449,97 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF - enable_setuid=true;break + enable_setuid=true +else + enable_setuid=false;break fi done + +if test x$enable_setuid != xtrue; then + # Likewise if we have setreuid AND getreuid + + +for ac_func in setreuid getreuid +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +f = $ac_func; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + enable_setuid=true +else + enable_setuid=false;break +fi +done + +fi + +# Otherwise, not if test x$enable_setuid != xtrue; then cat >>confdefs.h <<\_ACEOF #define NO_SETUID 1 diff --git a/hercules.h b/hercules.h index d2fbc97f..6535ca41 100644 --- a/hercules.h +++ b/hercules.h @@ -719,6 +719,7 @@ typedef struct _SYSBLK { int httpauth; /* HTTP auth required flag */ char *httpuser; /* HTTP userid */ char *httppass; /* HTTP password */ + char *httproot; /* HTTP root */ // #endif /*defined(OPTION_HTTP_SERVER)*/ CPCONV *codepage; #ifdef OPTION_IODELAY_KLUDGE diff --git a/html/hercconf.html b/html/hercconf.html index 15762463..3007802a 100644 --- a/html/hercconf.html +++ b/html/hercconf.html @@ -29,6 +29,7 @@ a real System/390. The configuration file is an ASCII text file. CODEPAGE default CNSLPORT 3270 HTTPPORT 8081 + HTTPROOT /usr/local/share/hercules/ NUMCPU 1 NUMVEC 1 CPUPRIO 15 @@ -100,6 +101,19 @@ The following system parameters may be specified: AUTH indictates that a userid and password are required to access the HTTP server, whereas NOAUTH indicates that a userid and password are not required. The userid and password may be any valid string. +
HTTPROOTpathname +
specifies the root directory where the HTTP server's files reside. + The default value varies depending on how the hercules executable was + built, but is usually /usr/local/share/hercules/.
+ Note: Windows users + of Hercules who do not have Cygwin installed (and are instead just using + the Cygwin DLLs) should specify "/cygdrive/x/pathname/" where + 'x' is the Windows drive letter. For example, if the Windows + directory where the http server's files reside is + "H:\Hercules\httpserv\" + then you should specify + "/cygdrive/h/Hercules/httpserv/" + on your HTTPROOT statement.
CNSLPORT nnnn
specifies the port number (in decimal) to which tn3270 and telnet clients will connect diff --git a/httpserv.c b/httpserv.c index 878f37d3..55139e7f 100644 --- a/httpserv.c +++ b/httpserv.c @@ -17,12 +17,12 @@ /* */ /* If the request is for a /cgi-bin/ path, then the cgibin */ /* directory in cgibin.c will be searched, for any other request */ -/* the HTTP_ROOT (/usr/local/hercules) will be used as the root */ -/* to find the specified file. */ +/* the sysblk.httproot (/usr/local/hercules) will be used as the */ +/* root to find the specified file. */ /* */ /* As realpath() is used to verify that the files are from within */ -/* the HTTP_ROOT tree symbolic links that refer to files outside */ -/* the HTTP_ROOT tree are not supported. */ +/* the sysblk.httproot tree symbolic links that refer to files */ +/* outside the sysblk.httproot tree are not supported. */ /* */ /* */ /* Jan Jaeger - 28/03/2002 */ @@ -52,11 +52,12 @@ static CONTYP mime_types[] = { int html_include(WEBBLK *webblk, char *filename) { FILE *inclfile; - char fullname[1024] = HTTP_ROOT; + char fullname[1024]; char buffer[1024]; int ret; - inclfile = fopen(strcat(fullname,filename),"r"); + strncpy(fullname,sysblk.httproot,1024); + inclfile = fopen(strncat(fullname,filename,1024),"r"); if (!inclfile) { @@ -280,7 +281,7 @@ static void http_verify_path(WEBBLK *webblk, char *path) char resolved_path[1024]; int i; - realpath(HTTP_ROOT,resolved_base); strcat(resolved_base,"/"); + realpath(sysblk.httproot,resolved_base); strncat(resolved_base,"/",1024); realpath(path,resolved_path); for (i = 0; path[i]; i++) @@ -358,11 +359,12 @@ static void http_download(WEBBLK *webblk, char *filename) char tbuf[80]; int fd, length; char *filetype; - char fullname[1024] = HTTP_ROOT; + char fullname[1024]; struct stat st; CONTYP *mime_type = mime_types; - strcat(fullname,filename); + strncpy(fullname,sysblk.httproot,1024); + strncat(fullname,filename,1024); http_verify_path(webblk,fullname); diff --git a/impl.c b/impl.c index 98339075..ce0b9027 100644 --- a/impl.c +++ b/impl.c @@ -230,6 +230,7 @@ TID paneltid; #if defined(OPTION_HTTP_SERVER) if(sysblk.httpport) { /* Start the http server connection thread */ + if (!sysblk.httproot) sysblk.httproot = HTTP_ROOT; if ( create_thread (&sysblk.httptid, &sysblk.detattr, http_server, NULL) ) {