summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2012-07-11 13:22:09 -0400
committerGreg Hudson <ghudson@mit.edu>2012-07-11 13:23:17 -0400
commitb700a332dd835affa78b60089b9de5c79a8c689e (patch)
tree43bf2f422f00c9cd3c5695e4a611e690a40eeb7b /src/lib/krb5
parent9cca31e478f857d22058658f73a1923f9a77fd66 (diff)
downloadkrb5-b700a332dd835affa78b60089b9de5c79a8c689e.tar.gz
krb5-b700a332dd835affa78b60089b9de5c79a8c689e.tar.xz
krb5-b700a332dd835affa78b60089b9de5c79a8c689e.zip
Automatically create DIR ccache directories
If the directory for a DIR ccache doesn't exist yet, try to create it (but not its parents) with mode 700. Exercise this in test scripts by not pre-creating directories. ticket: 7196 (new)
Diffstat (limited to 'src/lib/krb5')
-rw-r--r--src/lib/krb5/ccache/cc_dir.c4
-rw-r--r--src/lib/krb5/ccache/t_cccol.py1
2 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/krb5/ccache/cc_dir.c b/src/lib/krb5/ccache/cc_dir.c
index f241c0acb..dc133f91b 100644
--- a/src/lib/krb5/ccache/cc_dir.c
+++ b/src/lib/krb5/ccache/cc_dir.c
@@ -218,13 +218,15 @@ cleanup:
return ret;
}
-/* Verify that a cache directory path exists as a directory. */
+/* Verify or create a cache directory path. */
static krb5_error_code
verify_dir(krb5_context context, const char *dirname)
{
struct stat st;
if (stat(dirname, &st) < 0) {
+ if (errno == ENOENT && mkdir(dirname, S_IRWXU) == 0)
+ return 0;
krb5_set_error_message(context, KRB5_FCC_NOFILE,
_("Credential cache directory %s does not "
"exist"), dirname);
diff --git a/src/lib/krb5/ccache/t_cccol.py b/src/lib/krb5/ccache/t_cccol.py
index 2b2c8450c..8c459ddeb 100644
--- a/src/lib/krb5/ccache/t_cccol.py
+++ b/src/lib/krb5/ccache/t_cccol.py
@@ -11,7 +11,6 @@ dccname = 'DIR:%s' % ccdir
duser = 'DIR::%s/tkt1' % ccdir
dalice = 'DIR::%s/tkt2' % ccdir
dbob = 'DIR::%s/tkt3' % ccdir
-os.mkdir(ccdir)
realm.kinit('user', password('user'), flags=['-c', duser])
realm.kinit('alice', password('alice'), flags=['-c', dalice])
realm.kinit('bob', password('bob'), flags=['-c', dbob])