Ejemplo n.º 1
0
/* FIXME: why there was #if !defined(HAVE___OPENDIR2) around fts_open() ???? */
FTS * fts_open_gate(
	int *result_errno_ptr,
	FTS * (*real_fts_open_ptr)(char * const *path_argv,
		int options, int (*compar)(const FTSENT **,const FTSENT **)),
	const char *realfnname,
	char * const *path_argv,
	int options,
	int (*compar)(const FTSENT **,const FTSENT **))
{
	char *path;
	char * const *p;
	char **new_path_argv;
	char **np;
	int n;
	FTS *result;

	for (n=0, p=path_argv; *p; n++, p++);
	if ((new_path_argv = calloc(n+1, (sizeof(char *)))) == NULL) {
		return NULL;
	}

	for (n=0, p=path_argv, np=new_path_argv; *p; n++, p++, np++) {
		mapping_results_t res;

		clear_mapping_results_struct(&res);
		path = *p;
		sbox_map_path(realfnname, path,
			0/*flags*/, &res,
			SB2_INTERFACE_CLASS_FTSOPEN);
		if (res.mres_result_path) {
			/* Mapped OK */
			*np = strdup(res.mres_result_path);
		} else {
			*np = strdup("");
		}
		free_mapping_results(&res);
	}

	/* FIXME: this system causes memory leaks */

	errno = *result_errno_ptr; /* restore to orig.value */
	result = (*real_fts_open_ptr)(new_path_argv, options, compar);
	*result_errno_ptr = errno;
	return(result);
}
Ejemplo n.º 2
0
char *bindtextdomain_gate(int *result_errno_ptr,
	char *(*realfn)(const char *, const char *),
	const char *realfn_name, const char *domainname, const char *dirname)
{
	mapping_results_t res;
	const char *mapped_dirname = dirname;
	char *result = NULL;

	clear_mapping_results_struct(&res);

	if (dirname != NULL) { 
		sbox_map_path(realfn_name, dirname, 0, &res);
		assert(res.mres_result_path != NULL);

		mapped_dirname = res.mres_result_path;

		SB_LOG(SB_LOGLEVEL_DEBUG, "binding domain %s to %s",
		    domainname, mapped_dirname);
	}

	errno = *result_errno_ptr; /* restore to orig.value */
	result = (*realfn)(domainname, mapped_dirname);
	*result_errno_ptr = errno;

	free_mapping_results(&res);
	if (result && (*result != '\0')) {
		char *sbox_path = NULL;
		sbox_path = scratchbox_reverse_path(realfn_name, result);
		if (sbox_path) {
			/* FIXME: this will leak memory. nobody will free
			 * the buffer at *sbox_path; in fact the manual
			 * page denies that ("..must not be modified
			 * or freed")
			*/
			result = sbox_path;
		}
	}
	return (result);
}
Ejemplo n.º 3
0
char *bindtextdomain_gate(char *(*realfn)(const char *, const char *),
    const char *realfn_name, const char *domainname, const char *dirname)
{
	mapping_results_t res;
	const char *mapped_dirname = dirname;
	char *result = NULL;

	clear_mapping_results_struct(&res);

	if (dirname != NULL) { 
		sbox_map_path(realfn_name, dirname, 0, &res);
		assert(res.mres_result_path != NULL);

		mapped_dirname = res.mres_result_path;

		SB_LOG(SB_LOGLEVEL_DEBUG, "binding domain %s to %s",
		    domainname, mapped_dirname);
	}

	result = (*realfn)(domainname, mapped_dirname);
	free_mapping_results(&res);
	return (result);
}