Reno is the second iteration of the AWMTK-powered AwesomeWM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.6 KiB

2 years ago
  1. -- This file is part of Reno desktop.
  2. --
  3. -- Reno desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  4. --
  5. -- Reno desktop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  6. --
  7. -- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
  8. -- If you experience errors on the next line,
  9. -- that means that you did not install lua-pam.
  10. -- Run install_luapam.sh from the various-scripts directory.
  11. local pam = require('pam')
  12. local naughty = require("naughty")
  13. local function check_password(pw,username)
  14. local function conversation(messages)
  15. local responses = {}
  16. for i, message in ipairs(messages) do
  17. local msg_style, msg = message[1], message[2]
  18. if msg_style == pam.PROMPT_ECHO_OFF then
  19. -- Assume PAM asks us for the password
  20. print("PAM Message: ",msg)
  21. responses[i] = {pw, 0}
  22. elseif msg_style == pam.PROMPT_ECHO_ON then
  23. -- Assume PAM asks us for the username
  24. print("PAM Message: ",msg)
  25. responses[i] = {username or os.getenv("USER"), 0}
  26. elseif msg_style == pam.ERROR_MSG then
  27. print("PAM Error: ",msg)
  28. responses[i] = {"", 0}
  29. elseif msg_style == pam.TEXT_INFO then
  30. print("PAM Info message: ",msg)
  31. responses[i] = {"", 0}
  32. else
  33. print("Unsupported conversation message style for PAM: " .. msg_style)
  34. print("PAM Message: ",msg)
  35. end
  36. end
  37. return responses
  38. end
  39. local handler,err = pam.start("system-auth", nil, {conversation, nil})
  40. if not handler then
  41. naughty.notify({title="PAM session start error: ",text=err,bg="#AA0000"})
  42. print("PAM session start error: ",err)
  43. return false
  44. end
  45. local auth,err = pam.authenticate(handler)
  46. if not auth then
  47. print("PAM authentication error: ",err)
  48. return false
  49. end
  50. local s_end,err = pam.endx(handler, pam.SUCCESS)
  51. if not s_end then
  52. naughty.notify({title="PAM session end error: ",text=err,bg="#AA0000"})
  53. print("PAM session end error: ",err)
  54. return false
  55. end
  56. return true
  57. end
  58. return check_password