forked from krb5/krb5-anonsvn
/
fcc_sseq.c
65 lines (57 loc) · 1.63 KB
/
fcc_sseq.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* $Source$
* $Author$
*
* Copyright 1990 by the Massachusetts Institute of Technology.
*
* For copying and distribution information, please see the file
* <krb5/copyright.h>.
*
* This file contains the source code for krb5_fcc_start_seq_get.
*/
#if !defined(lint) && !defined(SABER)
static char rcsid_fcc_sseq_c[] = "$Id$";
#endif /* !lint && !SABER */
#include <krb5/copyright.h>
#include "fcc.h"
/*
* Effects:
* Prepares for a sequential search of the credentials cache.
* Returns and krb5_cc_cursor to be used with krb5_fcc_next_cred and
* krb5_fcc_end_seq_get.
*
* If the cache is modified between the time of this call and the time
* of the final krb5_fcc_end_seq_get, the results are undefined.
*
* Errors:
* KRB5_CC_NOMEM
* system errors
*/
krb5_error_code
krb5_fcc_start_seq_get(id, cursor)
krb5_ccache id;
krb5_cc_cursor *cursor;
{
krb5_fcc_cursor *fcursor;
int ret;
fcursor = (krb5_fcc_cursor *) malloc(sizeof(krb5_fcc_cursor));
if (fcursor == NULL)
return KRB5_CC_NOMEM;
/* Make sure we start reading right after the primary principal */
if (OPENCLOSE(id)) {
ret = open(((krb5_fcc_data *) id->data)->filename, O_RDONLY, 0);
if (ret < 0)
return krb5_fcc_interpret(errno);
((krb5_fcc_data *) id->data)->fd = ret;
}
else
lseek(((krb5_fcc_data *) id->data)->fd, 0, L_SET);
krb5_fcc_skip_principal(id);
fcursor->pos = tell(((krb5_fcc_data *) id->data)->fd);
*cursor = (krb5_cc_cursor) fcursor;
if (OPENCLOSE(id)) {
close(((krb5_fcc_data *) id->data)->fd);
((krb5_fcc_data *) id->data)->fd = -1;
}
return KRB5_OK;
}