Beispiel #1
0
static ret_t
configure (cherokee_rule_fullpath_t  *rule,
           cherokee_config_node_t    *conf,
           cherokee_virtual_server_t *vsrv)
{
	ret_t                   ret;
	cherokee_config_node_t *subconf;
	cherokee_list_t        *i;

	UNUSED (vsrv);

	/* Get the entry
	 */
	ret = cherokee_config_node_get (conf, "fullpath", &subconf);
	if (ret != ret_ok) {
		LOG_CRITICAL (CHEROKEE_ERROR_RULE_NO_PROPERTY,
		              RULE(rule)->priority, "fullpath");
		return ret_error;
	}

	/* Add the paths
	 */
	cherokee_config_node_foreach (i, subconf) {
		cherokee_config_node_t *path = CONFIG_NODE(i);

		TRACE(ENTRIES, "Adding fullpath entry (key=%s): '%s'\n",
		      path->key.buf, path->val.buf);

		cherokee_avl_add (&rule->paths, &path->val, NULL);
	}
Beispiel #2
0
static ret_t
configure (cherokee_rule_not_t       *rule,
           cherokee_config_node_t    *conf,
           cherokee_virtual_server_t *vsrv)
{
	ret_t                   ret;
	cherokee_config_node_t *subconf = NULL;

	/* Get the configuration sub-tree
	 */
	ret = cherokee_config_node_get (conf, "right", &subconf);
	if (ret != ret_ok)
		return ret;

	/* Instance the sub-rule match
	 */
	ret = cherokee_virtual_server_new_rule (vsrv, subconf,
	                                        RULE(rule)->priority,
	                                        &rule->right);
	if (ret != ret_ok)
		return ret;

	if (rule->right == NULL)
		return ret_error;

	/* Let the child rule know about its parent
	 */
	rule->right->parent_rule = RULE(rule);

	return ret_ok;
}
static ret_t
configure (cherokee_vrule_target_ip_t   *vrule,
	   cherokee_config_node_t       *conf,
	   cherokee_virtual_server_t    *vsrv)
{
	ret_t                   ret;
	cherokee_list_t        *i;
	cherokee_config_node_t *subconf;

	UNUSED(vsrv);

	ret = cherokee_config_node_get (conf, "to", &subconf);
	if (ret != ret_ok) {
		LOG_CRITICAL (CHEROKEE_ERROR_VRULE_NO_PROPERTY, VRULE(vrule)->priority, "to");
		return ret_error;
	}

	cherokee_config_node_foreach (i, subconf) {
		cherokee_config_node_t *subconf2 = CONFIG_NODE(i);

		ret = cherokee_access_add (&vrule->access, subconf2->val.buf);
		if (ret != ret_ok) {
			LOG_ERROR (CHEROKEE_ERROR_VRULE_TARGET_IP_PARSE, subconf2->val.buf);
			return ret_error;
		}
	}
Beispiel #4
0
static ret_t
configure_branch (cherokee_rule_and_t       *rule,
		  cherokee_config_node_t    *conf,
		  cherokee_virtual_server_t *vsrv,
		  const char                *branch,
		  cherokee_rule_t          **branch_rule)
{
	ret_t                   ret;
	cherokee_config_node_t *subconf = NULL;

	/* Get the configuration sub-tree
	 */
	ret = cherokee_config_node_get (conf, branch, &subconf);
	if (ret != ret_ok)
		return ret;

	/* Instance the sub-rule match
	 */
	ret = cherokee_virtual_server_new_rule (vsrv, subconf,
						RULE(rule)->priority,
						branch_rule);
	if (ret != ret_ok)
		return ret;

	return ret_ok;
}
Beispiel #5
0
ret_t
cherokee_validator_file_configure (cherokee_config_node_t     *conf,
				   cherokee_server_t          *srv,
				   cherokee_module_props_t  **_props)
{
	ret_t                            ret;
	cherokee_config_node_t          *subconf;
	cherokee_validator_file_props_t *props    = PROP_VFILE(*_props);

	UNUSED (srv);

	/* Password file
	 */
	ret = cherokee_config_node_get (conf, "passwdfile", &subconf);
	if (ret == ret_ok) {
		cherokee_buffer_add_buffer (&props->password_file, &subconf->val);
	}

	/* Path type
	 */
	ret = cherokee_config_node_get (conf, "passwdfile_path", &subconf);
	if (ret == ret_ok) {
		if (equal_buf_str (&subconf->val, "full")) {
			props->password_path_type = val_path_full;
		} else if (equal_buf_str (&subconf->val, "local_dir")) {
			props->password_path_type = val_path_local_dir;
		} else {
			LOG_ERROR (CHEROKEE_ERROR_VALIDATOR_FILE, subconf->val.buf);
			return ret_error;
		}
	}

	/* Final checks
	 */
	if (cherokee_buffer_is_empty (&props->password_file)) {
		LOG_CRITICAL_S (CHEROKEE_ERROR_VALIDATOR_FILE_NO_FILE);
		return ret_error;
	}

	return ret_ok;
}
Beispiel #6
0
ret_t
cherokee_x_real_ip_configure (cherokee_x_real_ip_t   *real_ip,
			      cherokee_config_node_t *config)
{
	ret_t                   ret;
	cherokee_config_node_t *subconf;

	cherokee_config_node_read_bool (config, "x_real_ip_enabled",    &real_ip->enabled);
	cherokee_config_node_read_bool (config, "x_real_ip_access_all", &real_ip->access_all);

	ret = cherokee_config_node_get (config, "x_real_ip_access", &subconf);
	if (ret == ret_ok) {
		ret = cherokee_config_node_read_list (subconf, NULL, add_access, real_ip);
		if (ret != ret_ok) {
			LOG_ERROR_S (CHEROKEE_ERROR_LOGGER_X_REAL_IP_PARSE);
			return ret_error;
		}
	}

	return ret_ok;
}
Beispiel #7
0
ret_t
cherokee_logger_ncsa_init_base (cherokee_logger_ncsa_t    *logger,
				cherokee_virtual_server_t *vsrv,
				cherokee_config_node_t    *config)
{
	ret_t                   ret;
	cherokee_config_node_t *subconf;
	static int              callback_init = 0;

	/* Init the local buffers
	 */
	cherokee_buffer_init (&logger->now_dtm);
	cherokee_buffer_init (&logger->referer);
	cherokee_buffer_init (&logger->useragent);
	cherokee_buffer_ensure_size (&logger->now_dtm,   64);
	cherokee_buffer_ensure_size (&logger->referer, 1024);
	cherokee_buffer_ensure_size (&logger->useragent, 512);

	/* Init the logger writer
	 */
	ret = cherokee_config_node_get (config, "access", &subconf);
	if (ret != ret_ok) {
		LOG_CRITICAL (CHEROKEE_ERROR_LOGGER_NO_KEY, "access");
		return ret_error;
	}

	ret = cherokee_server_get_log_writer (VSERVER_SRV(vsrv), subconf, &logger->writer_access);
	if (ret != ret_ok) {
		return ret_error;
	}

	/* Callback init
	 */
	if (callback_init == 0) {
		cherokee_buffer_init (&now);
		cherokee_bogotime_add_callback (bogotime_callback, logger, 1);
	}

	return ret_ok;
}