Skip to content

Commit

Permalink
Bumping to v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Whissi committed Jun 1, 2014
1 parent a770958 commit 33de0c2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions turbo_realpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,41 @@ ZEND_GET_MODULE(turbo_realpath)

PHP_INI_BEGIN()
PHP_INI_ENTRY("realpath_cache_basedir", "", PHP_INI_SYSTEM, NULL)
PHP_INI_ENTRY("realpath_cache_security", "", PHP_INI_SYSTEM, NULL)
PHP_INI_END()

PHP_RINIT_FUNCTION(turbo_realpath)
{
char *basedir = INI_STR("realpath_cache_basedir");
char *disabled_functions = INI_STR("disable_functions");
char *risky_functions = "link,symlink";
char *new_functions;
int security = INI_INT("realpath_cache_security");



if(strlen(basedir) > 0) {
zend_alter_ini_entry("open_basedir", sizeof("open_basedir"), basedir, strlen(basedir), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
}

switch(security) {
// check disabled functions for symlink and link entries
case 1:
if(strlen(disabled_functions) > 0) {
new_functions = emalloc(strlen(disabled_functions) + strlen(risky_functions) + 2);
strcpy(new_functions, risky_functions);
strcat(new_functions, ",");
strcat(new_functions, disabled_functions);
} else {
new_functions = emalloc(strlen(risky_functions) + 1);
strcpy(new_functions, risky_functions);
}
zend_alter_ini_entry("disable_functions", sizeof("disable_functions"), new_functions, strlen(new_functions), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
efree(new_functions);
break;
default:
break;
}
}

PHP_MINIT_FUNCTION(turbo_realpath)
Expand All @@ -63,6 +89,7 @@ PHP_MINFO_FUNCTION(turbo_realpath)
php_info_print_table_header(2, "Turbo Real Path", "enabled");
php_info_print_table_row(2, "Extension version", PHP_TURBO_REALPATH_VERSION);
php_info_print_table_row(2, "RealPath basedir path", INI_STR("realpath_cache_basedir"));
php_info_print_table_row(2, "RealPath basedir security", INI_INT("realpath_cache_security") == 1 ? "On" : "Off");
php_info_print_table_row(2, "Author", "Artur Graniszewski");
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
Expand Down
2 changes: 1 addition & 1 deletion turbo_realpath.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef PHP_TURBO_H
#define PHP_TURBO_H 1

#define PHP_TURBO_REALPATH_VERSION "1.0"
#define PHP_TURBO_REALPATH_VERSION "1.1"
#define PHP_TURBO_REALPATH_EXTNAME "turbo_realpath"

PHP_RINIT_FUNCTION(turbo_realpath);
Expand Down

0 comments on commit 33de0c2

Please sign in to comment.