bad file access "fix"
This commit is contained in:
parent
31cbdf86a5
commit
f64668543d
@ -1,20 +1,24 @@
|
||||
# frozen_string_literal: true
|
||||
class FtpConfig
|
||||
def build_password_list accounts
|
||||
`sudo chown $(whoami) #{password_file}`
|
||||
File.open(password_file, "w+") do |file|
|
||||
Array(accounts).each do |account|
|
||||
file.write "#{account.username}:#{hash_password(account.password)}"
|
||||
end
|
||||
end
|
||||
`sudo chown root #{password_file}`
|
||||
end
|
||||
|
||||
def build_user_configs accounts
|
||||
`sudo chown -R $(whoami) #{config_path}`
|
||||
Array(accounts).each do |account|
|
||||
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}"
|
||||
end
|
||||
end
|
||||
`sudo chown -R root #{config_path}`
|
||||
end
|
||||
|
||||
private
|
||||
@ -31,6 +35,10 @@ class FtpConfig
|
||||
AppConfig.ftproot
|
||||
end
|
||||
|
||||
def ftp_user
|
||||
AppConfig.ftpaccount
|
||||
end
|
||||
|
||||
def hash_password password
|
||||
`openssl passwd -1 -noverify -quiet #{password}`
|
||||
end
|
||||
|
@ -13,6 +13,7 @@ defaults: &defaults
|
||||
htpasswd: "/path/to/vsftpd/password.file"
|
||||
ftpusers: "/path/to/vsftpd/users/configs"
|
||||
ftproot: "/path/to/root/ftp/prefix/"
|
||||
ftpaccount: vsftpd
|
||||
|
||||
development:
|
||||
<<: *defaults
|
||||
|
@ -52,4 +52,6 @@ Rails.application.configure do
|
||||
# Use an evented file watcher to asynchronously detect changes in source code,
|
||||
# routes, locales, etc. This feature depends on the listen gem.
|
||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
|
||||
config.web_console.whitelisted_ips = '192.168.76.0/16'
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user