Ticket #219: lighttpd-1.4.1-include_glob.diff
| File lighttpd-1.4.1-include_glob.diff, 6.1 kB (added by Aaron Walker <ka0ttic@…>, 3 years ago) |
|---|
-
lighttpd-1.4.1
diff --exclude='*~' --exclude='.*' -I '$Id:' -urN lighttpd-1.4.1.orig/configure.in lighttpd-1.4.1/configure.in
old new 56 56 sys/socket.h sys/time.h unistd.h sys/sendfile.h sys/uio.h \ 57 57 getopt.h sys/epoll.h sys/select.h poll.h sys/poll.h sys/devpoll.h sys/filio.h \ 58 58 sys/mman.h sys/event.h sys/port.h winsock2.h pwd.h sys/syslimits.h \ 59 sys/resource.h sys/un.h syslog.h ])59 sys/resource.h sys/un.h syslog.h glob.h]) 60 60 61 61 # Checks for typedefs, structures, and compiler characteristics. 62 62 AC_C_CONST … … 397 397 strdup strerror strstr strtol sendfile getopt socket \ 398 398 gethostbyname poll sigtimedwait epoll_ctl getrlimit chroot \ 399 399 getuid select signal pathconf\ 400 writev sigaction sendfile64 send_file kqueue port_create localtime_r]) 400 writev sigaction sendfile64 send_file kqueue port_create localtime_r\ 401 glob]) 401 402 402 403 AC_MSG_CHECKING(for Large File System support) 403 404 AC_ARG_ENABLE(lfs, -
doc/configuration.txt
diff --exclude='*~' --exclude='.*' -I '$Id:' -urN lighttpd-1.4.1.orig/doc/configuration.txt lighttpd-1.4.1/doc/configuration.txt
old new 36 36 <array> : "(" [ <string> "=>" ] <value> [, [ <string> "=>" ] <value> ]* ")" 37 37 INCLUDE : "include" VALUE 38 38 INCLUDE_SHELL : "include_shell" STRING_VALUE 39 INCLUDE_GLOB : "include_glob" STRING_VALUE 39 40 40 41 Example 41 42 ------- … … 64 65 # read configuration from output of a command 65 66 include_shell "/usr/local/bin/confmimetype /etc/mime.types" 66 67 68 # include all files matching the specified glob pattern 69 include_glob "*.conf" 70 67 71 68 72 Conditional Configuration 69 73 ========================= -
src/configfile.c
diff --exclude='*~' --exclude='.*' -I '$Id:' -urN lighttpd-1.4.1.orig/src/configfile.c lighttpd-1.4.1/src/configfile.c
old new 745 745 tid = TK_INCLUDE; 746 746 } else if (strcmp(token->ptr, "include_shell") == 0) { 747 747 tid = TK_INCLUDE_SHELL; 748 } else if (strcmp(token->ptr, "include_glob") == 0) { 749 tid = TK_INCLUDE_GLOB; 748 750 } else if (strcmp(token->ptr, "else") == 0) { 749 751 tid = TK_ELSE; 750 752 } else { … … 844 846 tokenizer_t t; 845 847 stream s; 846 848 int ret; 849 size_t i; 847 850 buffer *filename; 851 data_string *ds; 852 853 /* don't parse it if we've parsed it already */ 854 for (i = 0; i < context->parsed->used; i++) { 855 if (buffer_is_equal_string( 856 ((data_string *)(context->parsed->data[i]))->value, 857 fn, strlen(fn))) { 858 return 0; 859 } 860 } 861 862 ds = data_string_init(); 863 buffer_copy_string(ds->value, fn); 864 array_insert_unique(context->parsed, (data_unset *)ds); 848 865 849 866 if (buffer_is_empty(context->basedir) && 850 867 (fn[0] == '/' || fn[0] == '\\') && … … 910 927 context->ok = 1; 911 928 context->configs_stack = array_init(); 912 929 context->configs_stack->is_weakref = 1; 930 context->parsed = array_init(); 913 931 context->basedir = buffer_init(); 914 932 } 915 933 916 934 static void context_free(config_t *context) { 917 935 array_free(context->configs_stack); 936 array_free(context->parsed); 918 937 buffer_free(context->basedir); 919 938 } 920 939 -
src/configfile.h
diff --exclude='*~' --exclude='.*' -I '$Id:' -urN lighttpd-1.4.1.orig/src/configfile.h lighttpd-1.4.1/src/configfile.h
old new 10 10 int ok; 11 11 array *all_configs; 12 12 array *configs_stack; /* to parse nested block */ 13 array *parsed; /* keep track of the configs we've parsed */ 13 14 data_config *current; /* current started with { */ 14 15 buffer *basedir; 15 16 } config_t; -
src/configparser.y
diff --exclude='*~' --exclude='.*' -I '$Id:' -urN lighttpd-1.4.1.orig/src/configparser.y lighttpd-1.4.1/src/configparser.y
old new 7 7 #include <stdio.h> 8 8 #include <string.h> 9 9 #include "config.h" 10 #ifdef HAVE_GLOB_H 11 # include <errno.h> 12 # include <glob.h> 13 #endif 10 14 #include "configfile.h" 11 15 #include "buffer.h" 12 16 #include "array.h" … … 132 136 metaline ::= condlines(A) EOL. { A = NULL; } 133 137 metaline ::= include. 134 138 metaline ::= include_shell. 139 metaline ::= include_glob. 135 140 metaline ::= EOL. 136 141 137 142 %type value {data_unset *} … … 504 509 A = NULL; 505 510 } 506 511 } 512 513 include_glob ::= INCLUDE_GLOB stringop(A). { 514 if (ctx->ok) { 515 #ifdef HAVE_GLOB 516 size_t i; 517 int ret; 518 glob_t gbuf; 519 buffer *globstr; 520 521 /* construct full path for passing to glob() */ 522 if (buffer_is_empty(ctx->basedir) && 523 (A->ptr[0] == '/' || A->ptr[0] == '\\') && 524 (A->ptr[0] == '.' && (A->ptr[1] == '/' || A->ptr[1] == '\\'))) { 525 globstr = buffer_init_buffer(A); 526 } else { 527 globstr = buffer_init_buffer(ctx->basedir); 528 buffer_append_string_buffer(globstr, A); 529 } 530 531 errno = 0; 532 if (0 != (ret = glob(globstr->ptr, GLOB_ERR|GLOB_MARK, NULL, &gbuf))) { 533 ctx->ok = 0; 534 535 if (ret == GLOB_NOMATCH) { 536 fprintf(stderr, "nothing matches glob pattern '%s'\n", globstr->ptr); 537 } 538 else if (errno) { 539 fprintf(stderr, "glob: %s\n", strerror(errno)); 540 } 541 else { 542 fprintf(stderr, "internal glob() error\n"); 543 } 544 } 545 else { 546 for (i = 0; gbuf.gl_pathv[i] != NULL; i++) { 547 const char *path = gbuf.gl_pathv[i]; 548 549 /* skip directories ('/' is appended due to GLOB_MARK option) */ 550 if (path[strlen(path) - 1] == '/') { 551 continue; 552 } 553 554 /* remove the basedir we added to get the glob results */ 555 if (!buffer_is_empty(ctx->basedir)) { 556 path += strlen(ctx->basedir->ptr); 557 } 558 559 if (0 != config_parse_file(ctx->srv, ctx, path)) { 560 ctx->ok = 0; 561 break; 562 } 563 } 564 } 565 buffer_free(globstr); 566 globstr = NULL; 567 globfree(&gbuf); 568 569 #else 570 fprintf(stderr, "The include_glob directive requires the glob() function.\n"); 571 ctx->ok = 0; 572 #endif 573 574 buffer_free(A); 575 A = NULL; 576 } 577 }

