return 0;
}
-static const char* net_idmap_dbfile(struct net_context *c,
- struct net_idmap_ctx *ctx)
+/* returns db path for idmap backend alloced on talloc_tos */
+static char *net_idmap_dbfile(struct net_context *c,
+ struct net_idmap_ctx *ctx)
{
- const char* dbfile = NULL;
+ char *dbfile = NULL;
const char *backend = NULL;
backend = lp_idmap_default_backend();
struct db_context **db)
{
bool ret = false;
- const char *dbfile;
+ char *dbfile = NULL;
struct net_idmap_ctx ctx = { .backend = AUTORID };
if (c == NULL) {
ret = true;
done:
+ talloc_free(dbfile);
return ret;
}
static int net_idmap_check(struct net_context *c, int argc, const char **argv)
{
- const char* dbfile;
+ char *dbfile;
struct check_options opts;
struct net_idmap_ctx ctx = { .backend = TDB };
+ int ret;
if ( argc > 1 || c->display_usage) {
d_printf("%s\n%s",
return c->display_usage ? 0 : -1;
}
- dbfile = (argc > 0) ? argv[0] : net_idmap_dbfile(c, &ctx);
+ if (argc > 0) {
+ dbfile = talloc_strdup(talloc_tos(), argv[0]);
+ } else {
+ dbfile = net_idmap_dbfile(c, &ctx);
+ }
if (dbfile == NULL) {
return -1;
}
if (ctx.backend != TDB) {
d_fprintf(stderr, _("Sorry, checking of non-TDB databases is "
"currently not supported\n"));
+ talloc_free(dbfile);
return -1;
}
.repair = c->opt_repair || c->opt_reboot,
};
- return net_idmap_check_db(dbfile, &opts);
+ ret = net_idmap_check_db(dbfile, &opts);
+ talloc_free(dbfile);
+ return ret;
}
/***********************************************************