/* duo_common_ini_handler returns 0 for invalid input */
static void test_failmode_neither() {
    struct duo_config cfg = {0};
    char *name = "failmode";
    char *failmode = "neither";

    TEST_ASSERT_FALSE(duo_common_ini_handler(&cfg, SECTION, name, failmode));
}
/* Testing duo_common_ini_handler with a wrong flag */
static void test_wrong_flag() {
    struct duo_config cfg = {0};
    char *name = "wrong_flag";
    char *value = "asdf";

    TEST_ASSERT_FALSE(duo_common_ini_handler(&cfg, SECTION, name, value));
}
/* Testing adding failmode to duo_config */
static void test_failmode_safe() {
    struct duo_config cfg = {0};
    char *name = "failmode";
    char *failmode = "safe";
    int expected_failmode = DUO_FAIL_SAFE;

    duo_common_ini_handler(&cfg, SECTION, name, failmode);
    TEST_ASSERT_EQUAL(expected_failmode, cfg.failmode);
}
Example #4
0
static int
__ini_handler(void *u, const char *section, const char *name, const char *val)
{
	struct duo_config *cfg = (struct duo_config *)u;
	if (!duo_common_ini_handler(cfg, section, name, val)) {
		/* There are no options specific to pam_duo yet */
		duo_syslog(LOG_ERR, "Invalid pam_duo option: '%s'", name);
		return (0);
	}
	return (1);
}
Example #5
0
static int
__ini_handler(void *u, const char *section, const char *name, const char *val)
{
    struct duo_config *cfg = (struct duo_config *)u;
    if (!duo_common_ini_handler(cfg, section, name, val)) {
        /* Extra login_duo options */
        if (strcmp(name, "motd") == 0) {
            cfg->motd = duo_set_boolean_option(val);
        } else {
            fprintf(stderr, "Invalid login_duo option: '%s'\n", name);
            return (0);
        }
    }
    return (1);
}
static void test_failmode_null() {
    struct duo_config cfg = {0};
    char *name = "failmode";

    TEST_ASSERT_FALSE(duo_common_ini_handler(&cfg, SECTION, name, NULL_STR));
}
static void test_wrong_flag_null() {
    struct duo_config cfg = {0};
    char *value = "asdf";

    TEST_ASSERT_FALSE(duo_common_ini_handler(&cfg, SECTION, NULL_STR, value));
}