Ejemplo n.º 1
0
/**
 * Closes the databse and frees all resources.
 *
 * @param context The current krb5 context
 * @param db      Heimdal database handle
 *
 * @return        0 on success, an error code if not
 */
static krb5_error_code
hdb_sqlite_destroy(krb5_context context, HDB *db)
{
    int ret;

    ret = hdb_clear_master_key(context, db);

    hdb_sqlite_close_database(context, db);

    hdb_sqlite_db *hsdb = (hdb_sqlite_db*)(db->hdb_db);

    free(hsdb->db_file);
    free(db->hdb_db);
    free(db);
    
    return ret;
}
Ejemplo n.º 2
0
/*
 * Renames the database file.
 */
static krb5_error_code
hdb_sqlite_rename(krb5_context context, HDB *db, const char *new_name)
{
    hdb_sqlite_db *hsdb = (hdb_sqlite_db *) db->hdb_db;
    int ret;

    krb5_warnx(context, "hdb_sqlite_rename");

    if (strncasecmp(new_name, "sqlite:", 7) == 0)
	new_name += 7;

    hdb_sqlite_close_database(context, db);

    ret = rename(hsdb->db_file, new_name);
    free(hsdb->db_file);

    hdb_sqlite_make_database(context, db, new_name);

    return ret;
}
Ejemplo n.º 3
0
/*
 * Renames the database file.
 */
static krb5_error_code
hdb_sqlite_rename(krb5_context context, HDB *db, const char *new_name)
{
    krb5_error_code ret, ret2;
    hdb_sqlite_db *hsdb = (hdb_sqlite_db *) db->hdb_db;

    krb5_warnx(context, "hdb_sqlite_rename");

    if (strncasecmp(new_name, "sqlite:", 7) == 0)
	new_name += 7;

    ret = hdb_sqlite_close_database(context, db);

    if (rename(hsdb->db_file, new_name) == -1)
        return errno;

    free(hsdb->db_file);
    ret2 = hdb_sqlite_make_database(context, db, new_name);
    return ret ? ret : ret2;
}