More fallow/fdeny fixes

- Always apply host-based allows/denies even in var.ACCOUNTS_ONLY is set
- Fix display of mixed-mode allows/denies for a particular user
- Make -acc and -host switches operate more intelligently on both the
  bare command as well as when given an argument
This commit is contained in:
skizzerz 2015-10-18 20:56:27 -05:00
parent db0823bb37
commit 26e7acc8f8
2 changed files with 13 additions and 10 deletions

View File

@ -145,7 +145,7 @@ class cmd:
adminlog(chan, rawnick, self.name, rest) adminlog(chan, rawnick, self.name, rest)
return self.func(*largs) return self.func(*largs)
if not var.ACCOUNTS_ONLY and host: if host:
for pattern in var.DENY: for pattern in var.DENY:
if var.match_hostmask(pattern, nick, ident, host): if var.match_hostmask(pattern, nick, ident, host):
for command in self.cmds: for command in self.cmds:

View File

@ -7399,18 +7399,18 @@ def allow_deny(cli, nick, chan, rest, mode):
variable = var.DENY_ACCOUNTS variable = var.DENY_ACCOUNTS
noaccvar = var.DENY noaccvar = var.DENY
if len(data) == 1: if len(data) == 1:
cmds = [] cmds = set()
if acc in variable: if acc in variable:
cmds.extend(variable[acc]) cmds |= set(variable[acc])
if hostmask: if hostmask and not opts["acc"]:
for mask in noaccvar: for mask in noaccvar:
if var.match_hostmask(mask, user, ident, host): if var.match_hostmask(mask, user, ident, host):
cmds.extend(noaccvar[mask]) cmds |= set(noaccvar[mask])
if cmds: if cmds:
msg = "\u0002{0}\u0002 (Account: {1}) is {2} the following {3}commands: {4}.".format( msg = "\u0002{0}\u0002 (Account: {1}) is {2} the following {3}commands: {4}.".format(
data[0], acc, "allowed" if mode == "allow" else "denied", "special " if mode == "allow" else "", ", ".join(variable[acc])) data[0], acc, "allowed" if mode == "allow" else "denied", "special " if mode == "allow" else "", ", ".join(cmds))
else: else:
msg = "\u0002{0}\u0002 (Account: {1}) is not {2} commands.".format(data[0], acc, "allowed any special" if mode == "allow" else "denied any") msg = "\u0002{0}\u0002 (Account: {1}) is not {2} commands.".format(data[0], acc, "allowed any special" if mode == "allow" else "denied any")
else: else:
@ -7517,25 +7517,28 @@ def allow_deny(cli, nick, chan, rest, mode):
else: else:
users_to_cmds = {} users_to_cmds = {}
if not var.DISABLE_ACCOUNTS: if not var.DISABLE_ACCOUNTS and not opts["host"]:
if mode == "allow": if mode == "allow":
variable = var.ALLOW_ACCOUNTS variable = var.ALLOW_ACCOUNTS
noaccvar = var.ALLOW
else: else:
variable = var.DENY_ACCOUNTS variable = var.DENY_ACCOUNTS
noaccvar = var.DENY
if variable: if variable:
for acc, varied in variable.items(): for acc, varied in variable.items():
if var.ACCOUNTS_ONLY and not opts["host"]: if opts["acc"] or (var.ACCOUNTS_ONLY and not noaccvar):
users_to_cmds[acc] = sorted(varied, key=str.lower) users_to_cmds[acc] = sorted(varied, key=str.lower)
else: else:
users_to_cmds[acc+" (Account)"] = sorted(varied, key=str.lower) users_to_cmds[acc+" (Account)"] = sorted(varied, key=str.lower)
if not var.ACCOUNTS_ONLY or opts["host"]: if not opts["acc"]:
if mode == "allow": if mode == "allow":
variable = var.ALLOW variable = var.ALLOW
else: else:
variable = var.DENY variable = var.DENY
if variable: if variable:
for hostmask, varied in variable.items(): for hostmask, varied in variable.items():
if var.DISABLE_ACCOUNTS: if var.DISABLE_ACCOUNTS or opts["host"]:
users_to_cmds[hostmask] = sorted(varied, key=str.lower) users_to_cmds[hostmask] = sorted(varied, key=str.lower)
else: else:
users_to_cmds[hostmask+" (Host)"] = sorted(varied, key=str.lower) users_to_cmds[hostmask+" (Host)"] = sorted(varied, key=str.lower)