src/server/safs/cgiutils.c

changeset 121
a881dc866e23
parent 120
d2eb5fd97df0
child 122
6467dbb3e887
equal deleted inserted replaced
120:d2eb5fd97df0 121:a881dc866e23
36 36
37 #include "cgiutils.h" 37 #include "cgiutils.h"
38 38
39 #include <stdio.h> 39 #include <stdio.h>
40 #include <stdlib.h> 40 #include <stdlib.h>
41 #include <inttypes.h>
41 42
42 #include "../util/util.h" 43 #include "../util/util.h"
43 #include "../util/pblock.h" 44 #include "../util/pblock.h"
45 #include "../daemon/protocol.h"
44 46
45 47
46 //----------------------------------------------------------------------------- 48 //-----------------------------------------------------------------------------
47 // Macros 49 // Macros
48 //----------------------------------------------------------------------------- 50 //-----------------------------------------------------------------------------
282 //----------------------------------------------------------------------------- 284 //-----------------------------------------------------------------------------
283 // cgi_common_vars 285 // cgi_common_vars
284 //----------------------------------------------------------------------------- 286 //-----------------------------------------------------------------------------
285 287
286 char** cgi_common_vars(Session *sn, Request *rq, char **env) 288 char** cgi_common_vars(Session *sn, Request *rq, char **env)
287 { 289 {
288 // TODO: enable code and add cgi_client_auth_vars()
289 return env;
290 #if 0
291 char *t; 290 char *t;
292 int x; 291 int x;
293 292
294 env = util_env_create(env, MAX_CGI_COMMON_VARS, &x); 293 env = util_env_create(env, MAX_CGI_COMMON_VARS, &x);
295 294
295 /*
296 if (!_env_initialized) cgi_env_init(); 296 if (!_env_initialized) cgi_env_init();
297 if (_env_path) env[x++] = util_env_str("PATH", _env_path); 297 if (_env_path) env[x++] = util_env_str("PATH", _env_path);
298 if (_env_tz) env[x++] = util_env_str("TZ", _env_tz); 298 if (_env_tz) env[x++] = util_env_str("TZ", _env_tz);
299 if (_env_lang) env[x++] = util_env_str("LANG", _env_lang); 299 if (_env_lang) env[x++] = util_env_str("LANG", _env_lang);
300 if (_env_ldpath) env[x++] = util_env_str(LIBRARY_PATH, _env_ldpath); 300 if (_env_ldpath) env[x++] = util_env_str(LIBRARY_PATH, _env_ldpath);
301 env[x++] = util_env_str("SERVER_SOFTWARE", PRODUCT_HEADER_ID"/"PRODUCT_VERSION_ID); 301 env[x++] = util_env_str("SERVER_SOFTWARE", PRODUCT_HEADER_ID"/"PRODUCT_VERSION_ID);
302 302 */ // TODO: enable
303 NSString srvName, portStr; 303
304 char buf1[256], buf2[64]; 304 //NSString srvName, portStr;
305 srvName.useStatic(buf1, sizeof(buf1), 0); 305 //char buf1[256], buf2[64];
306 portStr.useStatic(buf2, sizeof(buf2), 0); 306 //srvName.useStatic(buf1, sizeof(buf1), 0);
307 GetServerHostnameAndPort(*rq, *sn, srvName, portStr); 307 //portStr.useStatic(buf2, sizeof(buf2), 0);
308 env[x++] = util_env_str("SERVER_PORT", (char*)(const char*)portStr); 308 //GetServerHostnameAndPort(*rq, *sn, srvName, portStr);
309 env[x++] = util_env_str("SERVER_NAME", (char*)(const char*)srvName); 309 char *scheme;
310 310 char *host;
311 t = http_uri2url_dynamic("","",sn,rq); 311 uint16_t port;
312 env[x++] = util_env_str("SERVER_URL", t); 312 http_get_scheme_host_port(sn, rq, &scheme, &host, &port);
313 FREE(t); 313 char portstr[8];
314 snprintf(portstr, 8, "%" PRIu16, (int)port);
315 env[x++] = util_env_str("SERVER_PORT", host);
316 env[x++] = util_env_str("SERVER_NAME", portstr);
317
318 //t = http_uri2url_dynamic("","",sn,rq);
319 //env[x++] = util_env_str("SERVER_URL", t);
320 //FREE(t);
314 321
315 char *ip; 322 char *ip;
316 ip = pblock_findval("ip", sn->client); 323 ip = pblock_findval("ip", sn->client);
317 t = session_dns(sn); 324 t = session_dns(sn);
318 env[x++] = util_env_str("REMOTE_HOST", (t ? t : ip)); 325 env[x++] = util_env_str("REMOTE_HOST", (t ? t : ip));
340 if (t = pblock_findval("status", rq->orig_rq->srvhdrs)) { 347 if (t = pblock_findval("status", rq->orig_rq->srvhdrs)) {
341 env[x++] = util_env_str("REDIRECT_STATUS", t); 348 env[x++] = util_env_str("REDIRECT_STATUS", t);
342 } 349 }
343 } 350 }
344 351
352 #if 0
345 if (GetSecurity(sn)) { 353 if (GetSecurity(sn)) {
346 env[x++] = util_env_str("HTTPS", "ON"); 354 env[x++] = util_env_str("HTTPS", "ON");
347 355
348 if (t = pblock_findval("keysize", sn->client)) 356 if (t = pblock_findval("keysize", sn->client))
349 env[x++] = util_env_str("HTTPS_KEYSIZE", t); 357 env[x++] = util_env_str("HTTPS_KEYSIZE", t);
367 env[x++] = util_env_str("HTTPS_RANDOM", random_string); 375 env[x++] = util_env_str("HTTPS_RANDOM", random_string);
368 376
369 } else { 377 } else {
370 env[x++] = util_env_str("HTTPS", "OFF"); 378 env[x++] = util_env_str("HTTPS", "OFF");
371 } 379 }
380 #endif
372 381
373 env[x] = NULL; 382 env[x] = NULL;
374 383
375 env = cgi_client_auth_vars(sn, rq, env); 384 //env = cgi_client_auth_vars(sn, rq, env); // TODO: enable
376 385
377 return env; 386 return env;
378 #endif 387
379 } 388 }

mercurial