Changeset 842 for server/common
- Timestamp:
- Sep 28, 2008, 3:43:31 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/common/patches/httpd-suexec-scripts.patch
r823 r842 47 47 --- httpd-2.2.2/support/suexec.c.old 2006-04-21 21:53:06.000000000 -0400 48 48 +++ httpd-2.2.2/support/suexec.c 2007-05-22 10:32:04.000000000 -0400 49 @@ -30,6 +30, 8@@49 @@ -30,6 +30,9 @@ 50 50 * 51 51 */ 52 52 53 53 +#define STATIC_CAT_PATH "/usr/local/bin/static-cat" 54 +#define PHP_PATH "/usr/bin/php-cgi" 54 55 + 55 56 #include "apr.h" … … 72 73 73 74 /* variable name is */ 74 @@ -140,6 +144,7 @@ 75 "UNIQUE_ID=", 76 "USER_NAME=", 77 "TZ=", 78 + "PHPRC=", 79 NULL 80 }; 81 82 @@ -245,9 +250,58 @@ 75 @@ -245,9 +250,65 @@ 83 76 environ = cleanenv; 84 77 } … … 132 125 +} 133 126 + 127 +static int is_php_extension(const char *file) 128 +{ 129 + const char *extension = strrchr(file, '.'); 130 + if (extension == NULL) return 0; 131 + return strcmp(extension + 1, "php") == 0; 132 +} 133 + 134 134 int main(int argc, char *argv[]) 135 135 { … … 259 259 (gid != dir_info.st_gid) || 260 260 (uid != prg_info.st_uid) || 261 @@ -574, 6 +676,7@@261 @@ -574,12 +676,14 @@ 262 262 prg_info.st_uid, prg_info.st_gid); 263 263 exit(120); … … 267 267 * Error out if the program is not executable for the user. 268 268 * Otherwise, she won't find any error in the logs except for 269 @@ -606,6 +709,13 @@ 269 * "[error] Premature end of script headers: ..." 270 */ 271 - if (!(prg_info.st_mode & S_IXUSR)) { 272 + if (!is_static_extension(cmd) && !is_php_extension(cmd) && 273 + !(prg_info.st_mode & S_IXUSR)) { 274 log_err("file has no execute permission: (%s/%s)\n", cwd, cmd); 275 exit(121); 276 } 277 @@ -606,6 +709,21 @@ 270 278 exit(122); 271 279 } … … 277 285 + exit(255); 278 286 + } 287 + if (is_php_extension(cmd)) { 288 + setenv("PHPRC", ".", 1); 289 + argv[1] = PHP_PATH; 290 + argv[2] = "-f"; 291 + execv(PHP_PATH, &argv[1]); 292 + log_err("(%d)%s: php exec failed (%s)\n", errno, strerror(errno), argv[2]); 293 + exit(255); 294 + } 279 295 + 280 296 /*
Note: See TracChangeset
for help on using the changeset viewer.