bad file access "fix"

This commit is contained in:
Mark Moser 2016-10-09 20:58:30 -05:00
parent 31cbdf86a5
commit f64668543d
3 changed files with 12 additions and 1 deletions

View File

@ -1,20 +1,24 @@
# frozen_string_literal: true # frozen_string_literal: true
class FtpConfig class FtpConfig
def build_password_list accounts def build_password_list accounts
`sudo chown $(whoami) #{password_file}`
File.open(password_file, "w+") do |file| File.open(password_file, "w+") do |file|
Array(accounts).each do |account| Array(accounts).each do |account|
file.write "#{account.username}:#{hash_password(account.password)}" file.write "#{account.username}:#{hash_password(account.password)}"
end end
end end
`sudo chown root #{password_file}`
end end
def build_user_configs accounts def build_user_configs accounts
`sudo chown -R $(whoami) #{config_path}`
Array(accounts).each do |account| Array(accounts).each do |account|
File.open("#{config_path}#{account.username}", "w+") do |file| File.open("#{config_path}#{account.username}", "w+") do |file|
FileUtils.mkdir_p "#{ftp_root}#{account.home_folder}" `sudo -u #{ftp_user} mkdir -p #{ftp_root}#{account.home_folder}`
file.write "local_root=#{ftp_root}#{account.home_folder}" file.write "local_root=#{ftp_root}#{account.home_folder}"
end end
end end
`sudo chown -R root #{config_path}`
end end
private private
@ -31,6 +35,10 @@ class FtpConfig
AppConfig.ftproot AppConfig.ftproot
end end
def ftp_user
AppConfig.ftpaccount
end
def hash_password password def hash_password password
`openssl passwd -1 -noverify -quiet #{password}` `openssl passwd -1 -noverify -quiet #{password}`
end end

View File

@ -13,6 +13,7 @@ defaults: &defaults
htpasswd: "/path/to/vsftpd/password.file" htpasswd: "/path/to/vsftpd/password.file"
ftpusers: "/path/to/vsftpd/users/configs" ftpusers: "/path/to/vsftpd/users/configs"
ftproot: "/path/to/root/ftp/prefix/" ftproot: "/path/to/root/ftp/prefix/"
ftpaccount: vsftpd
development: development:
<<: *defaults <<: *defaults

View File

@ -52,4 +52,6 @@ Rails.application.configure do
# Use an evented file watcher to asynchronously detect changes in source code, # Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem. # routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.web_console.whitelisted_ips = '192.168.76.0/16'
end end