Lines Matching +full:drop +full:- +full:out

30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 #define SCACHE(X) ((krb5_scache *)(X)->data.data)
63 #define SCACHE_DEF_NAME "Default-cache"
71 #define SCACHE_INVALID_CID ((sqlite_uint64)-1)
156 if (s->file) in scc_free()
157 free(s->file); in scc_free()
158 if (s->name) in scc_free()
159 free(s->name); in scc_free()
161 if (s->icred) in scc_free()
162 sqlite3_finalize(s->icred); in scc_free()
163 if (s->dcred) in scc_free()
164 sqlite3_finalize(s->dcred); in scc_free()
165 if (s->iprincipal) in scc_free()
166 sqlite3_finalize(s->iprincipal); in scc_free()
167 if (s->icache) in scc_free()
168 sqlite3_finalize(s->icache); in scc_free()
169 if (s->ucachen) in scc_free()
170 sqlite3_finalize(s->ucachen); in scc_free()
171 if (s->ucachep) in scc_free()
172 sqlite3_finalize(s->ucachep); in scc_free()
173 if (s->dcache) in scc_free()
174 sqlite3_finalize(s->dcache); in scc_free()
175 if (s->scache) in scc_free()
176 sqlite3_finalize(s->scache); in scc_free()
177 if (s->scache_name) in scc_free()
178 sqlite3_finalize(s->scache_name); in scc_free()
179 if (s->umaster) in scc_free()
180 sqlite3_finalize(s->umaster); in scc_free()
182 if (s->db) in scc_free()
183 sqlite3_close(s->db); in scc_free()
201 ret = sqlite3_prepare_v2(db, str, -1, stmt, NULL); in prepare_stmt()
271 goto out; in get_def_name()
274 goto out; in get_def_name()
278 goto out; in get_def_name()
282 goto out; in get_def_name()
287 out: in get_def_name()
306 s->cid = SCACHE_INVALID_CID; in scc_alloc()
313 ret = get_def_name(context, &s->name); in scc_alloc()
315 s->name = strdup(SCACHE_DEF_NAME); in scc_alloc()
317 s->name = strdup(name); in scc_alloc()
319 file = strrchr(s->name, ':'); in scc_alloc()
322 s->file = strdup(file); in scc_alloc()
325 ret = _krb5_expand_default_cc_name(context, KRB5_SCACHE_DB, &s->file); in scc_alloc()
328 _krb5_expand_default_cc_name(context, KRB5_SCACHE_DB, &s->file); in scc_alloc()
329 ret = asprintf(&s->name, "unique-%p", s); in scc_alloc()
331 if (ret < 0 || s->file == NULL || s->name == NULL) { in scc_alloc()
344 ret = sqlite3_open_v2(s->file, &s->db, SQLITE_OPEN_READWRITE|flags, NULL); in open_database()
346 if (s->db) { in open_database()
349 s->file, sqlite3_errmsg(s->db)); in open_database()
350 sqlite3_close(s->db); in open_database()
351 s->db = NULL; in open_database()
354 N_("malloc: out of memory", "")); in open_database()
365 sqlite3_bind_text(s->icache, 1, s->name, -1, NULL); in create_cache()
367 ret = sqlite3_step(s->icache); in create_cache()
374 sqlite3_reset(s->icache); in create_cache()
376 s->cid = sqlite3_last_insert_rowid(s->db); in create_cache()
387 if (s->db) in make_database()
395 if (ret) goto out; in make_database()
399 ret = exec_stmt(context, s->db, SQL_CMASTER, KRB5_CC_IO); in make_database()
400 if (ret) goto out; in make_database()
401 ret = exec_stmt(context, s->db, SQL_CCACHE, KRB5_CC_IO); in make_database()
402 if (ret) goto out; in make_database()
403 ret = exec_stmt(context, s->db, SQL_CCREDS, KRB5_CC_IO); in make_database()
404 if (ret) goto out; in make_database()
405 ret = exec_stmt(context, s->db, SQL_CPRINCIPALS, KRB5_CC_IO); in make_database()
406 if (ret) goto out; in make_database()
407 ret = exec_stmt(context, s->db, SQL_SETUP_MASTER, KRB5_CC_IO); in make_database()
408 if (ret) goto out; in make_database()
410 ret = exec_stmt(context, s->db, SQL_TCACHE, KRB5_CC_IO); in make_database()
411 if (ret) goto out; in make_database()
412 ret = exec_stmt(context, s->db, SQL_TCRED, KRB5_CC_IO); in make_database()
413 if (ret) goto out; in make_database()
417 sqlite3_trace(s->db, trace, NULL); in make_database()
420 ret = prepare_stmt(context, s->db, &s->icred, SQL_ICRED); in make_database()
421 if (ret) goto out; in make_database()
422 ret = prepare_stmt(context, s->db, &s->dcred, SQL_DCRED); in make_database()
423 if (ret) goto out; in make_database()
424 ret = prepare_stmt(context, s->db, &s->iprincipal, SQL_IPRINCIPAL); in make_database()
425 if (ret) goto out; in make_database()
426 ret = prepare_stmt(context, s->db, &s->icache, SQL_ICACHE); in make_database()
427 if (ret) goto out; in make_database()
428 ret = prepare_stmt(context, s->db, &s->ucachen, SQL_UCACHE_NAME); in make_database()
429 if (ret) goto out; in make_database()
430 ret = prepare_stmt(context, s->db, &s->ucachep, SQL_UCACHE_PRINCIPAL); in make_database()
431 if (ret) goto out; in make_database()
432 ret = prepare_stmt(context, s->db, &s->dcache, SQL_DCACHE); in make_database()
433 if (ret) goto out; in make_database()
434 ret = prepare_stmt(context, s->db, &s->scache, SQL_SCACHE); in make_database()
435 if (ret) goto out; in make_database()
436 ret = prepare_stmt(context, s->db, &s->scache_name, SQL_SCACHE_NAME); in make_database()
437 if (ret) goto out; in make_database()
438 ret = prepare_stmt(context, s->db, &s->umaster, SQL_UMASTER); in make_database()
439 if (ret) goto out; in make_database()
443 out: in make_database()
444 if (s->db) in make_database()
445 sqlite3_close(s->db); in make_database()
447 unlink(s->file); in make_database()
466 ret = sqlite3_bind_text(stmt, col, str, -1, free_krb5); in bind_principal()
485 return SCACHE(id)->name; in scc_get_name()
497 N_("malloc: out of memory", "")); in scc_resolve()
507 ret = sqlite3_bind_text(s->scache_name, 1, s->name, -1, NULL); in scc_resolve()
510 "bind name: %s", sqlite3_errmsg(s->db)); in scc_resolve()
515 if (sqlite3_step(s->scache_name) == SQLITE_ROW) { in scc_resolve()
517 if (sqlite3_column_type(s->scache_name, 0) != SQLITE_INTEGER) { in scc_resolve()
518 sqlite3_reset(s->scache_name); in scc_resolve()
522 s->name); in scc_resolve()
527 s->cid = sqlite3_column_int(s->scache_name, 0); in scc_resolve()
529 s->cid = SCACHE_INVALID_CID; in scc_resolve()
531 sqlite3_reset(s->scache_name); in scc_resolve()
533 (*id)->data.data = s; in scc_resolve()
534 (*id)->data.length = sizeof(*s); in scc_resolve()
548 N_("malloc: out of memory", "")); in scc_gen_new()
552 (*id)->data.data = s; in scc_gen_new()
553 (*id)->data.length = sizeof(*s); in scc_gen_new()
570 ret = exec_stmt(context, s->db, "BEGIN IMMEDIATE TRANSACTION", KRB5_CC_IO); in scc_initialize()
573 if (s->cid == SCACHE_INVALID_CID) { in scc_initialize()
578 sqlite3_bind_int(s->dcred, 1, s->cid); in scc_initialize()
580 ret = sqlite3_step(s->dcred); in scc_initialize()
582 sqlite3_reset(s->dcred); in scc_initialize()
588 sqlite3_errmsg(s->db)); in scc_initialize()
593 ret = bind_principal(context, s->db, s->ucachep, 1, primary_principal); in scc_initialize()
596 sqlite3_bind_int(s->ucachep, 2, s->cid); in scc_initialize()
599 ret = sqlite3_step(s->ucachep); in scc_initialize()
601 sqlite3_reset(s->ucachep); in scc_initialize()
606 sqlite3_errmsg(s->db)); in scc_initialize()
610 ret = exec_stmt(context, s->db, "COMMIT", KRB5_CC_IO); in scc_initialize()
616 exec_stmt(context, s->db, "ROLLBACK", 0); in scc_initialize()
637 if (s->cid == SCACHE_INVALID_CID) in scc_destroy()
640 sqlite3_bind_int(s->dcache, 1, s->cid); in scc_destroy()
642 ret = sqlite3_step(s->dcache); in scc_destroy()
644 sqlite3_reset(s->dcache); in scc_destroy()
648 s->name, sqlite3_errmsg(s->db)); in scc_destroy()
663 N_("malloc: out of memory", "")); in encode_creds()
693 N_("malloc: out of memory", "")); in decode_creds()
726 sqlite3_bind_int(s->icred, 1, s->cid); in scc_store_cred()
733 ret = decode_Ticket(creds->ticket.data, in scc_store_cred()
734 creds->ticket.length, &t, &len); in scc_store_cred()
744 sqlite3_bind_int(s->icred, 2, kvno); in scc_store_cred()
745 sqlite3_bind_int(s->icred, 3, etype); in scc_store_cred()
749 sqlite3_bind_blob(s->icred, 4, data.data, data.length, free_data); in scc_store_cred()
750 sqlite3_bind_int(s->icred, 5, time(NULL)); in scc_store_cred()
752 ret = exec_stmt(context, s->db, "BEGIN IMMEDIATE TRANSACTION", KRB5_CC_IO); in scc_store_cred()
756 ret = sqlite3_step(s->icred); in scc_store_cred()
758 sqlite3_reset(s->icred); in scc_store_cred()
763 sqlite3_errmsg(s->db)); in scc_store_cred()
767 credid = sqlite3_last_insert_rowid(s->db); in scc_store_cred()
770 bind_principal(context, s->db, s->iprincipal, 1, creds->server); in scc_store_cred()
771 sqlite3_bind_int(s->iprincipal, 2, 1); in scc_store_cred()
772 sqlite3_bind_int(s->iprincipal, 3, credid); in scc_store_cred()
775 ret = sqlite3_step(s->iprincipal); in scc_store_cred()
777 sqlite3_reset(s->iprincipal); in scc_store_cred()
782 sqlite3_errmsg(s->db)); in scc_store_cred()
788 bind_principal(context, s->db, s->iprincipal, 1, creds->client); in scc_store_cred()
789 sqlite3_bind_int(s->iprincipal, 2, 0); in scc_store_cred()
790 sqlite3_bind_int(s->iprincipal, 3, credid); in scc_store_cred()
793 ret = sqlite3_step(s->iprincipal); in scc_store_cred()
795 sqlite3_reset(s->iprincipal); in scc_store_cred()
800 sqlite3_errmsg(s->db)); in scc_store_cred()
805 ret = exec_stmt(context, s->db, "COMMIT", KRB5_CC_IO); in scc_store_cred()
811 exec_stmt(context, s->db, "ROLLBACK", 0); in scc_store_cred()
831 sqlite3_bind_int(s->scache, 1, s->cid); in scc_get_principal()
833 if (sqlite3_step(s->scache) != SQLITE_ROW) { in scc_get_principal()
834 sqlite3_reset(s->scache); in scc_get_principal()
837 s->name, s->file); in scc_get_principal()
841 if (sqlite3_column_type(s->scache, 0) != SQLITE_TEXT) { in scc_get_principal()
842 sqlite3_reset(s->scache); in scc_get_principal()
846 s->name, s->file); in scc_get_principal()
850 str = (const char *)sqlite3_column_text(s->scache, 0); in scc_get_principal()
852 sqlite3_reset(s->scache); in scc_get_principal()
855 s->name, s->file); in scc_get_principal()
861 sqlite3_reset(s->scache); in scc_get_principal()
867 char *drop; member
887 N_("malloc: out of memory", "")); in scc_get_first()
897 if (s->cid == SCACHE_INVALID_CID) { in scc_get_first()
900 s->name); in scc_get_first()
909 N_("malloc: out of memory", "")); in scc_get_first()
914 ret = asprintf(&ctx->drop, "DROP TABLE %s", name); in scc_get_first()
915 if (ret < 0 || ctx->drop == NULL) { in scc_get_first()
917 N_("malloc: out of memory", "")); in scc_get_first()
925 name, (unsigned long)s->cid); in scc_get_first()
927 free(ctx->drop); in scc_get_first()
933 ret = exec_stmt(context, s->db, str, KRB5_CC_IO); in scc_get_first()
937 free(ctx->drop); in scc_get_first()
945 exec_stmt(context, s->db, ctx->drop, 0); in scc_get_first()
946 free(ctx->drop); in scc_get_first()
952 ret = prepare_stmt(context, s->db, &ctx->stmt, str); in scc_get_first()
957 exec_stmt(context, s->db, ctx->drop, 0); in scc_get_first()
958 free(ctx->drop); in scc_get_first()
963 ret = prepare_stmt(context, s->db, &ctx->credstmt, in scc_get_first()
966 sqlite3_finalize(ctx->stmt); in scc_get_first()
967 exec_stmt(context, s->db, ctx->drop, 0); in scc_get_first()
968 free(ctx->drop); in scc_get_first()
992 ret = sqlite3_step(ctx->stmt); in scc_get_next()
999 sqlite3_errmsg(s->db)); in scc_get_next()
1003 oid = sqlite3_column_int64(ctx->stmt, 0); in scc_get_next()
1007 sqlite3_bind_int(ctx->credstmt, 1, oid); in scc_get_next()
1009 ret = sqlite3_step(ctx->credstmt); in scc_get_next()
1011 sqlite3_reset(ctx->credstmt); in scc_get_next()
1015 if (sqlite3_column_type(ctx->credstmt, 0) != SQLITE_BLOB) { in scc_get_next()
1018 s->name, s->file); in scc_get_next()
1019 sqlite3_reset(ctx->credstmt); in scc_get_next()
1023 data = sqlite3_column_blob(ctx->credstmt, 0); in scc_get_next()
1024 len = sqlite3_column_bytes(ctx->credstmt, 0); in scc_get_next()
1027 sqlite3_reset(ctx->credstmt); in scc_get_next()
1039 sqlite3_finalize(ctx->stmt); in scc_end_get()
1040 sqlite3_finalize(ctx->credstmt); in scc_end_get()
1042 exec_stmt(context, s->db, ctx->drop, 0); in scc_end_get()
1044 free(ctx->drop); in scc_end_get()
1067 ret = prepare_stmt(context, s->db, &stmt, in scc_remove_cred()
1073 sqlite3_bind_int(stmt, 1, s->cid); in scc_remove_cred()
1087 sqlite3_errmsg(s->db)); in scc_remove_cred()
1096 s->name, s->file); in scc_remove_cred()
1119 ret = prepare_stmt(context, s->db, &stmt, in scc_remove_cred()
1149 char *drop; member
1166 N_("malloc: out of memory", "")); in scc_get_cache_first()
1170 ret = default_db(context, &ctx->db); in scc_get_cache_first()
1171 if (ctx->db == NULL) { in scc_get_cache_first()
1180 N_("malloc: out of memory", "")); in scc_get_cache_first()
1181 sqlite3_close(ctx->db); in scc_get_cache_first()
1186 ret = asprintf(&ctx->drop, "DROP TABLE %s", name); in scc_get_cache_first()
1187 if (ret < 0 || ctx->drop == NULL) { in scc_get_cache_first()
1189 N_("malloc: out of memory", "")); in scc_get_cache_first()
1190 sqlite3_close(ctx->db); in scc_get_cache_first()
1200 N_("malloc: out of memory", "")); in scc_get_cache_first()
1201 sqlite3_close(ctx->db); in scc_get_cache_first()
1203 free(ctx->drop); in scc_get_cache_first()
1208 ret = exec_stmt(context, ctx->db, str, KRB5_CC_IO); in scc_get_cache_first()
1212 sqlite3_close(ctx->db); in scc_get_cache_first()
1214 free(ctx->drop); in scc_get_cache_first()
1222 exec_stmt(context, ctx->db, ctx->drop, 0); in scc_get_cache_first()
1223 sqlite3_close(ctx->db); in scc_get_cache_first()
1225 free(ctx->drop); in scc_get_cache_first()
1230 ret = prepare_stmt(context, ctx->db, &ctx->stmt, str); in scc_get_cache_first()
1233 exec_stmt(context, ctx->db, ctx->drop, 0); in scc_get_cache_first()
1234 sqlite3_close(ctx->db); in scc_get_cache_first()
1235 free(ctx->drop); in scc_get_cache_first()
1255 ret = sqlite3_step(ctx->stmt); in scc_get_cache_next()
1262 sqlite3_errmsg(ctx->db)); in scc_get_cache_next()
1266 if (sqlite3_column_type(ctx->stmt, 0) != SQLITE_TEXT) in scc_get_cache_next()
1269 name = (const char *)sqlite3_column_text(ctx->stmt, 0); in scc_get_cache_next()
1285 exec_stmt(context, ctx->db, ctx->drop, 0); in scc_end_cache_get()
1286 sqlite3_finalize(ctx->stmt); in scc_end_cache_get()
1287 sqlite3_close(ctx->db); in scc_end_cache_get()
1288 free(ctx->drop); in scc_end_cache_get()
1300 if (strcmp(sfrom->file, sto->file) != 0) { in scc_move()
1303 "credential move: %s -> %s", ""), in scc_move()
1304 sfrom->file, sto->file); in scc_move()
1312 ret = exec_stmt(context, sfrom->db, in scc_move()
1316 if (sto->cid != SCACHE_INVALID_CID) { in scc_move()
1317 /* drop old cache entry */ in scc_move()
1319 sqlite3_bind_int(sfrom->dcache, 1, sto->cid); in scc_move()
1321 ret = sqlite3_step(sfrom->dcache); in scc_move()
1323 sqlite3_reset(sfrom->dcache); in scc_move()
1332 sqlite3_bind_text(sfrom->ucachen, 1, sto->name, -1, NULL); in scc_move()
1333 sqlite3_bind_int(sfrom->ucachen, 2, sfrom->cid); in scc_move()
1336 ret = sqlite3_step(sfrom->ucachen); in scc_move()
1338 sqlite3_reset(sfrom->ucachen); in scc_move()
1346 sto->cid = sfrom->cid; in scc_move()
1348 ret = exec_stmt(context, sfrom->db, "COMMIT", KRB5_CC_IO); in scc_move()
1356 exec_stmt(context, sfrom->db, "ROLLBACK", 0); in scc_move()
1378 N_("malloc: out of memory", "")); in scc_get_default_name()
1390 if (s->cid == SCACHE_INVALID_CID) { in scc_set_default()
1394 s->name); in scc_set_default()
1398 ret = sqlite3_bind_text(s->umaster, 1, s->name, -1, NULL); in scc_set_default()
1400 sqlite3_reset(s->umaster); in scc_set_default()
1407 ret = sqlite3_step(s->umaster); in scc_set_default()
1409 sqlite3_reset(s->umaster); in scc_set_default()