Handle relative paths in configuration.

This patch changes all configuration options that receive paths to files
to convert them to an absolute path. This ensures that relative paths
work correctly after the server changes the current working directory
during session initialization.

Thanks to Jeroen De Ridder for reporting this bug and suggesting a fix!

git-svn-id: https://modmellon.googlecode.com/svn/trunk@180 a716ebb1-153a-0410-b759-cfb97c6a1b53
This commit is contained in:
olavmrk 2013-03-06 12:53:51 +00:00
parent fc3c4a556e
commit 1ecef88f75
1 changed files with 23 additions and 13 deletions

View File

@ -173,24 +173,34 @@ static const char *am_set_filestring_slot(cmd_parms *cmd,
const char *arg)
{
const char *data;
const char *path;
path = ap_server_root_relative(cmd->pool, arg);
if (!path) {
return apr_pstrcat(cmd->pool, cmd->cmd->name,
": Invalid file path ", arg, NULL);
}
#ifdef HAVE_lasso_server_new_from_buffers
if ((data = am_getfile(cmd->pool, cmd->server, arg)) == NULL)
return apr_psprintf(cmd->pool, "%s - Cannot read file %s",
cmd->cmd->name, arg);
data = am_getfile(cmd->pool, cmd->server, path);
if (!data) {
return apr_pstrcat(cmd->pool, cmd->cmd->name,
": Cannot read file ", path, NULL);
}
#else
apr_finfo_t finfo;
apr_status_t rv;
char error[64];
rv = apr_stat(&finfo, arg, APR_FINFO_SIZE, cmd->pool);
rv = apr_stat(&finfo, path, APR_FINFO_SIZE, cmd->pool);
if(rv != 0) {
apr_strerror(rv, error, sizeof(error));
return apr_psprintf(cmd->pool,
"%s - Cannot read file \"%s\" [%d] \"%s\"",
cmd->cmd->name, arg, rv, error);
cmd->cmd->name, path, rv, error);
}
data = arg;
data = path;
#endif
return ap_set_string_slot(cmd, struct_ptr, data);
@ -339,7 +349,7 @@ static const char *am_set_idp_ignore_slot(cmd_parms *cmd,
}
/* This function handles configuration directives which set a string
/* This function handles configuration directives which set a file path
* slot in the module configuration.
*
* Parameters:
@ -354,11 +364,11 @@ static const char *am_set_idp_ignore_slot(cmd_parms *cmd,
* Returns:
* NULL on success or an error string on failure.
*/
static const char *am_set_module_config_string_slot(cmd_parms *cmd,
static const char *am_set_module_config_file_slot(cmd_parms *cmd,
void *struct_ptr,
const char *arg)
{
return ap_set_string_slot(cmd, am_get_mod_cfg(cmd->server), arg);
return ap_set_file_slot(cmd, am_get_mod_cfg(cmd->server), arg);
}
/* This function handles configuration directives which set an int
@ -823,7 +833,7 @@ const command_rec auth_mellon_commands[] = {
),
AP_INIT_TAKE1(
"MellonLockFile",
am_set_module_config_string_slot,
am_set_module_config_file_slot,
(void *)APR_OFFSETOF(am_mod_cfg_rec, lock_file),
RSRC_CONF,
"The lock file for session synchronization."
@ -831,7 +841,7 @@ const command_rec auth_mellon_commands[] = {
),
AP_INIT_TAKE1(
"MellonPostDirectory",
am_set_module_config_string_slot,
am_set_module_config_file_slot,
(void *)APR_OFFSETOF(am_mod_cfg_rec, post_dir),
RSRC_CONF,
"The directory for saving POST requests."
@ -1035,14 +1045,14 @@ const command_rec auth_mellon_commands[] = {
),
AP_INIT_TAKE1(
"MellonIdPPublicKeyFile",
ap_set_string_slot,
ap_set_file_slot,
(void *)APR_OFFSETOF(am_dir_cfg_rec, idp_public_key_file),
OR_AUTHCFG,
"Full path to pem file with the public key for the IdP."
),
AP_INIT_TAKE1(
"MellonIdPCAFile",
ap_set_string_slot,
ap_set_file_slot,
(void *)APR_OFFSETOF(am_dir_cfg_rec, idp_ca_file),
OR_AUTHCFG,
"Full path to pem file with CA chain for the IdP."