[Groonga-commit] droonga/droonga-engine at 4a06b87 [master] Show error if the current user don't have a permission to write configuration files

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Sep 18 16:10:36 JST 2014


YUKI Hiroshi	2014-09-18 16:10:36 +0900 (Thu, 18 Sep 2014)

  New Revision: 4a06b87dc003ae52f697699c294c75c4ec7e2cda
  https://github.com/droonga/droonga-engine/commit/4a06b87dc003ae52f697699c294c75c4ec7e2cda

  Message:
    Show error if the current user don't have a permission to write configuration files

  Modified files:
    bin/droonga-engine-configure

  Modified: bin/droonga-engine-configure (+17 -0)
===================================================================
--- bin/droonga-engine-configure    2014-09-18 16:02:45 +0900 (ff4cac7)
+++ bin/droonga-engine-configure    2014-09-18 16:10:36 +0900 (52d740e)
@@ -48,6 +48,21 @@ configuration.add_command_line_options(parser)
 parser.parse!(ARGV)
 
 
+def ensure_have_write_permission
+  test_file = Droonga::Path.base + "#{Time.now.to_i}.test"
+  begin
+    FileUtils.touch(test_file.to_s)
+  rescue Errno::EACCES => error
+  end
+  unless test_file.exist?
+    puts("You have no permission to write files under " +
+           "<#{Droonga::Path.base.to_s}>.")
+    puts("Try again with right permission.")
+    exit(false)
+  end
+  FileUtils.rm_f(test_file.to_s)
+end
+
 def installed_as_service?
   succeeded = system("service", "droonga-engine", "status",
                      :out => "/dev/null",
@@ -161,6 +176,8 @@ end
 
 Droonga::Path.base = service_base_directory if installed_as_service?
 
+ensure_have_write_permission
+
 
 data_files = [
   Droonga::Path.databases,
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index