equal
deleted
inserted
replaced
687 def register(func): |
687 def register(func): |
688 commands[name] = (func, args) |
688 commands[name] = (func, args) |
689 return func |
689 return func |
690 return register |
690 return register |
691 |
691 |
|
692 # TODO define a more appropriate permissions type to use for this. |
|
693 permissions['batch'] = 'pull' |
692 @wireprotocommand('batch', 'cmds *') |
694 @wireprotocommand('batch', 'cmds *') |
693 def batch(repo, proto, cmds, others): |
695 def batch(repo, proto, cmds, others): |
694 repo = repo.filtered("served") |
696 repo = repo.filtered("served") |
695 res = [] |
697 res = [] |
696 for pair in cmds.split(';'): |
698 for pair in cmds.split(';'): |
699 for a in args.split(','): |
701 for a in args.split(','): |
700 if a: |
702 if a: |
701 n, v = a.split('=') |
703 n, v = a.split('=') |
702 vals[unescapearg(n)] = unescapearg(v) |
704 vals[unescapearg(n)] = unescapearg(v) |
703 func, spec = commands[op] |
705 func, spec = commands[op] |
|
706 |
|
707 # If the protocol supports permissions checking, perform that |
|
708 # checking on each batched command. |
|
709 # TODO formalize permission checking as part of protocol interface. |
|
710 if util.safehasattr(proto, 'checkperm'): |
|
711 # Assume commands with no defined permissions are writes / for |
|
712 # pushes. This is the safest from a security perspective because |
|
713 # it doesn't allow commands with undefined semantics from |
|
714 # bypassing permissions checks. |
|
715 proto.checkperm(permissions.get(op, 'push')) |
|
716 |
704 if spec: |
717 if spec: |
705 keys = spec.split() |
718 keys = spec.split() |
706 data = {} |
719 data = {} |
707 for k in keys: |
720 for k in keys: |
708 if k == '*': |
721 if k == '*': |