krb5 commit: Automatically create DIR ccache directories

Greg Hudson ghudson at MIT.EDU
Wed Jul 11 13:23:36 EDT 2012


https://github.com/krb5/krb5/commit/b700a332dd835affa78b60089b9de5c79a8c689e
commit b700a332dd835affa78b60089b9de5c79a8c689e
Author: Greg Hudson <ghudson at mit.edu>
Date:   Wed Jul 11 13:22:09 2012 -0400

    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)

 src/lib/krb5/ccache/cc_dir.c   |    4 +++-
 src/lib/krb5/ccache/t_cccol.py |    1 -
 src/tests/gssapi/t_ccselect.py |    1 -
 src/tests/t_cccol.py           |    1 -
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/lib/krb5/ccache/cc_dir.c b/src/lib/krb5/ccache/cc_dir.c
index f241c0a..dc133f9 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 2b2c845..8c459dd 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])
diff --git a/src/tests/gssapi/t_ccselect.py b/src/tests/gssapi/t_ccselect.py
index ce25dfb..78f307f 100644
--- a/src/tests/gssapi/t_ccselect.py
+++ b/src/tests/gssapi/t_ccselect.py
@@ -55,7 +55,6 @@ if 'No Kerberos credentials available' not in output:
 # Make a directory collection and use it for client commands in both realms.
 ccdir = os.path.join(r1.testdir, 'cc')
 ccname = 'DIR:' + ccdir
-os.mkdir(ccdir)
 r1.env_client['KRB5CCNAME'] = ccname
 r2.env_client['KRB5CCNAME'] = ccname
 
diff --git a/src/tests/t_cccol.py b/src/tests/t_cccol.py
index 06e1902..35b39d2 100644
--- a/src/tests/t_cccol.py
+++ b/src/tests/t_cccol.py
@@ -28,7 +28,6 @@ realm = K5Realm(create_user=False, create_host=False)
 # Make a directory collection and use it for client commands in both realms.
 ccdir = os.path.join(realm.testdir, 'cc')
 ccname = 'DIR:' + ccdir
-os.mkdir(ccdir)
 realm.env_client['KRB5CCNAME'] = ccname
 
 realm.addprinc('alice', password('alice'))


More information about the cvs-krb5 mailing list