Commit 34bdabc6 authored by mh's avatar mh
Browse files

some cleanups

parent 6552f717
......@@ -62,9 +62,8 @@ def load_directories
end
# file name to pass the list of files to chown from the unprivileged find process to the mother process
@file_list = "/tmp/#{(0...32).map{65.+(rand(26)).chr}.join}"
def file_list
@file_list
@file_list ||= "/tmp/#{Process.pid}_#{(0...32).map{65.+(rand(26)).chr}.join('')}"
end
def adjust(path, permissions)
......@@ -74,8 +73,8 @@ def adjust(path, permissions)
cmd("find #{shellescape(path)} -user #{options['run_user']} -type d > #{file_list}")
cmd("find #{shellescape(path)} -user #{options['run_user']} -type f >> #{file_list}")
end
on_filelist(File.read(file_list),run_user_uid) do |path|
FileUtils.chown( options['sftp_user'], options['group'], path )
on_filelist(File.read(file_list),run_user_uid) do |p|
FileUtils.chown( options['sftp_user'], options['group'], p)
end
File.delete(file_list)
......
......@@ -10,7 +10,7 @@ end
# maps filenames to validated paths
def settings_files
@settings_files or settings_files_map_and_check!
@settings_files || settings_files_map_and_check!
end
def settings_files_map_and_check!
......@@ -60,6 +60,9 @@ def stringify(object)
end
end
# gives you the parsed content of
# a file, but only if all required keys
# are in.
def load_file(file, required_keys)
file_path = settings_files[file]
res = YAML.load_file(file_path) || {}
......
......@@ -36,7 +36,7 @@ def run_script
end
def perm_file
@perm_file ||= "/tmp/#{Process.pid}_#{(0...32).map{65.+(rand(26)).chr}.join}"
@perm_file ||= "/tmp/#{Process.pid}_#{(0...32).map{65.+(rand(26)).chr}.join('')}"
end
## script specific methods
......@@ -70,11 +70,11 @@ def reset_update_mode
# them writeable by the group
dirs = cmd("find #{shellescape(path)} -user #{options['run_user']} -type d")
files = cmd("find #{shellescape(path)} -user #{options['run_user']} -type f")
on_filelist(dirs,run_user_uid) do |path|
FileUtils.chmod(0770,path)
on_filelist(dirs,run_user_uid) do |p|
FileUtils.chmod(0770,p)
end
on_filelist(files,run_user_uid) do |path|
FileUtils.chmod(0660,path)
on_filelist(files,run_user_uid) do |p|
FileUtils.chmod(0660,p)
end
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment