Sha256: 1b156c309a36562012f1fd8ea00a8ec6194e85a2d6ea7816dac4cfe99797e7f8
Contents?: true
Size: 961 Bytes
Versions: 1
Compression:
Stored size: 961 Bytes
Contents
require 'thor' module SSH ; module Allow class CLI < Thor desc "guard --rules | -r=<file> [--echo | -e]", "Guard against the SSH_ORIGINAL_COMMAND, using rules in the --rules file." method_option :rules, :type => :string, :aliases => '-r', :required => true, :default => File.expand_path("~/.ssh-rules"), :banner => "Path to rules file" method_option :echo, :type => :boolean, :default => false, :aliases => '-e', :banner => "Echo the SSH_ORIGINAL_COMMAND." def guard rule_set.read(options[:rules]) puts command if options[:echo] command.allowed?(rule_set.rules) ? command.run : fail end private def rule_set @rule_set ||= SSH::Allow::RuleSet.new end def command @command ||= SSH::Allow::Command.new(ENV['SSH_ORIGINAL_COMMAND']) end def fail raise Thor::Error, "Remote Command Not Allowed: #{command}" end end end ; end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ssh-allow-0.6.0 | lib/ssh/allow/cli.rb |