diff options
| author | Noriko Hosoi <nhosoi@redhat.com> | 2006-12-04 18:36:57 +0000 |
|---|---|---|
| committer | Noriko Hosoi <nhosoi@redhat.com> | 2006-12-04 18:36:57 +0000 |
| commit | 0d0cc2374ec0c63864b752eae72a5bcf294aa54e (patch) | |
| tree | 4499005cea1e8ecee9273e31239553e69dd9604a | |
| parent | 0e6cd94b2023ef452a734cc4efba7a83d9ecc6c5 (diff) | |
Resolves: 158342
Summary: db backend path handling could be impoved to deal with "//", "..", etc.
Changes:
util.c:
modified rel2abspath so that if the given path contains "//", calls the
normalize function, and the normalize function eliminates the repeated
separators.
ldbm_config.c, ldbm_instance_config.c:
before setting the nsslapd-directory paths, pass them to rel2abspath to clean
up the paths.
| -rw-r--r-- | ldap/servers/slapd/back-ldbm/ldbm_config.c | 8 | ||||
| -rw-r--r-- | ldap/servers/slapd/back-ldbm/ldbm_instance_config.c | 10 | ||||
| -rw-r--r-- | ldap/servers/slapd/util.c | 15 |
3 files changed, 21 insertions, 12 deletions
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c index d9c298b4..32403a68 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c @@ -227,7 +227,8 @@ static int ldbm_config_directory_set(void *arg, void *value, char *errorbuf, int if (CONFIG_PHASE_RUNNING == phase) { slapi_ch_free((void **) &(li->li_new_directory)); - li->li_new_directory = slapi_ch_strdup(val); + li->li_new_directory = rel2abspath(val); /* normalize the path; + strdup'ed in rel2abspath */ LDAPDebug(LDAP_DEBUG_ANY, "New db directory location will not take affect until the server is restarted\n", 0, 0, 0); } else { if (!strcmp(val, "get default")) { @@ -294,8 +295,9 @@ done: } slapi_ch_free((void **) &(li->li_new_directory)); slapi_ch_free((void **) &(li->li_directory)); - li->li_new_directory = slapi_ch_strdup(val); - li->li_directory = slapi_ch_strdup(val); + li->li_new_directory = rel2abspath(val); /* normalize the path; + strdup'ed in rel2abspath */ + li->li_directory = rel2abspath(val); /* ditto */ } return retval; diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c index 0616bc0f..7dfc826f 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c @@ -189,15 +189,19 @@ ldbm_instance_config_instance_dir_set(void *arg, void *value, char *errorbuf, in { char sep = get_sep(dir); char *p = strrchr(dir, sep); - if (NULL == p) /* never happens, tho */ + if (NULL == p) /* should not happens, tho */ { inst->inst_parent_dir_name = NULL; - inst->inst_dir_name = slapi_ch_strdup(dir); + inst->inst_dir_name = rel2abspath(dir); /* normalize dir; + strdup'ed in + rel2abspath */ } else { *p = '\0'; - inst->inst_parent_dir_name = slapi_ch_strdup(dir); + inst->inst_parent_dir_name = rel2abspath(dir); /* normalize dir; + strdup'ed in + rel2abspath */ inst->inst_dir_name = slapi_ch_strdup(p+1); *p = sep; } diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c index 0ef040d8..3145e736 100644 --- a/ldap/servers/slapd/util.c +++ b/ldap/servers/slapd/util.c @@ -61,9 +61,11 @@ #if defined( _WIN32 ) #define _PSEP "\\" +#define _PSEP2 "\\\\" #define _CSEP '\\' #else #define _PSEP "/" +#define _PSEP2 "//" #define _CSEP '/' #endif @@ -422,9 +424,9 @@ normalize_path(char *path) if (NULL == bnamep) { bnamep = dnamep; } else { - *bnamep = '\0'; - bnamep++; - } + *bnamep = '\0'; + bnamep++; + } if (0 != strcmp(bnamep, ".")) { *dp++ = slapi_ch_strdup(bnamep); /* remove "/./" in the path */ } @@ -447,9 +449,10 @@ normalize_path(char *path) if (rdp > rdirs) rdp--; } - if (*dp) + if (*dp && strlen(*dp) > 0) *rdp++ = slapi_ch_strdup(*dp); } + *rdp = NULL; clean_path(dirs); slapi_ch_free_string(&dname); @@ -518,14 +521,14 @@ rel2abspath_ext( char *relpath, char *cwd ) if ( abspath[ 0 ] != '\0' && abspath[ strlen( abspath ) - 1 ] != _CSEP ) { - PL_strcatn( abspath, sizeof(abspath), "/" ); + PL_strcatn( abspath, sizeof(abspath), _PSEP ); } PL_strcatn( abspath, sizeof(abspath), relpath ); } } retpath = slapi_ch_strdup(abspath); /* if there's no '.', no need to call normalize_path */ - if (NULL != strchr(abspath, '.')) + if (NULL != strchr(abspath, '.') || NULL != strstr(abspath, _PSEP2)) { char **norm_path = normalize_path(abspath); char **np, *rp; |
