diff -r d2eb5fd97df0 -r a881dc866e23 src/server/safs/cgiutils.c --- a/src/server/safs/cgiutils.c Fri Oct 28 19:29:38 2016 +0200 +++ b/src/server/safs/cgiutils.c Sat Oct 29 20:02:26 2016 +0200 @@ -38,9 +38,11 @@ #include #include +#include #include "../util/util.h" #include "../util/pblock.h" +#include "../daemon/protocol.h" //----------------------------------------------------------------------------- @@ -284,33 +286,38 @@ //----------------------------------------------------------------------------- char** cgi_common_vars(Session *sn, Request *rq, char **env) -{ - // TODO: enable code and add cgi_client_auth_vars() - return env; -#if 0 +{ char *t; int x; env = util_env_create(env, MAX_CGI_COMMON_VARS, &x); + /* if (!_env_initialized) cgi_env_init(); if (_env_path) env[x++] = util_env_str("PATH", _env_path); if (_env_tz) env[x++] = util_env_str("TZ", _env_tz); if (_env_lang) env[x++] = util_env_str("LANG", _env_lang); if (_env_ldpath) env[x++] = util_env_str(LIBRARY_PATH, _env_ldpath); env[x++] = util_env_str("SERVER_SOFTWARE", PRODUCT_HEADER_ID"/"PRODUCT_VERSION_ID); + */ // TODO: enable - NSString srvName, portStr; - char buf1[256], buf2[64]; - srvName.useStatic(buf1, sizeof(buf1), 0); - portStr.useStatic(buf2, sizeof(buf2), 0); - GetServerHostnameAndPort(*rq, *sn, srvName, portStr); - env[x++] = util_env_str("SERVER_PORT", (char*)(const char*)portStr); - env[x++] = util_env_str("SERVER_NAME", (char*)(const char*)srvName); - - t = http_uri2url_dynamic("","",sn,rq); - env[x++] = util_env_str("SERVER_URL", t); - FREE(t); + //NSString srvName, portStr; + //char buf1[256], buf2[64]; + //srvName.useStatic(buf1, sizeof(buf1), 0); + //portStr.useStatic(buf2, sizeof(buf2), 0); + //GetServerHostnameAndPort(*rq, *sn, srvName, portStr); + char *scheme; + char *host; + uint16_t port; + http_get_scheme_host_port(sn, rq, &scheme, &host, &port); + char portstr[8]; + snprintf(portstr, 8, "%" PRIu16, (int)port); + env[x++] = util_env_str("SERVER_PORT", host); + env[x++] = util_env_str("SERVER_NAME", portstr); + + //t = http_uri2url_dynamic("","",sn,rq); + //env[x++] = util_env_str("SERVER_URL", t); + //FREE(t); char *ip; ip = pblock_findval("ip", sn->client); @@ -342,6 +349,7 @@ } } +#if 0 if (GetSecurity(sn)) { env[x++] = util_env_str("HTTPS", "ON"); @@ -369,11 +377,12 @@ } else { env[x++] = util_env_str("HTTPS", "OFF"); } +#endif env[x] = NULL; - env = cgi_client_auth_vars(sn, rq, env); + //env = cgi_client_auth_vars(sn, rq, env); // TODO: enable return env; -#endif + }