summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-05-31 19:28:29 +0200
committerStephen Gallagher <sgallagh@redhat.com>2012-06-14 15:52:29 -0400
commit7b9f1e13c750fed76886513071a2b63949181ea4 (patch)
tree780b613d92c9bbf3105b367f6f9fa53d9f75397e /src
parentf674270b1068e4ad51c80dcd528ae996a4fe99ef (diff)
downloadsssd-7b9f1e13c750fed76886513071a2b63949181ea4.tar.gz
sssd-7b9f1e13c750fed76886513071a2b63949181ea4.tar.xz
sssd-7b9f1e13c750fed76886513071a2b63949181ea4.zip
Handle trailing slash in the ccname template
With the DIR cache support, it's perfectly legal to specify a ccname directory that ends with a slash. The create_dir function did not handle that situation correctly.
Diffstat (limited to 'src')
-rw-r--r--src/providers/krb5/krb5_utils.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/providers/krb5/krb5_utils.c b/src/providers/krb5/krb5_utils.c
index c97d58e7c..9d199e1f5 100644
--- a/src/providers/krb5/krb5_utils.c
+++ b/src/providers/krb5/krb5_utils.c
@@ -285,14 +285,20 @@ static errno_t find_ccdir_parent_data(TALLOC_CTX *mem_ctx, const char *dirname,
DEBUG(1, ("talloc_strdup failed.\n"));
return ENOMEM;
}
- end = strrchr(parent, '/');
- if (end == NULL || end == parent) {
- DEBUG(1, ("Cannot find parent directory of [%s], / is not allowed.\n",
- dirname));
- ret = EINVAL;
- goto done;
- }
- *end = '\0';
+
+ /* We'll remove all trailing slashes from the back so that
+ * we only pass /some/path to find_ccdir_parent_data, not
+ * /some/path */
+ do {
+ end = strrchr(parent, '/');
+ if (end == NULL || end == parent) {
+ DEBUG(1, ("Cannot find parent directory of [%s], / is not allowed.\n",
+ dirname));
+ ret = EINVAL;
+ goto done;
+ }
+ *end = '\0';
+ } while (*(end+1) == '\0');
ret = find_ccdir_parent_data(mem_ctx, parent, parent_stat, missing_parents);