Project

General

Profile

Feature #322 » Lighty1.patch

Updated original patch for 1.4.24. - EDevil, 2009-10-28 11:38

View differences:

light/lighttpd-1.4.24/src/mod_fastcgi.c 2009-10-28 11:01:31.000000000 +0000
1435 1435
							host->mode = FCGI_RESPONDER;
1436 1436
						} else if (strcmp(fcgi_mode->ptr, "authorizer") == 0) {
1437 1437
							host->mode = FCGI_AUTHORIZER;
1438
							if (buffer_is_empty(host->docroot)) {
1439
								log_error_write(srv, __FILE__, __LINE__, "s",
1440
										"ERROR: docroot is required for authorizer mode.");
1441
								return HANDLER_ERROR;
1442
							}
1443 1438
						} else {
1444 1439
							log_error_write(srv, __FILE__, __LINE__, "sbs",
1445 1440
									"WARNING: unknown fastcgi mode:",
......
2072 2067
	b->used++; /* add virtual \0 */
2073 2068
	hctx->wb->bytes_in += b->used - 1;
2074 2069

  
2075
	if (con->request.content_length) {
2070
	if (con->request.content_length && host->mode != FCGI_AUTHORIZER) {
2076 2071
		chunkqueue *req_cq = con->request_content_queue;
2077 2072
		chunk *req_c;
2078 2073
		off_t offset;
......
2375 2370
		default:
2376 2371
			break;
2377 2372
		}
2373
		if ( host->mode == FCGI_AUTHORIZER &&
2374
		     key_len > 9 &&
2375
		     0 == strncasecmp(key, CONST_STR_LEN("Variable-")) )
2376
		{
2377
			if ( key_len == 20 && 0 == strncasecmp(key, CONST_STR_LEN("Variable-REMOTE_USER")) ) {
2378
				buffer_copy_string(con->authed_user, value);
2379
			} else {
2380
				if (NULL == (ds = (data_string *)array_get_unused_element(con->environment, TYPE_STRING))) {
2381
					ds = data_response_init();
2382
				}
2383
				buffer_copy_string_len(ds->key, key + 9, key_len - 9);
2384
				buffer_copy_string(ds->value, value);
2385

  
2386
				array_insert_unique(con->environment, (data_unset *)ds);
2387
			}
2388
		}
2378 2389
	}
2379 2390

  
2380 2391
	if (have_sendfile2) {
......
3289 3300
				 * now to handle authorized request.
3290 3301
				 */
3291 3302

  
3303
                                con->http_status = 0;
3304
                        	if ( ! buffer_is_empty(host->docroot) ) {
3305
					/*
3306
					 * Serve local file if they specified
3307
					 * a docroot
3308
					 */
3292 3309
				buffer_copy_string_buffer(con->physical.doc_root, host->docroot);
3293 3310

  
3294 3311
				buffer_copy_string_buffer(con->physical.path, host->docroot);
......
3296 3313
				fcgi_connection_close(srv, hctx);
3297 3314

  
3298 3315
				con->mode = DIRECT;
3299
				con->http_status = 0;
3300 3316
				con->file_started = 1; /* fcgi_extension won't touch the request afterwards */
3301 3317
			} else {
3318
					if ( buffer_is_empty(con->authed_user) ) {
3319
						/*
3320
						 * Currently we depend on a
3321
						 * non-empty authed_user in order to
3322
						 * determine if a user has been
3323
						 * authed, this should probably change
3324
						 * in the future:
3325
						 */
3326
						buffer_copy_string(con->authed_user, "-");
3327
					}
3328

  
3329
					fcgi_connection_close(srv, hctx);
3330
					con->mode = DIRECT;
3331
					con->file_started = 0;
3332
					con->file_finished = 0;
3333
					buffer_reset(con->physical.path);
3334
				}
3335

  
3336
			} else {
3302 3337
				/* we are done */
3303 3338
				fcgi_connection_close(srv, hctx);
3304 3339
			}
......
3552 3587
				/* found nothign */
3553 3588
				extension = NULL;
3554 3589
			}
3590

  
3591
			if ( extension != NULL &&
3592
			     ! buffer_is_empty(con->authed_user) &&
3593
			     extension->used > 0 &&
3594
			     extension->hosts[0]->mode == FCGI_AUTHORIZER )
3595
			{
3596
				extension = NULL;
3597
			}
3598

  
3555 3599
			break;
3556 3600
		}
3557 3601
	}
......
3562 3606
			size_t ct_len; /* length of the config entry */
3563 3607
			fcgi_extension *ext = p->conf.exts->exts[k];
3564 3608

  
3609
			if ( ! buffer_is_empty(con->authed_user) &&
3610
			     ext->used > 0 &&
3611
			     ext->hosts[0]->mode == FCGI_AUTHORIZER )
3612
			{
3613
				continue;
3614
			}
3615

  
3565 3616
			if (ext->key->used == 0) continue;
3566 3617

  
3567 3618
			ct_len = ext->key->used - 1;
......
3686 3737
					con->uri.path->used = 1;
3687 3738
					con->uri.path->ptr[con->uri.path->used - 1] = '\0';
3688 3739
				} else if (extension->key->ptr[0] == '/' &&
3740
                                        extension->key->used > 2 &&
3689 3741
					con->uri.path->used > extension->key->used &&
3690 3742
					NULL != (pathinfo = strchr(con->uri.path->ptr + extension->key->used - 1, '/'))) {
3691 3743
					/* rewrite uri.path and pathinfo */
(2-2/3)