Sha256: c5b80d6dbe2a365489a1fbd791ca8c5395ec76956ab56ae6e59993ab4c288df3
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
# PASSWD service<tab> username<tab> oldpasswd<tab> newpasswd<tab> <newline> # # Request a password change for the given account: validate that the # oldpassword is correct, and if so, change it to the newpassword. # # Reply: the string for success, or FAIL<newline> for a data error (e.g. no # such account, old password wrong, new password not acceptable). In the case # of a temporary failure, such as a database being down, authProg should # terminate without sending any response. # module Authpipe class Passwd def self.process(request = nil) Pre.new.process(request) end def process(request) params = parse_request(request) if (account = update_account_password(params)) return account.to_authpipe else raise AuthpipeException, 'Unable to update password' end end protected # Looks up the account by :service and :username, then confirms that # :oldpasswd is correct, then changes the password to :newpasswd and # returns the updated Authpipe::AccountData object. def update_account_password(params) raise NotImplementedError, 'update_account_password must be overridden by subclass' end def parse_request(request) if request.strip =~ /^(\w+)\t(\w+)\t(\w+)\t(\w+)$/ { :authservice => $1, :username => $2, :oldpasswd => $3, :newpasswd => $4 } else raise ArgumentError, "Invalid PASSWD request: #{request}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mroch-authpipe-0.1.1 | lib/authpipe/passwd.rb |