secrets.lisp 799 B

12345678910111213141516171819202122
  1. (in-package #:chatikbot)
  2. (defvar *secret-ring* nil "GPG keyring path")
  3. (defvar *secret-pass-store* nil "pass store dir")
  4. (defvar *secret-pass-bin* "pass" "pass util binary")
  5. (defun %secret/pass (args &key input output error-output)
  6. (ignore-errors
  7. (uiop:run-program
  8. (format nil "~@[GNUPGHOME=~A ~]~@[PASSWORD_STORE_DIR=~A ~]~A ~A"
  9. *secret-ring* *secret-pass-store* *secret-pass-bin*
  10. args)
  11. :input input :output output :error-output error-output)))
  12. (defun secret/get (path)
  13. (%secret/pass (format nil "show ~{~A~^/~}" path)
  14. :output :string))
  15. (defun secret/set (path value)
  16. (with-input-from-string (input value)
  17. (%secret/pass (format nil "insert --force --multiline ~{~A~^/~}" path)
  18. :input input :output :string)))