Skip to content

Commit 2c24a71

Browse files
committed
Allow repair hook functionality to work with older versions of sudo.
1 parent 0740c23 commit 2c24a71

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/git_adapter_hooks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def self.install_hook(hook_name)
147147
def self.get_local_config_map
148148
local_config_map=Hash.new{|hash, key| hash[key] = {}} # default -- empty hash
149149

150-
lines = %x[#{GitHosting.git_user_runner} 'find #{GitHosting.repository_base} -type d -name "*.git" -prune -print -execdir git config -f {}/config --get-regexp hooks.redmine_gitolite ";"'].chomp.split("\n")
150+
lines = %x[#{GitHosting.git_user_runner} 'find #{GitHosting.repository_base} -type d -name "*.git" -prune -print -exec git config -f {}/config --get-regexp hooks.redmine_gitolite \\;'].chomp.split("\n")
151151
filesplit = /(\.\/)*(#{GitHosting.repository_base}.*?[^\/]+\.git)/
152152
cur_repo_path = nil
153153
lines.each do |nextline|

lib/git_hosting.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ def self.update_git_exec
316316
f.puts 'else'
317317
f.puts '{'
318318
f.puts ' $command =~ s/\\\\/\\\\\\\\/g;'
319+
# Previous line turns \; => \\;
320+
# If old sudo, turn \\; => "\\;" to protect ';' from loss as command separator during eval
321+
if sudo_version < sudo_version_switch
322+
f.puts ' $command =~ s/(\\\\\\\\;)/"$1"/g;'
323+
end
319324
f.puts ' $command =~ s/"/\\\\"/g;'
320325
f.puts ' exec("sudo -u ' + git_user + ' -i eval \"$command\"");'
321326
f.puts '}'

0 commit comments

Comments
 (0)