Beispiel #1
0
abts_suite *testdso(abts_suite *suite)
{
    suite = ADD_SUITE(suite)

#if APR_HAS_DSO
    apr_filepath_merge(&modname, NULL, MOD_NAME, 0, p);
    
    abts_run_test(suite, test_load_module, NULL);
    abts_run_test(suite, test_dso_sym, NULL);
    abts_run_test(suite, test_dso_sym_return_value, NULL);
    abts_run_test(suite, test_unload_module, NULL);

#ifdef LIB_NAME
    apr_filepath_merge(&libname, NULL, LIB_NAME, 0, p);
    
    abts_run_test(suite, test_load_library, NULL);
    abts_run_test(suite, test_dso_sym_library, NULL);
    abts_run_test(suite, test_dso_sym_return_value_library, NULL);
    abts_run_test(suite, test_unload_library, NULL);
#endif

    abts_run_test(suite, test_load_notthere, NULL);
#endif /* APR_HAS_DSO */

    return suite;
}
Beispiel #2
0
APT_DECLARE(apt_dir_layout_t*) apt_default_dir_layout_create(const char *root_dir_path, apr_pool_t *pool)
{
	apt_dir_layout_t *dir_layout = apt_dir_layout_create_ext(APT_LAYOUT_DIR_COUNT,pool);

	if(!root_dir_path) {
		/* If root dir path is not specified, get the default one */
		root_dir_path = apt_default_root_dir_path_get(pool);
	}

	if(root_dir_path) {
		char *path;
		
		apr_filepath_merge(&path,root_dir_path,"conf",APR_FILEPATH_NATIVE,pool);
		apt_dir_layout_path_set_internal(dir_layout,APT_LAYOUT_CONF_DIR,path);

		apr_filepath_merge(&path,root_dir_path,"plugin",APR_FILEPATH_NATIVE,pool);
		apt_dir_layout_path_set_internal(dir_layout,APT_LAYOUT_PLUGIN_DIR,path);

		apr_filepath_merge(&path,root_dir_path,"log",APR_FILEPATH_NATIVE,pool);
		apt_dir_layout_path_set_internal(dir_layout,APT_LAYOUT_LOG_DIR,path);

		apr_filepath_merge(&path,root_dir_path,"data",APR_FILEPATH_NATIVE,pool);
		apt_dir_layout_path_set_internal(dir_layout,APT_LAYOUT_DATA_DIR,path);

		apr_filepath_merge(&path,root_dir_path,"var",APR_FILEPATH_NATIVE,pool);
		apt_dir_layout_path_set_internal(dir_layout,APT_LAYOUT_VAR_DIR,path);
	}
	return dir_layout;
}
Beispiel #3
0
APT_DECLARE(apt_dir_layout_t*) apt_default_dir_layout_create(const char *root_dir_path, apr_pool_t *pool)
{
	apt_dir_layout_t *dir_layout = apt_dir_layout_alloc(pool);
	if(root_dir_path) {
		apr_filepath_merge(&dir_layout->conf_dir_path,root_dir_path,"conf",0,pool);
		apr_filepath_merge(&dir_layout->plugin_dir_path,root_dir_path,"plugin",0,pool);
		apr_filepath_merge(&dir_layout->log_dir_path,root_dir_path,"log",0,pool);
		apr_filepath_merge(&dir_layout->data_dir_path,root_dir_path,"data",0,pool);
	}
	return dir_layout;
}
Beispiel #4
0
APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, 
                                       const char *path, apr_pool_t *pool)
{

    void *os_handle = NULL;
    char *fullpath = NULL;
    apr_status_t rv;

    if ((rv = apr_filepath_merge(&fullpath, NULL, path, 
                                 APR_FILEPATH_NATIVE, pool)) != APR_SUCCESS) {
        return rv;
    }

    os_handle = dlopen(fullpath, RTLD_NOW | RTLD_LOCAL);

    *res_handle = apr_pcalloc(pool, sizeof(**res_handle));

    if(os_handle == NULL) {
        (*res_handle)->errormsg = dlerror();
        return APR_EDSOOPEN;
    }

    (*res_handle)->handle = (void*)os_handle;
    (*res_handle)->pool = pool;
    (*res_handle)->errormsg = NULL;
    (*res_handle)->symbols = NULL;
    (*res_handle)->path = apr_pstrdup(pool, fullpath);

    apr_pool_cleanup_register(pool, *res_handle, dso_cleanup, apr_pool_cleanup_null);

    return APR_SUCCESS;
}
static void merge_lowercasedrive(abts_case *tc, void *data)
{
  char current_dir[1024];
  char current_dir_on_C[1024];
  char *dir_on_c;
  char *testdir;
  apr_status_t rv;

  /* Change the current directory on C: from something like "C:\dir"
     to something like "c:\dir" to replicate the failing case. */
  ABTS_PTR_NOTNULL(tc, _getcwd(current_dir, sizeof(current_dir)));

   /* 3 stands for drive C: */
  ABTS_PTR_NOTNULL(tc, _getdcwd(3, current_dir_on_C,
	                            sizeof(current_dir_on_C)));

  /* Use the same path, but now with a lower case driveletter */
  dir_on_c = apr_pstrdup(p, current_dir_on_C);
  dir_on_c[0] = (char)tolower(dir_on_c[0]);

  chdir(dir_on_c);

  /* Now merge a drive relative path with an upper case drive letter. */
  rv = apr_filepath_merge(&testdir, NULL, "C:hi",
                          APR_FILEPATH_NOTRELATIVE, p);

  /* Change back to original directory for next tests */
  chdir("C:\\"); /* Switch to upper case */
  chdir(current_dir_on_C); /* Switch cwd on C: */
  chdir(current_dir); /* Switch back to original cwd */

  ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}
Beispiel #6
0
static const char* apt_log_file_path_make(apt_log_file_data_t *file_data)
{
	char *log_file_path = NULL;
	const char *log_file_name = apr_psprintf(file_data->pool,"%s-%"APR_SIZE_T_FMT".log",file_data->log_file_name,file_data->cur_file_index);
	apr_filepath_merge(&log_file_path,file_data->log_dir_path,log_file_name,0,file_data->pool);
	return log_file_path;
}
Beispiel #7
0
static char* apt_dir_layout_subdir_parse(const char *root_dir_path, const apr_xml_elem *elem, apr_pool_t *pool)
{
	char *path;
	char *full_path = NULL;
	apr_status_t status;

	if(!elem || !elem->first_cdata.first || !elem->first_cdata.first->text) {
		return NULL;
	}

	path = apr_pstrdup(pool,elem->first_cdata.first->text);
	apr_collapse_spaces(path,path);

	/* Check if path is absolute or relative */
	status = apt_dir_is_path_absolute(path,pool);
	if(status == APR_SUCCESS) {
		/* Absolute path specified */
		return path;
	}
	else if (status == APR_ERELATIVE) {
		/* Relative path specified -> merge it with the root path */
		if(apr_filepath_merge(&full_path,root_dir_path,path,APR_FILEPATH_NATIVE,pool) == APR_SUCCESS) {
			return full_path;
		}
	}

	/* WARNING: invalid path specified */
	return NULL;
}
Beispiel #8
0
svn_error_t *
svn_opt__arg_canonicalize_path(const char **path_out, const char *path_in,
                               apr_pool_t *pool)
{
  const char *apr_target;
  char *truenamed_target; /* APR-encoded */
  apr_status_t apr_err;

  /* canonicalize case, and change all separators to '/'. */
  SVN_ERR(svn_path_cstring_from_utf8(&apr_target, path_in, pool));
  apr_err = apr_filepath_merge(&truenamed_target, "", apr_target,
                               APR_FILEPATH_TRUENAME, pool);

  if (!apr_err)
    /* We have a canonicalized APR-encoded target now. */
    apr_target = truenamed_target;
  else if (APR_STATUS_IS_ENOENT(apr_err))
    /* It's okay for the file to not exist, that just means we
       have to accept the case given to the client. We'll use
       the original APR-encoded target. */
    ;
  else
    return svn_error_createf(apr_err, NULL,
                             _("Error resolving case of '%s'"),
                             svn_dirent_local_style(path_in, pool));

  /* convert back to UTF-8. */
  SVN_ERR(svn_path_cstring_to_utf8(path_out, apr_target, pool));
  *path_out = svn_dirent_canonicalize(*path_out, pool);

  return SVN_NO_ERROR;
}
Beispiel #9
0
static apt_bool_t test_dir_process(apt_test_suite_t *suite)
{
	apr_status_t rv;
	apr_dir_t *dir;

	const char *dir_name = "msg";
	if(apr_dir_open(&dir,dir_name,suite->pool) != APR_SUCCESS) {
		apt_log(APT_PRIO_WARNING,"Cannot Open Directory [%s]",dir_name);
		return FALSE;
	}

	do {
		apr_finfo_t finfo;
		rv = apr_dir_read(&finfo,APR_FINFO_DIRENT,dir);
		if(rv == APR_SUCCESS) {
			if(finfo.filetype == APR_REG && finfo.name) {
				char *file_path;
				apr_filepath_merge(&file_path,dir_name,finfo.name,0,suite->pool);
				test_file_process(suite,file_path);
			}
		}
	} 
	while(rv == APR_SUCCESS);

	apr_dir_close(dir);
	return TRUE;
}
Beispiel #10
0
static apt_bool_t test_dir_process(apt_test_suite_t *suite, mrcp_resource_factory_t *factory, mrcp_version_e version)
{
	apr_status_t rv;
	apr_dir_t *dir;

	const char *dir_name = "v2";
	if(version == MRCP_VERSION_1) {
		dir_name = "v1";
	}
	if(apr_dir_open(&dir,dir_name,suite->pool) != APR_SUCCESS) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Cannot Open Directory [%s]",dir_name);
		return FALSE;
	}

	do {
		apr_finfo_t finfo;
		rv = apr_dir_read(&finfo,APR_FINFO_DIRENT,dir);
		if(rv == APR_SUCCESS) {
			if(finfo.filetype == APR_REG && finfo.name) {
				char *file_path;
				apr_filepath_merge(&file_path,dir_name,finfo.name,0,suite->pool);
				test_file_process(suite,factory,version,file_path);
				printf("\nPress ENTER to continue\n");
				getchar();
			}
		}
	} 
	while(rv == APR_SUCCESS);

	apr_dir_close(dir);
	return TRUE;
}
Beispiel #11
0
static void merge_dotdot_dotdot_dotdot(abts_case *tc, void *data)
{
    apr_status_t rv;
    char *dstpath = NULL;

    rv = apr_filepath_merge(&dstpath, "", 
                            "../../..", APR_FILEPATH_TRUENAME, p);
    ABTS_PTR_NOTNULL(tc, dstpath);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_STR_EQUAL(tc, "../../..", dstpath);

    rv = apr_filepath_merge(&dstpath, "", 
                            "../../../", APR_FILEPATH_TRUENAME, p);
    ABTS_PTR_NOTNULL(tc, dstpath);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_STR_EQUAL(tc, "../../../", dstpath);
}
Beispiel #12
0
static void root_from_cwd_and_back(abts_case *tc, void *data)
{
    apr_status_t rv;
    const char *root = NULL;
    const char *path = "//";
    char *origpath;
    char *testpath;
    int hadfailed;

    ABTS_INT_EQUAL(tc, APR_SUCCESS, apr_filepath_get(&origpath, 0, p));
    path = origpath;
    rv = apr_filepath_root(&root, &path, APR_FILEPATH_TRUENAME, p);

#if defined(WIN32) || defined(OS2)
    hadfailed = tc->failed;
    /* It appears some mingw/cygwin and more modern builds can return
     * a lowercase drive designation, but we canonicalize to uppercase
     */
    ABTS_INT_EQUAL(tc, toupper(origpath[0]), root[0]);
    ABTS_INT_EQUAL(tc, ':', root[1]);
    ABTS_INT_EQUAL(tc, '/', root[2]);
    ABTS_INT_EQUAL(tc, 0, root[3]);
    ABTS_STR_EQUAL(tc, origpath + 3, path);
#elif defined(NETWARE)
    ABTS_INT_EQUAL(tc, origpath[0], root[0]);
    {
    char *pt = strchr(root, ':');
    ABTS_PTR_NOTNULL(tc, pt);
    ABTS_INT_EQUAL(tc, ':', pt[0]);
    ABTS_INT_EQUAL(tc, '/', pt[1]);
    ABTS_INT_EQUAL(tc, 0, pt[2]);
    pt = strchr(origpath, ':');
    ABTS_PTR_NOTNULL(tc, pt);
    ABTS_STR_EQUAL(tc, (pt+2), path);
    }
#else
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_STR_EQUAL(tc, "/", root);
    ABTS_STR_EQUAL(tc, origpath + 1, path);
#endif

    rv = apr_filepath_merge(&testpath, root, path, 
                            APR_FILEPATH_TRUENAME
                          | APR_FILEPATH_NOTABOVEROOT
                          | APR_FILEPATH_NOTRELATIVE, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    hadfailed = tc->failed;
    /* The API doesn't promise equality!!! 
     * apr_filepath_get never promised a canonical filepath.
     * We'll emit noise under verbose so the user is aware,
     * but translate this back to success.
     */
    ABTS_STR_EQUAL(tc, origpath, testpath);
#if defined(WIN32) || defined(OS2) || defined(NETWARE)
    if (!hadfailed) tc->failed = 0;
#endif
}
Beispiel #13
0
AP_DECLARE(void) ap_add_cgi_vars(request_rec *r)
{
    apr_table_t *e = r->subprocess_env;

    apr_table_setn(e, "GATEWAY_INTERFACE", "CGI/1.1");
    apr_table_setn(e, "SERVER_PROTOCOL", r->protocol);
    apr_table_setn(e, "REQUEST_METHOD", r->method);
    apr_table_setn(e, "QUERY_STRING", r->args ? r->args : "");
    apr_table_setn(e, "REQUEST_URI", original_uri(r));

    /* Note that the code below special-cases scripts run from includes,
     * because it "knows" that the sub_request has been hacked to have the
     * args and path_info of the original request, and not any that may have
     * come with the script URI in the include command.  Ugh.
     */

    if (!strcmp(r->protocol, "INCLUDED")) {
        apr_table_setn(e, "SCRIPT_NAME", r->uri);
        if (r->path_info && *r->path_info) {
            apr_table_setn(e, "PATH_INFO", r->path_info);
        }
    }
    else if (!r->path_info || !*r->path_info) {
        apr_table_setn(e, "SCRIPT_NAME", r->uri);
    }
    else {
        int path_info_start = ap_find_path_info(r->uri, r->path_info);

        apr_table_setn(e, "SCRIPT_NAME",
                      apr_pstrndup(r->pool, r->uri, path_info_start));

        apr_table_setn(e, "PATH_INFO", r->path_info);
    }

    if (r->path_info && r->path_info[0]) {
        /*
         * To get PATH_TRANSLATED, treat PATH_INFO as a URI path.
         * Need to re-escape it for this, since the entire URI was
         * un-escaped before we determined where the PATH_INFO began.
         */
        request_rec *pa_req;

        pa_req = ap_sub_req_lookup_uri(ap_escape_uri(r->pool, r->path_info), r,
                                       NULL);

        if (pa_req->filename) {
            char *pt = apr_pstrcat(r->pool, pa_req->filename, pa_req->path_info,
                                  NULL);
#ifdef WIN32
            /* We need to make this a real Windows path name */
            apr_filepath_merge(&pt, "", pt, APR_FILEPATH_NATIVE, r->pool);
#endif
            apr_table_setn(e, "PATH_TRANSLATED", pt);
        }
        ap_destroy_sub_req(pa_req);
    }
}
Beispiel #14
0
static void merge_noflag(abts_case *tc, void *data)
{
    apr_status_t rv;
    char *dstpath = NULL;

    rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"foo/bar", 0, p);
    ABTS_PTR_NOTNULL(tc, dstpath);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_STR_EQUAL(tc, ABS_ROOT"foo/bar", dstpath);
}
Beispiel #15
0
APT_DECLARE(char*) apt_confdir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool)
{
	if(dir_layout && dir_layout->conf_dir_path && file_name) {
		char *file_path = NULL;
		if(apr_filepath_merge(&file_path,dir_layout->conf_dir_path,file_name,0,pool) == APR_SUCCESS) {
			return file_path;
		}
	}
	return NULL;
}
Beispiel #16
0
static void merge_notrel(abts_case *tc, void *data)
{
    apr_status_t rv;
    char *dstpath = NULL;

    rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz",
                            APR_FILEPATH_NOTRELATIVE, p);
    ABTS_PTR_NOTNULL(tc, dstpath);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_STR_EQUAL(tc, ABS_ROOT"foo/baz", dstpath);
}
Beispiel #17
0
static void merge_belowroot(abts_case *tc, void *data)
{
    apr_status_t rv;
    char *dstpath = NULL;

    rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"foo/bar", 
                            APR_FILEPATH_NOTABOVEROOT, p);
    ABTS_PTR_NOTNULL(tc, dstpath);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_STR_EQUAL(tc, ABS_ROOT"foo/bar", dstpath);
}
Beispiel #18
0
APT_DECLARE(char*) apt_dir_layout_path_compose(const apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id, const char *file_name, apr_pool_t *pool)
{
	char *file_path;
	if(!dir_layout || dir_entry_id >= dir_layout->count)
		return NULL;

	if(apr_filepath_merge(&file_path,dir_layout->paths[dir_entry_id],file_name,APR_FILEPATH_NATIVE,pool) == APR_SUCCESS) {
		return file_path;
	}
	return NULL;
}
Beispiel #19
0
static void merge_aboveroot(abts_case *tc, void *data)
{
    apr_status_t rv;
    char *dstpath = NULL;
    char errmsg[256];

    rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo", ABS_ROOT"bar", APR_FILEPATH_NOTABOVEROOT,
                            p);
    apr_strerror(rv, errmsg, sizeof(errmsg));
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EABOVEROOT(rv));
    ABTS_PTR_EQUAL(tc, NULL, dstpath);
    ABTS_STR_EQUAL(tc, "The given path was above the root path", errmsg);
}
Beispiel #20
0
static void merge_notabsfail(abts_case *tc, void *data)
{
    apr_status_t rv;
    char *dstpath = NULL;
    char errmsg[256];

    rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz", 
                            APR_FILEPATH_NOTABSOLUTE, p);
    apr_strerror(rv, errmsg, sizeof(errmsg));

    ABTS_PTR_EQUAL(tc, NULL, dstpath);
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EABSOLUTE(rv));
    ABTS_STR_EQUAL(tc, "The given path is absolute", errmsg);
}
Beispiel #21
0
static void merge_notrelfail(abts_case *tc, void *data)
{
    apr_status_t rv;
    char *dstpath = NULL;
    char errmsg[256];

    rv = apr_filepath_merge(&dstpath, "foo/bar", "../baz", 
                            APR_FILEPATH_NOTRELATIVE, p);
    apr_strerror(rv, errmsg, sizeof(errmsg));

    ABTS_PTR_EQUAL(tc, NULL, dstpath);
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_ERELATIVE(rv));
    ABTS_STR_EQUAL(tc, "The given path is relative", errmsg);
}
Beispiel #22
0
static const char* apt_default_root_dir_path_get(apr_pool_t *pool)
{
	char *root_dir_path;
	char *cur_dir_path;
	/* Get the current directory */
	if(apr_filepath_get(&cur_dir_path,APR_FILEPATH_NATIVE,pool) != APR_SUCCESS)
		return NULL;

	/* Root directory is supposed to be one level up by default */
	if(apr_filepath_merge(&root_dir_path,cur_dir_path,"../",APR_FILEPATH_NATIVE,pool) != APR_SUCCESS)
		return FALSE;

	return root_dir_path;
}
const char *UploadItemIO::get_path(apr_pool_t *pool, const char *dir_path,
                                   apr_size_t item_id, const char *file_name)
{
    char *file_path;

    if (apr_filepath_merge(&file_path,
                           get_sub_dir_path(pool, dir_path, item_id),
                           file_name,
                           APR_FILEPATH_NOTABOVEROOT, pool) != APR_SUCCESS) {
        THROW(MESSAGE_UPLOAD_ITEM_FILE_PATH_CREATION_FAILED);
    }

    return file_path;
}
Beispiel #24
0
static void merge_dotdot(abts_case *tc, void *data)
{
    apr_status_t rv;
    char *dstpath = NULL;

    rv = apr_filepath_merge(&dstpath, ABS_ROOT"foo/bar", "../baz", 0, p);
    ABTS_PTR_NOTNULL(tc, dstpath);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_STR_EQUAL(tc, ABS_ROOT"foo/baz", dstpath);

    rv = apr_filepath_merge(&dstpath, "", "../test", 0, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_STR_EQUAL(tc, "../test", dstpath);

    /* Very dangerous assumptions here about what the cwd is.  However, let's assume
     * that the testall is invoked from within apr/test/ so the following test should
     * return ../test unless a previously fixed bug remains or the developer changes
     * the case of the test directory:
     */
    rv = apr_filepath_merge(&dstpath, "", "../test", APR_FILEPATH_TRUENAME, p);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    ABTS_STR_EQUAL(tc, "../test", dstpath);
}
Beispiel #25
0
CuSuite *testdso(void)
{
    CuSuite *suite = CuSuiteNew("DSO");

    apr_filepath_merge(&modname, NULL, MOD_NAME, 0, p);

    SUITE_ADD_TEST(suite, test_load_module);
    SUITE_ADD_TEST(suite, test_dso_sym);
    SUITE_ADD_TEST(suite, test_dso_sym_return_value);
    SUITE_ADD_TEST(suite, test_unload_module);

#ifdef LIB_NAME
    apr_filepath_merge(&libname, NULL, LIB_NAME, 0, p);

    SUITE_ADD_TEST(suite, test_load_library);
    SUITE_ADD_TEST(suite, test_dso_sym_library);
    SUITE_ADD_TEST(suite, test_dso_sym_return_value_library);
    SUITE_ADD_TEST(suite, test_unload_library);
#endif

    SUITE_ADD_TEST(suite, test_load_notthere);

    return suite;
}
Beispiel #26
0
const char *fcgi_config_new_auth_server(cmd_parms * cmd,
    void * dircfg, const char *fs_path, const char * compat)
{
    fcgi_dir_config * dir_config = (fcgi_dir_config *) dircfg;
    pool * const tp = cmd->temp_pool;
    char * auth_server;

#ifdef APACHE2
    if (apr_filepath_merge(&auth_server, "", fs_path, 0, cmd->pool))
        return ap_psprintf(tp, "%s %s: invalid filepath", cmd->cmd->name, fs_path);
#else
    auth_server = (char *) ap_os_canonical_filename(cmd->pool, fs_path);
#endif

    auth_server = ap_server_root_relative(cmd->pool, auth_server);

    /* Make sure its already configured or at least a candidate for dynamic */
    if (fcgi_util_fs_get_by_id(auth_server, fcgi_util_get_server_uid(cmd->server),
                               fcgi_util_get_server_gid(cmd->server)) == NULL) 
    {
        const char *err = fcgi_util_fs_is_path_ok(tp, auth_server, NULL);
        if (err)
            return ap_psprintf(tp, "%s: \"%s\" %s", cmd->cmd->name, auth_server, err);
    }

    if (compat && strcasecmp(compat, "-compat"))
        return ap_psprintf(cmd->temp_pool, "%s: unknown option: \"%s\"", cmd->cmd->name, compat);

    switch((long)cmd->info) {
        case FCGI_AUTH_TYPE_AUTHENTICATOR:
            dir_config->authenticator = auth_server;
            dir_config->authenticator_options |= (compat) ? FCGI_COMPAT : 0;
            break;
        case FCGI_AUTH_TYPE_AUTHORIZER:
            dir_config->authorizer = auth_server;
            dir_config->authorizer_options |= (compat) ? FCGI_COMPAT : 0;
            break;
        case FCGI_AUTH_TYPE_ACCESS_CHECKER:
            dir_config->access_checker = auth_server;
            dir_config->access_checker_options |= (compat) ? FCGI_COMPAT : 0;
            break;
    }

    return NULL;
}
Beispiel #27
0
/** Load UniMRCP client from file */
static apt_bool_t unimrcp_client_load(unimrcp_client_loader_t *loader, const char *dir_path, const char *file_name)
{
	apr_pool_t *pool = loader->pool;
	apr_xml_doc *doc;
	char *file_path;

	if(!dir_path || !file_name) {
		return FALSE;
	}

	if(apr_filepath_merge(&file_path,dir_path,file_name,APR_FILEPATH_NATIVE,pool) != APR_SUCCESS) {
		return FALSE;
	}

	/* Parse XML document */
	doc = unimrcp_client_doc_parse(file_path,pool);
	return unimrcp_client_doc_process(loader, dir_path, doc, pool);
}
Beispiel #28
0
static void test_rmkdir_nocwd(abts_case *tc, void *data)
{
    char *cwd, *path;

    APR_ASSERT_SUCCESS(tc, "make temp dir",
                       apr_dir_make("dir3", APR_OS_DEFAULT, p));

    APR_ASSERT_SUCCESS(tc, "obtain cwd", apr_filepath_get(&cwd, 0, p));

    APR_ASSERT_SUCCESS(tc, "determine path to temp dir",
                       apr_filepath_merge(&path, cwd, "dir3", 0, p));

    APR_ASSERT_SUCCESS(tc, "change to temp dir", apr_filepath_set(path, p));

    APR_ASSERT_SUCCESS(tc, "restore cwd", apr_filepath_set(cwd, p));

    APR_ASSERT_SUCCESS(tc, "remove cwd", apr_dir_remove(path, p));
}
Beispiel #29
0
/*
  little helper function to build the file path if available
*/
static apr_status_t ap_xsendfile_get_filepath(request_rec *r, xsendfile_conf_t *conf, const char *file, /* out */ char **path) {

  const char *root = ap_xsendfile_get_orginal_path(r);
  apr_status_t rv;

  apr_array_header_t *patharr;
  const char **paths;
  int i;


#ifdef _DEBUG
  ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "xsendfile: path is %s", root);
#endif

  /* merge the array */
  if (root) {
    patharr = apr_array_make(r->pool, conf->paths->nelts + 1, sizeof(char*));
    *(const char**)(apr_array_push(patharr)) = root;
    apr_array_cat(patharr, conf->paths);
  } else {
    patharr = conf->paths;
  }
  if (patharr->nelts == 0) {
    return APR_EBADPATH;
  }
  paths = (const char**)patharr->elts;

  for (i = 0; i < patharr->nelts; ++i) {
    if ((rv = apr_filepath_merge(
      path,
      paths[i],
      file,
      APR_FILEPATH_TRUENAME | APR_FILEPATH_NOTABOVEROOT,
      r->pool
    )) == OK) {
      break;
    }
  }
  if (rv != OK) {
    *path = NULL;
  }
  return rv;
}
const char *UploadItemIO::get_sub_dir_path(apr_pool_t *pool,
                                          const char *dir_path,
                                          apr_size_t item_id)
{
    static const char HEX_CHAR[]    = "0123456789abcdef";

    char *sub_dir_path;
    char *sub_dir_name;

    APR_PALLOC(sub_dir_name, char *, pool, 3);
    sub_dir_name[0] = HEX_CHAR[(item_id >> 4) & 0xf];
    sub_dir_name[1] = HEX_CHAR[(item_id     ) & 0xf];
    sub_dir_name[2] = '\0';

    if (apr_filepath_merge(&sub_dir_path, dir_path, sub_dir_name,
                           APR_FILEPATH_NOTABOVEROOT, pool) != APR_SUCCESS) {
        THROW(MESSAGE_UPLOAD_ITEM_SUB_DIR_PATH_CREATION_FAILED);
    }

    return sub_dir_path;
}