Pared::PAM
Constants
PAM_CONV_CALLBACK = ->(num_msg : LibC::Int, msg : ::Pointer(::Pointer(LibPAM::PamMessage)), resp : ::Pointer(::Pointer(LibPAM::PamResponse)), appdata_ptr : ::Pointer(Void)) : LibC::Int do
if appdata_ptr.nil?
return 19
end
password = Box(String).unbox(appdata_ptr)
responses = (LibC.malloc((sizeof(LibPAM::PamResponse)) * num_msg)).as(::Pointer(LibPAM::PamResponse))
num_msg.times do |i|
message = msg[i].value
if message.msg_style == LibPAM::PAM_PROMPT_ECHO_OFF
len = password.bytesize
ptr = (LibC.malloc(len + 1)).as(::Pointer(LibC::Char))
(Pointer(UInt8).new(ptr.address)).copy_from(password.to_unsafe, len)
ptr[len] = 0
responses[i] = LibPAM::PamResponse.new(resp: ptr, resp_retcode: 0)
else
responses[i] = LibPAM::PamResponse.new(resp: nil, resp_retcode: 0)
end
end
resp.value = responses
LibPAM::PAM_SUCCESS
end
Statically defined Proc to serve as the PAM conversation callback