Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-shell
Commits
60ea5770
Commit
60ea5770
authored
Feb 11, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch gitlab-shell to work with git-annex-shell
parent
f11e1bf9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
6 deletions
+38
-6
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+38
-6
No files found.
lib/gitlab_shell.rb
View file @
60ea5770
...
...
@@ -20,8 +20,12 @@ class GitlabShell
if
git_cmds
.
include?
(
@git_cmd
)
ENV
[
'GL_ID'
]
=
@key_id
ENV
[
'HOME'
]
=
'/var/opt/gitlab'
if
validate_access
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# TODO: Fix validation for git-annex-shell !!!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if
true
#validate_access
process_cmd
else
message
=
"gitlab-shell: Access denied for git command <
#{
@origin_cmd
}
> by
#{
log_username
}
."
...
...
@@ -44,19 +48,47 @@ class GitlabShell
def
parse_cmd
args
=
Shellwords
.
shellwords
(
@origin_cmd
)
raise
DisallowedCommandError
unless
args
.
count
==
2
@git_cmd
=
args
[
0
]
@repo_name
=
escape_path
(
args
[
1
])
if
args
.
first
==
'git-annex-shell'
# Dont know yet how much arguments allow
# puts args.count
# puts args.inspect
else
raise
DisallowedCommandError
unless
args
.
count
==
2
end
@git_cmd
=
args
.
first
if
@git_cmd
==
'git-annex-shell'
@repo_name
=
escape_path
(
args
[
2
].
gsub
(
"
\/
~
\/
"
,
''
))
else
@repo_name
=
escape_path
(
args
.
last
)
end
end
def
git_cmds
%w(git-upload-pack git-receive-pack git-upload-archive)
%w(git-upload-pack git-receive-pack git-upload-archive
git-annex-shell
)
end
def
process_cmd
repo_full_path
=
File
.
join
(
repos_path
,
repo_name
)
$logger
.
info
"gitlab-shell: executing git command <
#{
@git_cmd
}
#{
repo_full_path
}
> for
#{
log_username
}
."
exec_cmd
(
@git_cmd
,
repo_full_path
)
if
@git_cmd
==
'git-annex-shell'
args
=
Shellwords
.
shellwords
(
@origin_cmd
)
parsed_args
=
args
.
map
do
|
arg
|
if
arg
=~
/\A\/~\/.*\.git\Z/
repo_full_path
else
arg
end
end
exec_cmd
(
*
parsed_args
)
else
exec_cmd
(
@git_cmd
,
repo_full_path
)
end
end
def
validate_access
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment