Exemple #1
0
cc_int32 ccs_ccache_swap_contents (ccs_ccache_t           io_source_ccache,
                                   ccs_ccache_t           io_destination_ccache,
				   ccs_cache_collection_t io_cache_collection)
{
    cc_int32 err = ccNoError;

    if (!io_source_ccache     ) { err = cci_check_error (ccErrBadParam); }
    if (!io_destination_ccache) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        struct ccs_ccache_d temp_ccache = *io_destination_ccache;

        /* swap everything */
        *io_destination_ccache = *io_source_ccache;
        *io_source_ccache = temp_ccache;

        /* swap back the name and identifier */
        io_source_ccache->identifier = io_destination_ccache->identifier;
        io_destination_ccache->identifier = temp_ccache.identifier;

        io_source_ccache->name = io_destination_ccache->name;
        io_destination_ccache->name = temp_ccache.name;
    }

    if (!err) {
        err = ccs_ccache_changed (io_source_ccache, io_cache_collection);
    }

    if (!err) {
        err = ccs_ccache_changed (io_destination_ccache, io_cache_collection);
    }

    return cci_check_error (err);
}
Exemple #2
0
static cc_int32 ccs_ccache_set_kdc_time_offset (ccs_ccache_t           io_ccache,
                                                ccs_cache_collection_t io_cache_collection,
                                                k5_ipc_stream           in_request_data,
                                                k5_ipc_stream           io_reply_data)
{
    cc_int32 err = ccNoError;
    cc_uint32 cred_vers = 0;

    if (!io_ccache          ) { err = cci_check_error (ccErrBadParam); }
    if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
    if (!in_request_data    ) { err = cci_check_error (ccErrBadParam); }
    if (!io_reply_data      ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        err = krb5int_ipc_stream_read_uint32 (in_request_data, &cred_vers);
    }

    if (!err) {
        if (cred_vers == cc_credentials_v5) {
            err = krb5int_ipc_stream_read_time (in_request_data, &io_ccache->kdc_time_offset_v5);

            if (!err) {
                io_ccache->kdc_time_offset_v5_valid = 1;
            }
        } else {
            err = cci_check_error (ccErrBadCredentialsVersion);
        }
    }

    if (!err) {
        err = ccs_ccache_changed (io_ccache, io_cache_collection);
    }

    return cci_check_error (err);
}
Exemple #3
0
static cc_int32 ccs_ccache_move (ccs_ccache_t           io_ccache,
                                 ccs_cache_collection_t io_cache_collection,
                                 k5_ipc_stream           in_request_data,
                                 k5_ipc_stream           io_reply_data)
{
    cc_int32 err = ccNoError;
    cci_identifier_t source_identifier = NULL;

    if (!io_ccache          ) { err = cci_check_error (ccErrBadParam); }
    if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
    if (!in_request_data    ) { err = cci_check_error (ccErrBadParam); }
    if (!io_reply_data      ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        /* Note: message is sent as the destination ccache to avoid     */
        /* extra work on the server when deleting it the source ccache. */
        err = cci_identifier_read (&source_identifier, in_request_data);
    }

    if (!err) {
        err = ccs_ccache_collection_move_ccache (io_cache_collection,
                                                 source_identifier,
                                                 io_ccache);
    }

    if (!err) {
        err = ccs_ccache_changed (io_ccache, io_cache_collection);
    }

    cci_identifier_release (source_identifier);

    return cci_check_error (err);
}
Exemple #4
0
static cc_int32 ccs_ccache_remove_credentials (ccs_ccache_t           io_ccache,
                                               ccs_cache_collection_t io_cache_collection,
                                               k5_ipc_stream           in_request_data,
                                               k5_ipc_stream           io_reply_data)
{
    cc_int32 err = ccNoError;
    cci_identifier_t credentials_identifier = NULL;

    if (!io_ccache          ) { err = cci_check_error (ccErrBadParam); }
    if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
    if (!in_request_data    ) { err = cci_check_error (ccErrBadParam); }
    if (!io_reply_data      ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        err = cci_identifier_read (&credentials_identifier, in_request_data);
    }

    if (!err) {
        err = ccs_credentials_list_remove (io_ccache->credentials, credentials_identifier);
    }

    if (!err) {
        err = ccs_ccache_changed (io_ccache, io_cache_collection);
    }

    cci_identifier_release (credentials_identifier);

    return cci_check_error (err);
}
Exemple #5
0
static cc_int32 ccs_ccache_store_credentials (ccs_ccache_t           io_ccache,
                                              ccs_cache_collection_t io_cache_collection,
                                              k5_ipc_stream           in_request_data,
                                              k5_ipc_stream           io_reply_data)
{
    cc_int32 err = ccNoError;
    ccs_credentials_t credentials = NULL;

    if (!io_ccache          ) { err = cci_check_error (ccErrBadParam); }
    if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
    if (!in_request_data    ) { err = cci_check_error (ccErrBadParam); }
    if (!io_reply_data      ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        err = ccs_credentials_new (&credentials, in_request_data,
                                   io_ccache->creds_version,
                                   io_ccache->credentials);
    }

    if (!err) {
        err = ccs_ccache_changed (io_ccache, io_cache_collection);
    }


    return cci_check_error (err);
}
Exemple #6
0
cc_int32 ccs_ccache_notify_default_state_changed (ccs_ccache_t           io_ccache,
                                                  ccs_cache_collection_t io_cache_collection,
                                                  cc_uint32              in_new_default_state)
{
    cc_int32 err = ccNoError;

    if (!io_ccache          ) { err = cci_check_error (ccErrBadParam); }
    if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }

    if (!err && in_new_default_state) {
        cc_time_t now = time (NULL);

        if (io_ccache->last_default_time < now) {
            io_ccache->last_default_time = now;
        } else {
            io_ccache->last_default_time++;
        }
    }

    if (!err) {
        err = ccs_ccache_changed (io_ccache, io_cache_collection);
    }

    return cci_check_error (err);
}
Exemple #7
0
cc_int32 ccs_cache_collection_destroy_ccache (ccs_cache_collection_t  io_cache_collection,
                                              cci_identifier_t        in_identifier)
{
    cc_int32 err = ccNoError;
    ccs_ccache_t ccache = NULL;

    if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
    if (!in_identifier      ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        err = ccs_cache_collection_find_ccache (io_cache_collection,
                                                in_identifier,
                                                &ccache);
    }

    if (!err) {
        /* Notify before deletion because after deletion the ccache
         * will no longer exist (and won't know about its clients) */
        err = ccs_ccache_changed (ccache, io_cache_collection);
    }

    if (!err) {
        err = ccs_ccache_list_remove (io_cache_collection->ccaches,
                                      in_identifier);
    }

    return cci_check_error (err);
}
static cc_int32 ccs_ccache_set_principal (ccs_ccache_t           io_ccache,
                                          ccs_cache_collection_t io_cache_collection,
                                          k5_ipc_stream           in_request_data,
                                          k5_ipc_stream           io_reply_data)
{
    cc_int32 err = ccNoError;
    cc_uint32 version = 0;
    char *principal = NULL;

    if (!io_ccache          ) { err = cci_check_error (ccErrBadParam); }
    if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
    if (!in_request_data    ) { err = cci_check_error (ccErrBadParam); }
    if (!io_reply_data      ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        err = k5_ipc_stream_read_uint32 (in_request_data, &version);
    }

    if (!err) {
        err = k5_ipc_stream_read_string (in_request_data, &principal);
    }

    if (!err) {
        /* reset KDC time offsets because they are per-KDC */
        if (version == cc_credentials_v4) {
            io_ccache->kdc_time_offset_v4 = 0;
            io_ccache->kdc_time_offset_v4_valid = 0;

            if (io_ccache->v4_principal) { free (io_ccache->v4_principal); }
            io_ccache->v4_principal = principal;
            principal = NULL; /* take ownership */


        } else if (version == cc_credentials_v5) {
            io_ccache->kdc_time_offset_v5 = 0;
            io_ccache->kdc_time_offset_v5_valid = 0;

            if (io_ccache->v5_principal) { free (io_ccache->v5_principal); }
            io_ccache->v5_principal = principal;
            principal = NULL; /* take ownership */

        } else {
            err = cci_check_error (ccErrBadCredentialsVersion);
        }
    }

    if (!err) {
        io_ccache->creds_version |= version;

        err = ccs_ccache_changed (io_ccache, io_cache_collection);
    }

    k5_ipc_stream_free_string (principal);

    return cci_check_error (err);
}
Exemple #9
0
cc_int32 ccs_ccache_reset (ccs_ccache_t            io_ccache,
			   ccs_cache_collection_t  io_cache_collection,
                           cc_uint32               in_creds_version,
                           const char             *in_principal)
{
    cc_int32 err = ccNoError;
    char *v5_principal = NULL;
    ccs_credentials_list_t credentials = NULL;

    if (!io_ccache          ) { err = cci_check_error (ccErrBadParam); }
    if (!io_cache_collection) { err = cci_check_error (ccErrBadParam); }
    if (!in_principal       ) { err = cci_check_error (ccErrBadParam); }

    if (!err) {
        io_ccache->creds_version = in_creds_version;

        if (io_ccache->creds_version == cc_credentials_v5) {
            v5_principal = strdup (in_principal);
            if (!v5_principal) { err = cci_check_error (ccErrNoMem); }

        } else {
            err = cci_check_error (ccErrBadCredentialsVersion);
        }
    }

    if (!err) {
        err = ccs_credentials_list_new (&credentials);
    }

    if (!err) {
        io_ccache->kdc_time_offset_v5 = 0;
        io_ccache->kdc_time_offset_v5_valid = 0;

        if (io_ccache->v5_principal) { free (io_ccache->v5_principal); }
        io_ccache->v5_principal = v5_principal;
        v5_principal = NULL; /* take ownership */

        ccs_credentials_list_release (io_ccache->credentials);
        io_ccache->credentials = credentials;
        credentials = NULL; /* take ownership */

	err = ccs_ccache_changed (io_ccache, io_cache_collection);
    }

    free (v5_principal);
    ccs_credentials_list_release (credentials);

    return cci_check_error (err);
}