From 2b16c3f29f35ca9680a51aa9a4dfcd8dbed25f6d Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 5 Apr 2013 18:03:45 +0400 Subject: [PATCH 1/4] #81: use "rm -rf" for removing dir --- app/models/key_pair.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/key_pair.rb b/app/models/key_pair.rb index 54f306116..6cdfb076d 100644 --- a/app/models/key_pair.rb +++ b/app/models/key_pair.rb @@ -47,7 +47,7 @@ class KeyPair < ActiveRecord::Base end ensure # remove the directory. - FileUtils.remove_entry_secure dir + system "rm -rf #{dir}" end end From d47eaa7b943169158876162972c998a777a6dbdb Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 5 Apr 2013 18:08:37 +0400 Subject: [PATCH 2/4] #81: use rm_rf --- app/models/key_pair.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/key_pair.rb b/app/models/key_pair.rb index 6cdfb076d..439dff065 100644 --- a/app/models/key_pair.rb +++ b/app/models/key_pair.rb @@ -47,7 +47,7 @@ class KeyPair < ActiveRecord::Base end ensure # remove the directory. - system "rm -rf #{dir}" + FileUtils.rm_rf dir end end From b17ae312e8a95c1769b38092d23340a8b89c467b Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 8 Apr 2013 18:46:41 +0400 Subject: [PATCH 3/4] #81: rollback some changes, update code according to Vladimir's comments --- app/models/key_pair.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/key_pair.rb b/app/models/key_pair.rb index 439dff065..8bbeac841 100644 --- a/app/models/key_pair.rb +++ b/app/models/key_pair.rb @@ -21,7 +21,9 @@ class KeyPair < ActiveRecord::Base protected def check_keys - dir = Dir.mktmpdir('keys-', "#{APP_CONFIG['root_path']}/tmp") + tmp = "#{APP_CONFIG['root_path']}/tmp" + system "sudo chown rosa:rosa #{tmp} && chmod 1777 #{tmp}" + dir = Dir.mktmpdir('keys-', tmp) begin %w(pubring secring).each do |kind| filename = "#{dir}/#{kind}" @@ -47,7 +49,7 @@ class KeyPair < ActiveRecord::Base end ensure # remove the directory. - FileUtils.rm_rf dir + FileUtils.remove_entry_secure dir end end From 6c94b0766cd8a40c513a06fdcb94da0579927740 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 8 Apr 2013 19:14:36 +0400 Subject: [PATCH 4/4] #81: small refactoring --- app/models/key_pair.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/key_pair.rb b/app/models/key_pair.rb index 8bbeac841..ca8a3fe8c 100644 --- a/app/models/key_pair.rb +++ b/app/models/key_pair.rb @@ -22,7 +22,7 @@ class KeyPair < ActiveRecord::Base def check_keys tmp = "#{APP_CONFIG['root_path']}/tmp" - system "sudo chown rosa:rosa #{tmp} && chmod 1777 #{tmp}" + system "sudo chown `whoami` #{tmp} && chmod 1777 #{tmp}" dir = Dir.mktmpdir('keys-', tmp) begin %w(pubring secring).each do |kind|