Skip to content

Commit

Permalink
lib/param: lpcfg_private_db_path()
Browse files Browse the repository at this point in the history
This wrapper avoids testing lpcfg_use_ntdb() everywhere.

Signed-off-by: Rusty Russell <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
rustyrussell authored and jrasamba committed Apr 12, 2013
1 parent 1cf46d2 commit ccfd929
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/param/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,21 @@ char *lpcfg_private_path(TALLOC_CTX* mem_ctx,
struct loadparm_context *lp_ctx,
const char *name);

/**
* @brief Returns an absolute path to a NTDB or TDB file in the Samba
* private directory.
*
* @param name File to find, relative to PRIVATEDIR, without .(n)tdb extension.
* Only provide fixed-string names which are supposed to change with "use ntdb"
* option.
*
* @retval Pointer to a talloc'ed string containing the full path, for
* use with dbwrap_local_open().
**/
char *lpcfg_private_db_path(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx,
const char *name);

/**
return a path in the smbd.tmp directory, where all temporary file
for smbd go. If NULL is passed for name then return the directory
Expand Down
27 changes: 27 additions & 0 deletions lib/param/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,33 @@ char *lpcfg_private_path(TALLOC_CTX* mem_ctx,
return fname;
}

/**
* @brief Returns an absolute path to a NTDB or TDB file in the Samba
* private directory.
*
* @param name File to find, relative to PRIVATEDIR, without .(n)tdb extension.
* Only provide fixed-string names which are supposed to change with "use ntdb"
* option.
*
* @retval Pointer to a talloc'ed string containing the full path, for
* use with dbwrap_local_open().
**/
char *lpcfg_private_db_path(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx,
const char *name)
{
const char *extension = ".tdb";

#ifndef DISABLE_NTDB
if (lpcfg_use_ntdb(lp_ctx)) {
extension = ".ntdb";
}
#endif

return talloc_asprintf(mem_ctx, "%s/%s%s",
lpcfg_private_dir(lp_ctx), name, extension);
}

/**
return a path in the smbd.tmp directory, where all temporary file
for smbd go. If NULL is passed for name then return the directory
Expand Down

0 comments on commit ccfd929

Please sign in to comment.