Changeset 2760 for trunk/server
- Timestamp:
- Feb 27, 2016, 2:16:45 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/server/common/oursrc/httpdmods/mod_vhost_ldap.c ¶
r2755 r2760 399 399 } 400 400 401 static const char *escape(apr_pool_t *p, const char *input) 402 { 403 static const char *const to_escape = "'\\"; 404 405 const char *x = input + strcspn(input, to_escape); 406 if (*x == '\0') 407 return input; 408 const char *y = x; 409 size_t extra = 0; 410 while (*y != '\0') { 411 extra++; 412 size_t k = strcspn(y + 1, to_escape) + 1; 413 y += k; 414 } 415 416 char *output = apr_palloc(p, y - input + extra + 1); 417 418 memcpy(output, input, x - input); 419 char *z = output + (x - input); 420 while (*x != '\0') { 421 *z++ = '\\'; 422 size_t k = strcspn(x + 1, to_escape) + 1; 423 memcpy(z, x, k); 424 x += k; 425 z += k; 426 } 427 *z = '\0'; 428 429 return output; 430 } 431 401 432 static int reconfigure_directive(apr_pool_t *p, 402 433 server_rec *s, … … 583 614 for (i = 0; attributes[i]; i++) { 584 615 585 const char *directive;586 616 char *val = apr_pstrdup (r->pool, vals[i]); 587 617 /* These do not correspond to any real directives */ … … 602 632 continue; 603 633 } 604 605 if (strcasecmp (attributes[i], "scriptsVhostName") == 0) { 634 else if (strcasecmp (attributes[i], "scriptsVhostName") == 0) { 606 635 reqc->name = val; 607 directive = "ServerName";636 continue; 608 637 } 609 638 else { … … 614 643 continue; 615 644 } 616 617 if (val == NULL)618 continue;619 620 if ((code = reconfigure_directive(r->pool, server, directive, val)) != 0)621 return code;622 645 } 623 646 } … … 639 662 } 640 663 664 if ((code = reconfigure_directive( 665 r->pool, server, "ServerName", 666 apr_pstrcat(r->pool, "'", escape(r->pool, reqc->name), "'", (const char *)NULL))) != 0) 667 return code; 668 641 669 char *docroot = 642 670 strcmp(reqc->directory, ".") == 0 ? 643 671 apr_pstrcat(r->pool, reqc->home, "/web_scripts", (const char *)NULL) : 644 672 apr_pstrcat(r->pool, reqc->home, "/web_scripts/", reqc->directory, (const char *)NULL); 645 if ((code = reconfigure_directive(r->pool, server, "DocumentRoot", docroot)) != 0) 673 if ((code = reconfigure_directive( 674 r->pool, server, "DocumentRoot", 675 apr_pstrcat(r->pool, "'", escape(r->pool, docroot), "'", (const char *)NULL))) != 0) 646 676 return code; 647 677 … … 651 681 uid_t uid = (uid_t) atoll(reqc->uid); 652 682 653 if ((code = reconfigure_directive(r->pool, server, "UserDir", USERDIR)) != 0) 683 if ((code = reconfigure_directive( 684 r->pool, server, "UserDir", 685 apr_pstrcat(r->pool, "'", escape(r->pool, USERDIR), "'", (const char *)NULL))) != 0) 654 686 return code; 655 687 … … 664 696 } 665 697 666 userdir_val = apr_pstrcat(r->pool, "enabled ", username, (const char *)NULL);698 userdir_val = apr_pstrcat(r->pool, "enabled '", escape(r->pool, username), "'", (const char *)NULL); 667 699 668 700 if ((code = reconfigure_directive(r->pool, server, "UserDir", userdir_val)) != 0)
Note: See TracChangeset
for help on using the changeset viewer.