s3:eventlogadm make a transaction for addsource
authorGregor Beck <gbeck@sernet.de>
Thu, 19 Apr 2012 11:32:26 +0000 (13:32 +0200)
committerAndreas Schneider <asn@samba.org>
Wed, 25 Apr 2012 12:23:03 +0000 (14:23 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
source3/utils/eventlogadm.c

index 745e0ce383777bbaf322749ed73524053c35b38e..8d8fa4a4d74b184418ff90a545bb2560e5817b86 100644 (file)
@@ -28,6 +28,7 @@
 #include "registry/reg_api.h"
 #include "registry/reg_init_basic.h"
 #include "registry/reg_util_token.h"
+#include "registry/reg_backend_db.h"
 #include "../libcli/registry/util_reg.h"
 
 extern int optind;
@@ -265,9 +266,21 @@ static int DoAddSourceCommand( int argc, char **argv, bool debugflag, char *exen
                printf("Can't open the registry: %s.\n", win_errstr(werr));
                return -1;
        }
+       werr = regdb_transaction_start();
+       if (!W_ERROR_IS_OK(werr)) {
+               printf("Can't start transaction on registry: %s.\n", win_errstr(werr));
+               return -1;
+       }
 
-       if ( !eventlog_add_source( argv[0], argv[1], argv[2] ) )
+       if ( !eventlog_add_source( argv[0], argv[1], argv[2] ) ) {
+               regdb_transaction_cancel();
                return -2;
+       }
+       werr = regdb_transaction_commit();
+       if (!W_ERROR_IS_OK(werr)) {
+               printf("Failed to commit transaction on registry: %s.\n", win_errstr(werr));
+               return -1;
+       }
        return 0;
 }