Back to index

php5  5.3.10
Functions | Variables
fpm_php.c File Reference
#include "fpm_config.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "php.h"
#include "php_main.h"
#include "php_ini.h"
#include "ext/standard/dl.h"
#include "fastcgi.h"
#include "fpm.h"
#include "fpm_php.h"
#include "fpm_cleanup.h"
#include "fpm_worker_pool.h"
#include "zlog.h"

Go to the source code of this file.

Functions

static int fpm_php_zend_ini_alter_master (char *name, int name_length, char *new_value, int new_value_length, int mode, int stage TSRMLS_DC)
static void fpm_php_disable (char *value, int(*zend_disable)(char *, uint TSRMLS_DC) TSRMLS_DC)
int fpm_php_apply_defines_ex (struct key_value_s *kv, int mode)
static int fpm_php_apply_defines (struct fpm_worker_pool_s *wp)
static int fpm_php_set_allowed_clients (struct fpm_worker_pool_s *wp)
char * fpm_php_script_filename (TSRMLS_D)
char * fpm_php_request_uri (TSRMLS_D)
char * fpm_php_request_method (TSRMLS_D)
char * fpm_php_query_string (TSRMLS_D)
char * fpm_php_auth_user (TSRMLS_D)
size_t fpm_php_content_length (TSRMLS_D)
static void fpm_php_cleanup (int which, void *arg)
void fpm_php_soft_quit ()
int fpm_php_init_main ()
int fpm_php_init_child (struct fpm_worker_pool_s *wp)
int fpm_php_limit_extensions (char *path)

Variables

static char ** limit_extensions = NULL

Function Documentation

static int fpm_php_apply_defines ( struct fpm_worker_pool_s wp) [static]

Definition at line 117 of file fpm_php.c.

{
       struct key_value_s *kv;

       for (kv = wp->config->php_values; kv; kv = kv->next) {
              if (fpm_php_apply_defines_ex(kv, ZEND_INI_USER) == -1) {
                     zlog(ZLOG_ERROR, "Unable to set php_value '%s'", kv->key);
              }
       }

       for (kv = wp->config->php_admin_values; kv; kv = kv->next) {
              if (fpm_php_apply_defines_ex(kv, ZEND_INI_SYSTEM) == -1) {
                     zlog(ZLOG_ERROR, "Unable to set php_admin_value '%s'", kv->key);
              }
       }

       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int fpm_php_apply_defines_ex ( struct key_value_s kv,
int  mode 
)

Definition at line 80 of file fpm_php.c.

{
       TSRMLS_FETCH();

       char *name = kv->key;
       char *value = kv->value;
       int name_len = strlen(name);
       int value_len = strlen(value);

       if (!strcmp(name, "extension") && *value) {
              zval zv;
              php_dl(value, MODULE_PERSISTENT, &zv, 1 TSRMLS_CC);
              return Z_BVAL(zv) ? 1 : -1;
       }

       if (fpm_php_zend_ini_alter_master(name, name_len+1, value, value_len, mode, PHP_INI_STAGE_ACTIVATE TSRMLS_CC) == FAILURE) {
              return -1;
       }

       if (!strcmp(name, "disable_functions") && *value) {
              char *v = strdup(value);
              PG(disable_functions) = v;
              fpm_php_disable(v, zend_disable_function TSRMLS_CC);
              return 1;
       }

       if (!strcmp(name, "disable_classes") && *value) {
              char *v = strdup(value);
              PG(disable_classes) = v;
              fpm_php_disable(v, zend_disable_class TSRMLS_CC);
              return 1;
       }

       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 184 of file fpm_php.c.

{
       return SG(request_info).auth_user;
}

Here is the caller graph for this function:

static void fpm_php_cleanup ( int  which,
void *  arg 
) [static]

Definition at line 196 of file fpm_php.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 190 of file fpm_php.c.

{
       return SG(request_info).content_length;
}

Here is the caller graph for this function:

static void fpm_php_disable ( char *  value,
int(*)(char *, uint TSRMLS_DC) TSRMLS_DC  zend_disable 
) [static]

Definition at line 51 of file fpm_php.c.

{
       char *s = 0, *e = value;

       while (*e) {
              switch (*e) {
                     case ' ':
                     case ',':
                            if (s) {
                                   *e = '\0';
                                   zend_disable(s, e - s TSRMLS_CC);
                                   s = 0;
                            }
                            break;
                     default:
                            if (!s) {
                                   s = e;
                            }
                            break;
              }
              e++;
       }

       if (s) {
              zend_disable(s, e - s TSRMLS_CC);
       }
}

Here is the caller graph for this function:

Definition at line 219 of file fpm_php.c.

{
       if (0 > fpm_php_apply_defines(wp) ||
              0 > fpm_php_set_allowed_clients(wp)) {
              return -1;
       }

       if (wp->limit_extensions) {
              limit_extensions = wp->limit_extensions;
       }
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 210 of file fpm_php.c.

{
       if (0 > fpm_cleanup_add(FPM_CLEANUP_PARENT, fpm_php_cleanup, 0)) {
              return -1;
       }
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int fpm_php_limit_extensions ( char *  path)

Definition at line 233 of file fpm_php.c.

{
       char **p;
       size_t path_len;

       if (!path || !limit_extensions) {
              return 0; /* allowed by default */
       }

       p = limit_extensions;
       path_len = strlen(path);
       while (p && *p) {
              size_t ext_len = strlen(*p);
              if (path_len > ext_len) {
                     char *path_ext = path + path_len - ext_len;
                     if (strcmp(*p, path_ext) == 0) {
                            return 0; /* allow as the extension has been found */
                     }
              }
              p++;
       }


       zlog(ZLOG_NOTICE, "Access to the script '%s' has been denied (see security.limit_extensions)", path);
       return 1; /* extension not found: not allowed  */
}

Here is the caller graph for this function:

Definition at line 178 of file fpm_php.c.

{
       return SG(request_info).query_string;
}

Here is the caller graph for this function:

Definition at line 172 of file fpm_php.c.

{
       return (char *) SG(request_info).request_method;
}

Here is the caller graph for this function:

Definition at line 166 of file fpm_php.c.

{
       return (char *) SG(request_info).request_uri;
}

Here is the caller graph for this function:

Definition at line 160 of file fpm_php.c.

{
       return SG(request_info).path_translated;
}

Here is the caller graph for this function:

static int fpm_php_set_allowed_clients ( struct fpm_worker_pool_s wp) [static]

Definition at line 136 of file fpm_php.c.

{
       if (wp->listen_address_domain == FPM_AF_INET) {
              fcgi_set_allowed_clients(wp->config->listen_allowed_clients);
       }
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 204 of file fpm_php.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static int fpm_php_zend_ini_alter_master ( char *  name,
int  name_length,
char *  new_value,
int  new_value_length,
int  mode,
int stage  TSRMLS_DC 
) [static]

Definition at line 26 of file fpm_php.c.

{
       zend_ini_entry *ini_entry;
       char *duplicate;

       if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == FAILURE) {
              return FAILURE;
       }

       duplicate = strdup(new_value);

       if (!ini_entry->on_modify
                     || ini_entry->on_modify(ini_entry, duplicate, new_value_length,
                            ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC) == SUCCESS) {
              ini_entry->value = duplicate;
              ini_entry->value_length = new_value_length;
              ini_entry->modifiable = mode;
       } else {
              free(duplicate);
       }

       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char** limit_extensions = NULL [static]

Definition at line 24 of file fpm_php.c.