Sha256: 5532576203f9785d4680d9bb463cde0edd5256991a07556b21d7bafc1bc2dca8

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

#!/usr/bin/env ruby

#--
#   Copyright (C) 2009 BrownBeagle
#   Copyright (C) 2008 Darcy Laycock <sutto@sutto.net>
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#++


REAL_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__

# Require the proper gitauth file.
require File.expand_path(File.join(File.dirname(REAL_FILE), "..", "lib", "gitauth"))

GitAuth.setup!

# Gitorious does it so I should too!
File.umask(0022)

user_name = ARGV[0]
command   = ENV["SSH_ORIGINAL_COMMAND"]

GitAuth::Client.start!(user_name, command) do |c|
  
  c.on(:invalid_user) do |c|
    c.exit_with_error "An invalid user / key was used. Please ensure it is setup with GitAuth"
  end
  
  c.on(:invalid_command) do |c|
    if c.user.shell_accessible?
      exec(ENV["SHELL"])
    else
      c.exit_with_error "SSH_ORIGINAL_COMMAND is needed, mmmkay?"
    end
  end
  
  c.on(:invalid_repository) do |c|
   c.exit_with_error "Ze repository you specified does not exist."
  end
  
  c.on(:bad_command) do |c|
    c.exit_with_error "A Bad Command Has Failed Ye, Thou Shalt Not Continue."
  end

  c.on(:access_denied) do |c|
    c.exit_with_error "These are not the droids you are looking for"
  end

  c.on(:fatal_error) do |c|
    c.exit_with_error "Holy crap, we've imploded cap'n!"
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
brownbeagle-gitauth-0.0.1 bin/gitauth-shell