[PATCH: Domain backup and restore samba-tool commands] (with patch actually attached)

Jeremy Allison jra at samba.org
Thu Jun 21 00:47:36 UTC 2018


On Thu, Jun 21, 2018 at 12:11:27PM +1200, Aaron Haslett via samba-technical wrote:
> +	TALLOC_CTX *db_context = talloc_new(event_ctx);;

Needs check for NULL on talloc_new() fail.

> From 13ace68b4950c210146912142b0a86007c508052 Mon Sep 17 00:00:00 2001
> From: Aaron Haslett <aaronhaslett at catalyst.net.nz>
> Date: Tue, 1 May 2018 11:10:43 +1200
> Subject: [PATCH 02/12] tdb: adding readonly locks mode to tdbbackup tool
> 
> Signed-off-by: Aaron Haslett <aaronhaslett at catalyst.net.nz>
> ---
>  lib/tdb/tools/tdbbackup.c | 31 ++++++++++++++++++++++++-------
>  1 file changed, 24 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/tdb/tools/tdbbackup.c b/lib/tdb/tools/tdbbackup.c
> index eb33e25..cfd2820 100644
> --- a/lib/tdb/tools/tdbbackup.c
> +++ b/lib/tdb/tools/tdbbackup.c
> @@ -105,7 +105,7 @@ static int test_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
>    this function is also used for restore
>  */
>  static int backup_tdb(const char *old_name, const char *new_name,
> -		      int hash_size, int nolock)
> +		      int hash_size, int nolock, int readonly)
>  {
>  	TDB_CONTEXT *tdb;
>  	TDB_CONTEXT *tdb_new;
> @@ -145,8 +145,17 @@ static int backup_tdb(const char *old_name, const char *new_name,
>  		return 1;
>  	}
>  
> -	if (tdb_transaction_start(tdb) != 0) {
> -		printf("Failed to start transaction on old tdb\n");
> +	if (readonly){
> +		if(tdb_lockall_read(tdb) != 0){
> +			printf("Failed to readonly lock on old tdb\n");
> +			tdb_close(tdb);
> +			tdb_close(tdb_new);
> +			unlink(tmp_name);

Error checks please !

> diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c
> index e7e908f..6aa8414 100644
> --- a/source4/param/pyparam.c
> +++ b/source4/param/pyparam.c
> @@ -445,7 +445,24 @@ static PyGetSetDef py_lp_ctx_getset[] = {
>  
>  static PyObject *py_lp_ctx_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
>  {
> -	return pytalloc_reference(type, loadparm_init_global(false));
> +	const char *kwnames[] = {"_filename_for_non_global_lp", NULL};
> +	PyObject *lp_ctx;
> +	const char *conf_filename = NULL;
> +	struct loadparm_context *ctx;
> +
> +	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s",
> +	    discard_const_p(char *, kwnames), &conf_filename)){
> +		return NULL;
> +	}
> +	if (conf_filename != NULL){
> +		ctx = loadparm_init(NULL);

ctx == Null check here.

> +		lp_ctx = pytalloc_reference(type, ctx);

And here for lp_ctx.

Jeremy.



More information about the samba-technical mailing list