~ubuntu-branches/ubuntu/jaunty/heimdal/jaunty

« back to all changes in this revision

Viewing changes to lib/krb5/cache.c

  • Committer: Bazaar Package Importer
  • Author(s): Nick Ellery
  • Date: 2008-11-17 22:25:58 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20081117222558-jd1aj1jth6ycdb0x
Tags: 1.2.dfsg.1-2.1ubuntu1
* Merge from debian unstable, remaining changes (LP: #299345):
  - Change libdb4.2-dev to libdb4.6-dev in build-deps
  - Add netbase to heimdal-kdc depends.
  - Set CPPFLAGS=-DLDAP_DEPRECATED to fix build with OpenLDAP 2.4 on
    64-bit architectures.
* Remove dependency on update-inetd to heimdal-servers and heimdal-kdc,
  as packages should rely on the inet-superserver to provide the
  update-inetd command.
* Drop the addition of -1 to the version of comerr-dev in build depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
#include "krb5_locl.h"
35
35
 
36
 
RCSID("$Id: cache.c 22127 2007-12-04 00:54:37Z lha $");
 
36
RCSID("$Id: cache.c 23131 2008-04-28 18:01:46Z lha $");
37
37
 
38
38
/**
39
39
 * Add a new ccache type with operations `ops', overwriting any
204
204
krb5_cc_new_unique(krb5_context context, const char *type, 
205
205
                   const char *hint, krb5_ccache *id)
206
206
{
207
 
    const krb5_cc_ops *ops = KRB5_DEFAULT_CCTYPE;
 
207
    const krb5_cc_ops *ops;
208
208
    krb5_error_code ret;
209
209
 
210
 
    if (type) {
211
 
        ops = krb5_cc_get_prefix_ops(context, type);
212
 
        if (ops == NULL) {
213
 
            krb5_set_error_string(context,
214
 
                                  "Credential cache type %s is unknown", type);
215
 
            return KRB5_CC_UNKNOWN_TYPE;
216
 
        }
 
210
    ops = krb5_cc_get_prefix_ops(context, type);
 
211
    if (ops == NULL) {
 
212
        krb5_set_error_string(context,
 
213
                              "Credential cache type %s is unknown", type);
 
214
        return KRB5_CC_UNKNOWN_TYPE;
217
215
    }
218
216
 
219
217
    ret = _krb5_cc_allocate(context, ops, id);
406
404
}
407
405
 
408
406
/**
 
407
 * Switch the default default credential cache for a specific
 
408
 * credcache type (and name for some implementations).
 
409
 *
 
410
 * @return Returns 0 or an error code.
 
411
 *
 
412
 * @ingroup krb5_ccache
 
413
 */
 
414
 
 
415
krb5_error_code
 
416
krb5_cc_switch(krb5_context context, krb5_ccache id)
 
417
{
 
418
 
 
419
    if (id->ops->set_default == NULL)
 
420
        return 0;
 
421
 
 
422
    return (*id->ops->set_default)(context, id);
 
423
}
 
424
 
 
425
/**
409
426
 * Set the default cc name for `context' to `name'.
410
427
 *
411
428
 * @ingroup krb5_ccache
412
429
 */
413
430
 
414
 
 
415
431
krb5_error_code KRB5_LIB_FUNCTION
416
432
krb5_cc_set_default_name(krb5_context context, const char *name)
417
433
{
440
456
            }
441
457
            if (e == NULL) {
442
458
                const krb5_cc_ops *ops = KRB5_DEFAULT_CCTYPE;
443
 
                ret = (*ops->default_name)(context, &p);
 
459
                e = krb5_config_get_string(context, NULL, "libdefaults",
 
460
                                           "default_cc_type", NULL);
 
461
                if (e) {
 
462
                    ops = krb5_cc_get_prefix_ops(context, e);
 
463
                    if (ops == NULL) {
 
464
                        krb5_set_error_string(context,
 
465
                                              "Credential cache type %s "
 
466
                                              "is unknown", e);
 
467
                        return KRB5_CC_UNKNOWN_TYPE;
 
468
                    }
 
469
                }
 
470
                ret = (*ops->get_default_name)(context, &p);
444
471
                if (ret)
445
472
                    return ret;
446
473
            }
846
873
 
847
874
/**
848
875
 * Get the cc ops that is registered in `context' to handle the
849
 
 * `prefix'. `prefix' can be a complete credential cache name or a
 
876
 * prefix. prefix can be a complete credential cache name or a
850
877
 * prefix, the function will only use part up to the first colon (:)
851
 
 * if there is one.
852
 
 * Returns NULL if ops not found.
 
878
 * if there is one. If prefix the argument is NULL, the default ccache
 
879
 * implemtation is returned.
 
880
 
 
881
 * @return Returns NULL if ops not found.
853
882
 *
854
883
 * @ingroup krb5_ccache
855
884
 */
861
890
    char *p, *p1;
862
891
    int i;
863
892
    
 
893
    if (prefix == NULL)
 
894
        return KRB5_DEFAULT_CCTYPE;
864
895
    if (prefix[0] == '/')
865
896
        return &krb5_fcc_ops;
866
897