[PATCH: Domain backup and restore samba-tool commands] (with patch actually attached) (version 2)
Aaron Haslett
aaronhaslett at catalyst.net.nz
Fri Jun 22 01:08:08 UTC 2018
This version fixes error checking and code formatting issues raised by
Stefan and Jeremy.
On 22/06/18 02:33, Stefan Metzmacher via samba-technical wrote:
> Hi Aaron,
>
> there're a couple of places where you add '){' without a whitespace in
> between, can you fix change that?
>
> Thanks!
> metze
>
> Am 21.06.2018 um 02:47 schrieb Jeremy Allison via samba-technical:
>> 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.
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: backup_and_restore.patch
Type: text/x-patch
Size: 80103 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180622/53d23db6/backup_and_restore.bin>
More information about the samba-technical
mailing list