Пример #1
0
// is this right?
bool isTrue(Obj expr) {
    switch (GETTAG(expr)) {
        case NUM:
            return GETNUM(expr) != false;
        case BOOL_:
            return GETBOOL(expr) != false;
        default:
            return true;
    }
}
Пример #2
0
/**************************************************************************************************
	LOAD_CONFIG
	Load the configuration file.
**************************************************************************************************/
void
load_config(void) {
    int		n;
    struct passwd *pwd = NULL;
    struct group	*grp = NULL;

    /* Load config */
    conf_load(&Conf, opt_conf);

    /* Set defaults */
    for (n = 0; defConfig[n].name; n++) {
        if (defConfig[n].name[0] == '-' || !defConfig[n].value)
            continue;
        if (!conf_get(&Conf, defConfig[n].name, NULL))
            conf_set(&Conf, defConfig[n].name, defConfig[n].value, 1);
    }

    /* Support "mysql-user" etc. for backwards compatibility */
    if (conf_get(&Conf, "mysql-host", NULL))
        conf_set(&Conf, "db-host", conf_get(&Conf, "mysql-host", NULL), 0);
    if (conf_get(&Conf, "mysql-user", NULL))
        conf_set(&Conf, "db-user", conf_get(&Conf, "mysql-user", NULL), 0);
    if (conf_get(&Conf, "mysql-pass", NULL))
        conf_set(&Conf, "db-password", conf_get(&Conf, "mysql-pass", NULL), 0);
    if (conf_get(&Conf, "mysql-password", NULL))
        conf_set(&Conf, "db-password", conf_get(&Conf, "mysql-password", NULL), 0);

#if HAVE_GETPWUID
    /* Set default for database username to real username if none was provided */
    if (!conf_get(&Conf, "db-user", NULL)) {
        struct passwd *pwd2;

        if ((pwd2 = getpwuid(getuid())) && pwd2->pw_name) {
            conf_set(&Conf, "db-user", pwd2->pw_name, 0);
            memset(pwd2, 0, sizeof(struct passwd));
        }
    }
#endif

    /* Load user/group perms */
    if (!(pwd = getpwnam(conf_get(&Conf, "user", NULL))))
        Err(_("error loading uid for user `%s'"), conf_get(&Conf, "user", NULL));
    perms_uid = pwd->pw_uid;
    perms_gid = pwd->pw_gid;
    memset(pwd, 0, sizeof(struct passwd));

    if (!(grp = getgrnam(conf_get(&Conf, "group", NULL))) && !(grp = getgrnam("nobody"))) {
        Warnx(_("error loading gid for group `%s'"), conf_get(&Conf, "group", NULL));
        Warnx(_("using gid %lu from user `%s'"), (unsigned long)perms_gid, conf_get(&Conf, "user", NULL));
    } else {
        perms_gid = grp->gr_gid;
        memset(grp, 0, sizeof(struct group));
    }

    /* We call conf_set_logging() again after moving into background, but it's called here
       to report on errors. */
    conf_set_logging();

    /* Set global options */
    task_timeout = atou(conf_get(&Conf, "timeout", NULL));

    axfr_enabled = GETBOOL(conf_get(&Conf, "allow-axfr", NULL));
    Verbose(_("AXFR is %senabled"), (axfr_enabled)?"":_("not "));

    tcp_enabled = GETBOOL(conf_get(&Conf, "allow-tcp", NULL));
    Verbose(_("TCP ports are %senabled"), (tcp_enabled)?"":_("not "));

    dns_update_enabled = GETBOOL(conf_get(&Conf, "allow-update", NULL));
    Verbose(_("DNS UPDATE is %senabled"), (dns_update_enabled)?"":_("not "));

    mydns_soa_use_active = GETBOOL(conf_get(&Conf, "use-soa-active", NULL));
    mydns_rr_use_active = GETBOOL(conf_get(&Conf, "use-rr-active", NULL));

    dns_notify_enabled = dns_update_enabled && GETBOOL(conf_get(&Conf, "notify-enabled", NULL));
    Verbose(_("DNS NOTIFY is %senabled"), (dns_notify_enabled)?"":_("not "));
    notify_timeout = atou(conf_get(&Conf, "notify-timeout", NULL));
    notify_retries = atou(conf_get(&Conf, "notify-retries", NULL));
    notify_algorithm = conf_get(&Conf, "notify-algorithm", NULL);

    dns_ixfr_enabled = GETBOOL(conf_get(&Conf, "ixfr-enabled", NULL));
    Verbose(_("DNS IXFR is %senabled"), (dns_ixfr_enabled)?"":_("not "));
    ixfr_gc_enabled = GETBOOL(conf_get(&Conf, "ixfr-gc-enabled", NULL));
    ixfr_gc_interval = atou(conf_get(&Conf, "ixfr-gc-interval", NULL));
    ixfr_gc_delay = atou(conf_get(&Conf, "ixfr-gc-delay", NULL));

    mydns_rr_extended_data = GETBOOL(conf_get(&Conf, "extended-data-support", NULL));

    mydns_dbengine = conf_get(&Conf, "dbengine", NULL);

    wildcard_recursion = atoi(conf_get(&Conf, "wildcard-recursion", NULL));

    ignore_minimum = GETBOOL(conf_get(&Conf, "ignore-minimum", NULL));

    /* Set table names if provided */
    mydns_set_soa_table_name(conf_get(&Conf, "soa-table", NULL));
    mydns_set_rr_table_name(conf_get(&Conf, "rr-table", NULL));

    /* Set additional where clauses if provided */
    mydns_set_soa_where_clause(conf_get(&Conf, "soa-where", NULL));
    mydns_set_rr_where_clause(conf_get(&Conf, "rr-where", NULL));

    /* Set recursive server if specified */
    conf_set_recursive();

#ifdef DN_COLUMN_NAMES
    dn_default_ns = conf_get(&Conf, "default-ns", NULL);
#endif
}