From: Greg Hudson Date: Wed, 11 Jul 2012 17:22:09 +0000 (-0400) Subject: Automatically create DIR ccache directories X-Git-Tag: krb5-1.11-alpha1~435 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b700a332dd835affa78b60089b9de5c79a8c689e;p=thirdparty%2Fkrb5.git 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) --- diff --git a/src/lib/krb5/ccache/cc_dir.c b/src/lib/krb5/ccache/cc_dir.c index f241c0acb2..dc133f91ba 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 2b2c8450cc..8c459ddebc 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 ce25dfb57a..78f307f017 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 06e1902932..35b39d265c 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'))