From: Garming Sam Date: Mon, 11 Jul 2016 03:14:47 +0000 (+1200) Subject: dbcheck: change argument to specify a partial --yes X-Git-Tag: tdb-1.3.10~376 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5361fc68436b4dcd8d1b7174daee27c78d3c7ade;p=thirdparty%2Fsamba.git dbcheck: change argument to specify a partial --yes Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py index ded4dc0a96c..f0c2217f683 100644 --- a/python/samba/dbchecker.py +++ b/python/samba/dbchecker.py @@ -280,14 +280,14 @@ systemFlags: -1946157056%s""" % (dn, guid_suffix), '''confirm a change with support for "all" ''' if not self.fix: return False - if self.quiet: - return self.yes if getattr(self, all_attr) == 'NONE': return False if getattr(self, all_attr) == 'ALL': forced = True else: forced = self.yes + if self.quiet: + return forced c = common.confirm(msg, forced=forced, allow_all=True) if c == 'ALL': setattr(self, all_attr, 'ALL') diff --git a/python/samba/netcmd/dbcheck.py b/python/samba/netcmd/dbcheck.py index 4cc0631bf76..2217366cc8d 100644 --- a/python/samba/netcmd/dbcheck.py +++ b/python/samba/netcmd/dbcheck.py @@ -38,6 +38,21 @@ class cmd_dbcheck(Command): "credopts": options.CredentialsOptionsDouble, } + def process_yes(option, opt, value, parser): + assert value is None + done = 0 + rargs = parser.rargs + if rargs: + arg = rargs[0] + if ((arg[:2] == "--" and len(arg) > 2) or + (arg[:1] == "-" and len(arg) > 1 and arg[1] != "-")): + setattr(parser.values, "yes", True) + else: + setattr(parser.values, "yes_rules", arg.split()) + del rargs[0] + else: + setattr(parser.values, "yes", True) + takes_args = ["DN?"] takes_options = [ @@ -45,7 +60,7 @@ class cmd_dbcheck(Command): help="Pass search scope that builds DN list. Options: SUB, ONE, BASE"), Option("--fix", dest="fix", default=False, action='store_true', help='Fix any errors found'), - Option("--yes", dest="yes", default=False, action='store_true', + Option("--yes", action='callback', callback=process_yes, help="don't confirm changes, just do them all as a single transaction"), Option("--cross-ncs", dest="cross_ncs", default=False, action='store_true', help="cross naming context boundaries"), @@ -65,7 +80,7 @@ class cmd_dbcheck(Command): cross_ncs=False, quiet=False, scope="SUB", credopts=None, sambaopts=None, versionopts=None, attrs=None, reindex=False, force_modules=False, - reset_well_known_acls=False): + reset_well_known_acls=False, yes_rules=[]): lp = sambaopts.get_loadparm() @@ -119,6 +134,12 @@ class cmd_dbcheck(Command): fix=fix, yes=yes, quiet=quiet, in_transaction=started_transaction, reset_well_known_acls=reset_well_known_acls) + for option in yes_rules: + if hasattr(chk, option): + setattr(chk, option, 'ALL') + else: + raise CommandError("Invalid fix rule %s" % option) + if reindex: self.outf.write("Re-indexing...\n") error_count = 0