iprop: Fix default dbname choice on initial prop

If a DB does not already exist, ipropd-slave will use the compiled
default, which is not necessarily what is desired or configured in
`[kdc]`.

This change makes `hdb_default_db()` return the first dbanme in the
`[kdc]` configuration, falling back on `HDB_DEFAULT_DB`.

Also, this adds a `--database` option to `ipropd-slave`.
This commit is contained in:
Nicolas Williams
2021-05-03 15:00:36 -05:00
parent e609e61f21
commit 0c1cd18e03
3 changed files with 26 additions and 1 deletions

View File

@@ -271,5 +271,21 @@ hdb_db_dir(krb5_context context)
const char *
hdb_default_db(krb5_context context)
{
return HDB_DEFAULT_DB;
static char *default_hdb = NULL;
struct hdb_dbinfo *dbinfo = NULL;
struct hdb_dbinfo *d = NULL;
const char *s;
if (default_hdb)
return default_hdb;
(void) hdb_get_dbinfo(context, &dbinfo);
while ((d = hdb_dbinfo_get_next(dbinfo, d)) != NULL) {
if ((s = hdb_dbinfo_get_dbname(context, d)) &&
(default_hdb = strdup(s)))
break;
}
hdb_free_dbinfo(context, &dbinfo);
return default_hdb ? default_hdb : HDB_DEFAULT_DB;
}