Пример #1
0
/**
 * Indicates whether or not the anti-denial-of-service attack feature is
 * enabled.
 *
 * @retval 0  The feature is disabled.
 * @retval 1  The feature is enabled.
 */
int
isAntiDosEnabled(void)
{
    static int isEnabled;
    static int isSet = 0;

    if (!isSet) {
        int status = reg_getBool(REG_ANTI_DOS, &isEnabled);

        if (status) {
            isEnabled = 1;
            LOG_ADD1("Using default value: %s", isEnabled ? "TRUE" : "FALSE");
            if (status == ENOENT) {
                log_log(LOG_INFO);
                isSet = 1;
            }
            else {
                log_log(LOG_ERR);
            }
        }
        else {
            isSet = 1;
        }
    }

    return isEnabled;
}
Пример #2
0
static void
test_regBool(void)
{
    RegStatus   status;
    int         value;

    status = reg_putBool("/fooBool_key", 0);
    if (status) {
        log_error("test_regBool(): Couldn't add boolean");
    }
    CU_ASSERT_EQUAL(status, 0);

    status = reg_getBool("/fooBool_key", &value);
    if (status) {
        log_error("test_regBool(): Couldn't get boolean");
    }
    CU_ASSERT_EQUAL(value, 0);

    status = reg_putString("/fooBool_key", "FALSE");
    if (status) {
        log_error("test_regBool(): Couldn't add boolean");
    }
    CU_ASSERT_EQUAL(status, 0);

    status = reg_getBool("/fooBool_key", &value);
    if (status) {
        log_error("test_regBool(): Couldn't get boolean");
    }
    CU_ASSERT_EQUAL(value, 0);

    status = reg_putBool("/fooBool_key", 1);
    if (status) {
        log_error("test_regBool(): Couldn't replace boolean");
    }
    CU_ASSERT_EQUAL(status, 0);

    status = reg_getBool("/fooBool_key", &value);
    if (status) {
        log_error("test_regBool(): Couldn't get boolean");
    }
    CU_ASSERT_EQUAL(value, 1);

    status = reg_putString("/fooBool_key", "TRUE");
    if (status) {
        log_error("test_regBool(): Couldn't replace boolean");
    }
    CU_ASSERT_EQUAL(status, 0);

    status = reg_getBool("/fooBool_key", &value);
    if (status) {
        log_error("test_regBool(): Couldn't get boolean");
    }
    CU_ASSERT_EQUAL(value, 1);

    status = reg_getBool("/barBool_key", &value);
    if (status && ENOENT != status) {
        log_error("test_regBool(): Bad status getting non-existent boolean: %d",
                status);
    }
    CU_ASSERT_EQUAL(status, ENOENT);
}