Method: Chook::Server.pw_from_file
- Defined in:
- lib/chook/server/auth.rb
.pw_from_file(file) ⇒ Object
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/chook/server/auth.rb', line 145 def self.pw_from_file(file) file = Pathname.new file return nil unless file.file? stat = file.stat mode = format('%o', stat.mode) raise "Password file #{setting} has insecure mode, must be 0600." unless mode.end_with?('0600') raise "Password file #{setting} has insecure owner, must be owned by UID #{Process.euid}." unless stat.owned? # chomping an empty string removes all trailing \n's and \r\n's file.read.chomp('') end |