]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Automatically create DIR ccache directories
authorGreg Hudson <ghudson@mit.edu>
Wed, 11 Jul 2012 17:22:09 +0000 (13:22 -0400)
committerGreg Hudson <ghudson@mit.edu>
Wed, 11 Jul 2012 17:23:17 +0000 (13:23 -0400)
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
src/lib/krb5/ccache/t_cccol.py
src/tests/gssapi/t_ccselect.py
src/tests/t_cccol.py

index f241c0acb24fd5fe35d41a2ef2be560c3ec59758..dc133f91bad577ef90d6d814e9be93507822510d 100644 (file)
@@ -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);
index 2b2c8450cca3d140c04985775edf42ac7fc01b53..8c459ddebc40896fca2e167230e1cd31c9ba1bee 100644 (file)
@@ -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])
index ce25dfb57a3b8e4e1a3f2e49fd01150d22eaa046..78f307f0174c9de97afd365a83e6564bf72ec5da 100644 (file)
@@ -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
 
index 06e190293255825aeb0ccbff23af26924b1dadd7..35b39d265c5d3acdcf5ce1d95bc3d9943926e5e0 100644 (file)
@@ -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'))