1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
-- @@SHEBANG
-- -*- Lua -*-
-- gitano-auth
--
-- Git (with) Augmented network operations -- User authentication wrapper
--
-- Copyright 2012 Daniel Silverstone <dsilvers@digital-scurf.org>
--
--
-- @@GITANO_LUA_PATH
local gitano = require "gitano"
local gall = require "gall"
local luxio = require "luxio"
local sio = require "luxio.simple"
local sp = require "luxio.subprocess"
-- @@GITANO_BIN_PATH
-- @@GITANO_SHARE_PATH
-- @@GITANO_I18N_PATH
-- @@GITANO_PLUGIN_PATH
local start_log_level = gitano.log.get_level()
gitano.log.cap_level(gitano.log.level.INFO)
local transactionid = gitano.log.syslog.open()
local repo_root, user, keytag = ...
gitano.config.repo_path(repo_root)
local cmdline = luxio.getenv "SSH_ORIGINAL_COMMAND" or ""
if cmdline:match("^[ \t\n]*$") then
gitano.log.fatal(gitano.i18n.expand("ERROR_NO_COMMAND"))
end
local authorized, cmd, parsed_cmdline, config, env, repo =
gitano.auth.is_authorized(user, "ssh", cmdline, repo_root,
transactionid, start_log_level, keytag)
if authorized then
local exit, quiet = gitano.util.run_command(cmd, cmdline, parsed_cmdline,
user, config, env, repo)
if exit ~= 0 then
if not quiet then
gitano.log.critical(gitano.i18n.expand("ERROR_COMMAND_FAILED"))
end
luxio._exit(exit)
end
else
gitano.log.fatal(gitano.i18n.expand("ERROR_NOT_AUTHORISED"))
end
gitano.log.syslog.close()
return 0
|