~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/windows/identity/kcreddb/identity.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman, Russ Allbery, Sam Hartman
  • Date: 2008-08-21 10:41:41 UTC
  • mfrom: (11.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080821104141-a0f9c4o4cpo8xd0o
Tags: 1.6.dfsg.4~beta1-4
[ Russ Allbery ]
* Translation updates:
  - Swedish, thanks Martin Bagge.  (Closes: #487669, #491774)
  - Italian, thanks Luca Monducci.  (Closes: #493962)

[ Sam Hartman ]
* Translation Updates:
    - Dutch, Thanks Vincent Zweije, Closes: #495733

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Copyright (c) 2005 Massachusetts Institute of Technology
 
3
 * Copyright (c) 2007 Secure Endpoints Inc.
3
4
 *
4
5
 * Permission is hereby granted, free of charge, to any person
5
6
 * obtaining a copy of this software and associated documentation
54
55
    EnterCriticalSection(&cs_ident);
55
56
    if (sub != kcdb_ident_sub) {
56
57
        if(kcdb_ident_sub != NULL) {
57
 
            kmq_post_sub_msg(kcdb_ident_sub,
 
58
            kmq_send_sub_msg(kcdb_ident_sub,
58
59
                             KMSG_IDENT,
59
60
                             KMSG_IDENT_EXIT,
60
61
                             0,
64
65
        kcdb_ident_sub = sub;
65
66
 
66
67
        if (kcdb_ident_sub)
67
 
            kmq_post_sub_msg(kcdb_ident_sub,
 
68
            kmq_send_sub_msg(kcdb_ident_sub,
68
69
                             KMSG_IDENT,
69
70
                             KMSG_IDENT_INIT,
70
71
                             0,
230
231
    StringCbCopy(id->name, namesize, name);
231
232
 
232
233
    id->flags = (flags & KCDB_IDENT_FLAGMASK_RDWR);
233
 
    id->flags |= KCDB_IDENT_FLAG_ACTIVE;
 
234
    id->flags |= KCDB_IDENT_FLAG_ACTIVE | KCDB_IDENT_FLAG_EMPTY;
234
235
    LINIT(id);
235
236
 
236
237
    EnterCriticalSection(&cs_ident);
321
322
       are freed.  Once they are released, kcdb_identity_delete() will
322
323
       be called again. */
323
324
 
324
 
#if 0
325
 
    EnterCriticalSection(&cs_ident);
326
 
    if(id->refcount == 0) {
327
 
        /*TODO: free up the identity */
328
 
    }
329
 
#endif
330
325
 _exit:
331
326
    LeaveCriticalSection(&cs_ident);
332
327
 
430
425
 
431
426
    id->flags = (id->flags & ~mask) | (flag & mask);
432
427
 
433
 
    if (flag & KCDB_IDENT_FLAG_VALID)
434
 
        id->flags &= ~KCDB_IDENT_FLAG_INVALID;
435
 
    if (flag & KCDB_IDENT_FLAG_INVALID)
436
 
        id->flags &= ~KCDB_IDENT_FLAG_VALID;
 
428
    if (flag & KCDB_IDENT_FLAG_VALID) {
 
429
        id->flags &= ~(KCDB_IDENT_FLAG_INVALID | KCDB_IDENT_FLAG_UNKNOWN);
 
430
    }
 
431
    if (flag & KCDB_IDENT_FLAG_INVALID) {
 
432
        id->flags &= ~(KCDB_IDENT_FLAG_VALID | KCDB_IDENT_FLAG_UNKNOWN);
 
433
    }
437
434
 
438
435
    newflags = id->flags;
439
436
 
471
468
 
472
469
    id = (kcdb_identity *) vid;
473
470
 
 
471
    EnterCriticalSection(&cs_ident);
474
472
    *flags = id->flags;
 
473
    LeaveCriticalSection(&cs_ident);
475
474
 
476
475
    return KHM_ERROR_SUCCESS;
477
476
}
570
569
 
571
570
        LeaveCriticalSection(&cs_ident);
572
571
 
573
 
        if (invoke_identpro)
574
 
            kcdbint_ident_post_message(KCDB_OP_NEW_DEFAULT, new_def);
 
572
        /* if (invoke_identpro) */
 
573
        kcdbint_ident_post_message(KCDB_OP_NEW_DEFAULT, new_def);
575
574
    } else {
576
575
        LeaveCriticalSection(&cs_ident);
577
576
    }
617
616
                            &hident);
618
617
 
619
618
        if(KHM_FAILED(rv)) {
 
619
            khm_int32 oldflags;
620
620
            EnterCriticalSection(&cs_ident);
 
621
            oldflags = id->flags;
621
622
            id->flags &= ~KCDB_IDENT_FLAG_CONFIG;
622
623
            LeaveCriticalSection(&cs_ident);
 
624
            if (oldflags & KCDB_IDENT_FLAG_CONFIG)
 
625
                kcdbint_ident_post_message(KCDB_OP_DELCONFIG, id);
623
626
            goto _exit;
624
627
        }
625
628
 
800
803
             ident != NULL;
801
804
             ident = next) {
802
805
 
803
 
            next = LNEXT(ident);
804
 
 
805
806
            if (!kcdb_is_active_identity(ident) ||
806
 
                ident->refresh_cycle == kcdb_ident_refresh_cycle)
 
807
                ident->refresh_cycle == kcdb_ident_refresh_cycle) {
 
808
                next = LNEXT(ident);
807
809
                continue;
 
810
            }
808
811
 
809
812
            kcdb_identity_hold((khm_handle) ident);
810
813
 
814
817
 
815
818
            EnterCriticalSection(&cs_ident);
816
819
 
 
820
            next = LNEXT(ident);
817
821
            kcdb_identity_release((khm_handle) ident);
818
822
 
819
823
            hit_count++;
876
880
 
877
881
    if (buffer == NULL) {
878
882
        /* we are removing a value */
879
 
        slot = kcdb_buf_slot_by_id(&id->buf, attr_id);
 
883
        slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id);
880
884
        if (slot != KCDB_BUF_INVALID_SLOT &&
881
885
            kcdb_buf_exist(&id->buf, slot))
882
 
            kcdb_buf_alloc(&id->buf, slot, attr_id, 0);
 
886
            kcdb_buf_alloc(&id->buf, slot, (khm_ui_2) attr_id, 0);
883
887
        code = KHM_ERROR_SUCCESS;
884
888
        goto _exit;
885
889
    }
900
904
        goto _exit;
901
905
    }
902
906
 
903
 
    kcdb_buf_alloc(&id->buf, KCDB_BUF_APPEND, attr_id, cbdest);
904
 
    slot = kcdb_buf_slot_by_id(&id->buf, attr_id);
 
907
    kcdb_buf_alloc(&id->buf, KCDB_BUF_APPEND, (khm_ui_2) attr_id, cbdest);
 
908
    slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id);
905
909
    if(slot == KCDB_BUF_INVALID_SLOT || !kcdb_buf_exist(&id->buf, slot)) {
906
910
        code = KHM_ERROR_NO_RESOURCES;
907
911
        goto _exit;
910
914
    if(KHM_FAILED(code =
911
915
        type->dup(buffer, cbbuf, kcdb_buf_get(&id->buf, slot), &cbdest)))
912
916
    {
913
 
        kcdb_buf_alloc(&id->buf, slot, attr_id, 0);
 
917
        kcdb_buf_alloc(&id->buf, slot, (khm_ui_2) attr_id, 0);
914
918
        goto _exit;
915
919
    }
916
920
 
929
933
 
930
934
KHMEXP khm_int32 KHMAPI 
931
935
kcdb_identity_set_attrib(khm_handle vid,
932
 
                         wchar_t * attr_name,
 
936
                         const wchar_t * attr_name,
933
937
                         void * buffer,
934
938
                         khm_size cbbuf)
935
939
{
980
984
    id = (kcdb_identity *) vid;
981
985
 
982
986
    if(!(id->flags & KCDB_IDENT_FLAG_ATTRIBS) ||
983
 
        (slot = kcdb_buf_slot_by_id(&id->buf, attr_id)) == KCDB_BUF_INVALID_SLOT ||
 
987
       (slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id)) == KCDB_BUF_INVALID_SLOT ||
984
988
        !kcdb_buf_val_exist(&id->buf, slot)) 
985
989
    {
986
990
        code = KHM_ERROR_NOT_FOUND;
999
1003
        /* we should never hit this case */
1000
1004
#ifdef DEBUG
1001
1005
        assert(FALSE);
1002
 
#else
 
1006
#endif
1003
1007
        code = KHM_ERROR_INVALID_OPERATION;
1004
 
#endif
1005
1008
    } else {
1006
1009
#endif
1007
1010
        code = type->dup(
1025
1028
 
1026
1029
KHMEXP khm_int32 KHMAPI 
1027
1030
kcdb_identity_get_attrib(khm_handle vid,
1028
 
                         wchar_t * attr_name,
 
1031
                         const wchar_t * attr_name,
1029
1032
                         khm_int32 * attr_type,
1030
1033
                         void * buffer,
1031
1034
                         khm_size * pcbbuf)
1074
1077
    id = (kcdb_identity *) vid;
1075
1078
 
1076
1079
    if(!(id->flags & KCDB_IDENT_FLAG_ATTRIBS) ||
1077
 
        (slot = kcdb_buf_slot_by_id(&id->buf, attr_id)) == KCDB_BUF_INVALID_SLOT ||
 
1080
       (slot = kcdb_buf_slot_by_id(&id->buf, (khm_ui_2) attr_id)) == KCDB_BUF_INVALID_SLOT ||
1078
1081
        !kcdb_buf_val_exist(&id->buf, slot)) 
1079
1082
    {
1080
1083
        code = KHM_ERROR_NOT_FOUND;
1092
1095
    if(attrib->flags & KCDB_ATTR_FLAG_COMPUTED) {
1093
1096
#ifdef DEBUG
1094
1097
        assert(FALSE);
1095
 
#else
 
1098
#endif
1096
1099
        code = KHM_ERROR_INVALID_OPERATION;
1097
 
#endif
1098
1100
    } else {
1099
1101
#endif
1100
1102
        if(kcdb_buf_exist(&id->buf, slot)) {
1121
1123
}
1122
1124
 
1123
1125
KHMEXP khm_int32 KHMAPI 
1124
 
kcdb_identity_get_attrib_string(
1125
 
                                khm_handle vid,
1126
 
                                wchar_t * attr_name,
 
1126
kcdb_identity_get_attrib_string(khm_handle vid,
 
1127
                                const wchar_t * attr_name,
1127
1128
                                wchar_t * buffer,
1128
1129
                                khm_size * pcbbuf,
1129
1130
                                khm_int32 flags)