Skip to content

Commit

Permalink
Make overrideable variables.
Browse files Browse the repository at this point in the history
The following environment variables are now available to override:

- SOCKET_PATH: defauts to /var/run/hermes.sock
- USER_TOKENS_PATH: defaults to /etc/hermes/ (the trailing slash is
  important)
- STORAGE_DEVICE_PREFIX: defaults to "sd"
- DEVICES_FOLDER: defaults to "/dev/" (the trailing slash is important)
  • Loading branch information
ralt committed Sep 28, 2015
1 parent 78bd812 commit ac9d6e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions daemon/hermes-daemon.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

(defun main (&rest args)
(declare (ignore args))
(make-overrideable-variables
(*socket-path* . "SOCKET_PATH")
(*user-tokens-path* . "USER_TOKENS_PATH")
(*storage-device-prefix* . "STORAGE_DEVICE_PREFIX")
(*devices-folder* . "DEVICES_FOLDER"))
(loop-with-unix-socket (socket)
(let ((user-buffer (make-array *max-username-length*
:element-type '(unsigned-byte 8))))
Expand Down
7 changes: 7 additions & 0 deletions daemon/macros.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@
;; Don't sleep the last time, it's pointless
do (unless (= ,i ,tries-max)
(sleep ,delay-in-seconds)))))

(defmacro make-overrideable-variables (&body alists)
`(progn
,@(loop for pair in alists
collect (let ((var-name (cdr pair)))
`(when (uiop:getenvp ,var-name)
(setf ,(car pair) (uiop:getenv ,var-name)))))))
8 changes: 4 additions & 4 deletions daemon/variables.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(defvar *user-tokens-path* #p"/etc/hermes/")
(defvar *storage-device-prefix* "sd")
(defvar *devices-folder* #p"/dev/")
(defvar *safe-ott-device-offset* 133)
(defvar *safe-ott-user-offset* 128)
(defvar *safe-ott-device-offset* 133)
(defvar *safe-ott-user-offset* 128)
(defvar *safe-ott-device-offset* (+ *fingerprint-length* *token-length*))
(defvar *safe-ott-user-offset* *token-length*)
(defvar *safe-ott-device-offset* (+ *fingerprint-length* *token-length*))
(defvar *safe-ott-user-offset* *token-length*)

0 comments on commit ac9d6e9

Please sign in to comment.