Revision 405bffe2 lib/backend.py

b/lib/backend.py
3582 3582
  hyper.PowercycleNode()
3583 3583

  
3584 3584

  
3585
def _VerifyRemoteCommandName(cmd):
3585
def _VerifyRestrictedCmdName(cmd):
3586 3586
  """Verifies a remote command name.
3587 3587

  
3588 3588
  @type cmd: string
......
3604 3604
  return (True, None)
3605 3605

  
3606 3606

  
3607
def _CommonRemoteCommandCheck(path, owner):
3607
def _CommonRestrictedCmdCheck(path, owner):
3608 3608
  """Common checks for remote command file system directories and files.
3609 3609

  
3610 3610
  @type path: string
......
3634 3634
  return (True, st)
3635 3635

  
3636 3636

  
3637
def _VerifyRemoteCommandDirectory(path, _owner=None):
3637
def _VerifyRestrictedCmdDirectory(path, _owner=None):
3638 3638
  """Verifies remote command directory.
3639 3639

  
3640 3640
  @type path: string
......
3644 3644
    element is an error message string, otherwise it's C{None}
3645 3645

  
3646 3646
  """
3647
  (status, value) = _CommonRemoteCommandCheck(path, _owner)
3647
  (status, value) = _CommonRestrictedCmdCheck(path, _owner)
3648 3648

  
3649 3649
  if not status:
3650 3650
    return (False, value)
......
3655 3655
  return (True, None)
3656 3656

  
3657 3657

  
3658
def _VerifyRemoteCommand(path, cmd, _owner=None):
3658
def _VerifyRestrictedCmd(path, cmd, _owner=None):
3659 3659
  """Verifies a whole remote command and returns its executable filename.
3660 3660

  
3661 3661
  @type path: string
......
3670 3670
  """
3671 3671
  executable = utils.PathJoin(path, cmd)
3672 3672

  
3673
  (status, msg) = _CommonRemoteCommandCheck(executable, _owner)
3673
  (status, msg) = _CommonRestrictedCmdCheck(executable, _owner)
3674 3674

  
3675 3675
  if not status:
3676 3676
    return (False, msg)
......
3681 3681
  return (True, executable)
3682 3682

  
3683 3683

  
3684
def _PrepareRemoteCommand(path, cmd,
3685
                          _verify_dir=_VerifyRemoteCommandDirectory,
3686
                          _verify_name=_VerifyRemoteCommandName,
3687
                          _verify_cmd=_VerifyRemoteCommand):
3684
def _PrepareRestrictedCmd(path, cmd,
3685
                          _verify_dir=_VerifyRestrictedCmdDirectory,
3686
                          _verify_name=_VerifyRestrictedCmdName,
3687
                          _verify_cmd=_VerifyRestrictedCmd):
3688 3688
  """Performs a number of tests on a remote command.
3689 3689

  
3690 3690
  @type path: string
3691 3691
  @param path: Directory containing remote commands
3692 3692
  @type cmd: string
3693 3693
  @param cmd: Command name
3694
  @return: Same as L{_VerifyRemoteCommand}
3694
  @return: Same as L{_VerifyRestrictedCmd}
3695 3695

  
3696 3696
  """
3697 3697
  # Verify the directory first
......
3712 3712
                     _lock_file=pathutils.RESTRICTED_COMMANDS_LOCK_FILE,
3713 3713
                     _path=pathutils.RESTRICTED_COMMANDS_DIR,
3714 3714
                     _sleep_fn=time.sleep,
3715
                     _prepare_fn=_PrepareRemoteCommand,
3715
                     _prepare_fn=_PrepareRestrictedCmd,
3716 3716
                     _runcmd_fn=utils.RunCmd,
3717 3717
                     _enabled=constants.ENABLE_RESTRICTED_COMMANDS):
3718 3718
  """Executes a remote command after performing strict tests.

Also available in: Unified diff