Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend_init doesn't respect backend env variable #831

Open
williamcroberts opened this issue Mar 15, 2023 · 0 comments
Open

backend_init doesn't respect backend env variable #831

williamcroberts opened this issue Mar 15, 2023 · 0 comments

Comments

@williamcroberts
Copy link
Member

The code below always initializes the backends no matter what the env variable returns.

CK_RV backend_init(void) {
    LOGV("Initializing backends");

    enum backend backend = get_backend();

    if (backend == backend_error) {
        return CKR_GENERAL_ERROR;
    }

    CK_RV rv = backend_fapi_init();
    if (rv) {
        static const char *msg = "FAPI backend was not initialized.";
        if (backend == backend_fapi) {
            LOGE(msg);
            return rv;
        }
        LOGW(msg);
    } else {
        fapi_init = true;
    }

    rv = backend_esysdb_init();
    if (rv) {
        LOGW("ESYSDB backend was not initialized.");
    } else {
        esysdb_init = true;
    }

    if (!fapi_init && !esysdb_init) {
        LOGE("Neither FAPI nor ESYSDB backends could be initialized.");
        return CKR_GENERAL_ERROR;
    }
    return CKR_OK;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant