summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2015-08-21 14:30:58 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2015-08-21 14:30:58 +0200
commitbd78e1a2e914409ed51dbbb80794ddcc1cc67a16 (patch)
tree7c9aee678d35f2558c28cac337b669f95611ac09 /lib
parent677bf6615f81ac0f681183a63e9d6d4fbdc5b1c6 (diff)
parentea9b8fe5f16b26b5793f7d27500b4ff2633b5656 (diff)
downloadgitlab-ce-bd78e1a2e914409ed51dbbb80794ddcc1cc67a16.tar.gz
Merge pull request #9535 from bbodenmiller/patch-3
check upload dir permissions
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/gitlab/check.rake52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index 80ee572938d..60aa50e8751 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -22,6 +22,7 @@ namespace :gitlab do
check_gitlab_config_not_outdated
check_log_writable
check_tmp_writable
+ check_uploads
check_init_script_exists
check_init_script_up_to_date
check_projects_have_namespace
@@ -276,6 +277,57 @@ namespace :gitlab do
fix_and_rerun
end
end
+
+ def check_uploads
+ print "Uploads directory setup correctly? ... "
+
+ unless File.directory?(Rails.root.join('public/uploads'))
+ puts "no".red
+ try_fixing_it(
+ "sudo -u #{gitlab_user} mkdir -m 750 #{Rails.root}/public/uploads"
+ )
+ for_more_information(
+ see_installation_guide_section "GitLab"
+ )
+ fix_and_rerun
+ return
+ end
+
+ upload_path = File.realpath(Rails.root.join('public/uploads'))
+ upload_path_tmp = File.join(upload_path, 'tmp')
+
+ if File.stat(upload_path).mode == 040750
+ unless Dir.exists?(upload_path_tmp)
+ puts 'skipped (no tmp uploads folder yet)'.magenta
+ return
+ end
+
+ # if tmp upload dir has incorrect permissions, assume others do as well
+ if File.stat(upload_path_tmp).mode == 040755 && File.owned?(upload_path_tmp) # verify drwxr-xr-x permissions
+ puts "yes".green
+ else
+ puts "no".red
+ try_fixing_it(
+ "sudo chown -R #{gitlab_user} #{upload_path}",
+ "sudo find #{upload_path} -type f -exec chmod 0644 {} \\;",
+ "sudo find #{upload_path} -type d -not -path #{upload_path} -exec chmod 0755 {} \\;"
+ )
+ for_more_information(
+ see_installation_guide_section "GitLab"
+ )
+ fix_and_rerun
+ end
+ else
+ puts "no".red
+ try_fixing_it(
+ "sudo chmod 0750 #{upload_path}",
+ )
+ for_more_information(
+ see_installation_guide_section "GitLab"
+ )
+ fix_and_rerun
+ end
+ end
def check_redis_version
print "Redis version >= 2.0.0? ... "