attr-sql: Use namespace for attr-sql config, with fallback
This commit is contained in:
@@ -61,7 +61,7 @@ static bool open_database(private_attr_sql_plugin_t *this,
|
|||||||
char *uri;
|
char *uri;
|
||||||
|
|
||||||
uri = lib->settings->get_str(lib->settings,
|
uri = lib->settings->get_str(lib->settings,
|
||||||
"libhydra.plugins.attr-sql.database", NULL);
|
"%s.plugins.attr-sql.database", NULL, lib->ns);
|
||||||
if (!uri)
|
if (!uri)
|
||||||
{
|
{
|
||||||
DBG1(DBG_CFG, "attr-sql plugin: database URI not set");
|
DBG1(DBG_CFG, "attr-sql plugin: database URI not set");
|
||||||
@@ -122,6 +122,8 @@ plugin_t *attr_sql_plugin_create()
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
lib->settings->add_fallback(lib->settings, "%s.plugins.attr-sql",
|
||||||
|
"libhydra.plugins.attr-sql", lib->ns);
|
||||||
|
|
||||||
return &this->public.plugin;
|
return &this->public.plugin;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ sql_attribute_t *sql_attribute_create(database_t *db)
|
|||||||
},
|
},
|
||||||
.db = db,
|
.db = db,
|
||||||
.history = lib->settings->get_bool(lib->settings,
|
.history = lib->settings->get_bool(lib->settings,
|
||||||
"libhydra.plugins.attr-sql.lease_history", TRUE),
|
"%s.plugins.attr-sql.lease_history", TRUE, lib->ns),
|
||||||
);
|
);
|
||||||
|
|
||||||
/* close any "online" leases in the case we crashed */
|
/* close any "online" leases in the case we crashed */
|
||||||
|
|||||||
+8
-3
@@ -1227,11 +1227,16 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
exit(SS_RC_INITIALIZATION_FAILED);
|
exit(SS_RC_INITIALIZATION_FAILED);
|
||||||
}
|
}
|
||||||
|
/* TODO: make database URI or setting key configurable via command line */
|
||||||
uri = lib->settings->get_str(lib->settings, "libhydra.plugins.attr-sql.database", NULL);
|
uri = lib->settings->get_str(lib->settings,
|
||||||
|
"pool.database",
|
||||||
|
lib->settings->get_str(lib->settings,
|
||||||
|
"charon.plugins.attr-sql.database",
|
||||||
|
lib->settings->get_str(lib->settings,
|
||||||
|
"libhydra.plugins.attr-sql.database", NULL)));
|
||||||
if (!uri)
|
if (!uri)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "database URI libhydra.plugins.attr-sql.database not set.\n");
|
fprintf(stderr, "database URI pool.database not set.\n");
|
||||||
exit(SS_RC_INITIALIZATION_FAILED);
|
exit(SS_RC_INITIALIZATION_FAILED);
|
||||||
}
|
}
|
||||||
db = lib->db->create(lib->db, uri);
|
db = lib->db->create(lib->db, uri);
|
||||||
|
|||||||
Reference in New Issue
Block a user