diff --git a/core/resource.lisp b/core/resource.lisp
index d9d5dd1..5904ad0 100644
--- a/core/resource.lisp
+++ b/core/resource.lisp
@@ -163,6 +163,8 @@
#+nil
(describe-probed (resource 'mount "/rd") t)
+(defmethod resource-additional-specs ((res resource) (os t))
+ )
;; Sync
diff --git a/core/spec.lisp b/core/spec.lisp
index 7198fd6..0ba8df2 100644
--- a/core/spec.lisp
+++ b/core/spec.lisp
@@ -44,7 +44,8 @@
(defmethod parse-next-specification ((res resource-container) spec)
(cond ((typep (first spec) 'resource)
- (add-resource res (pop spec))
+ (let ((child (pop spec)))
+ (add-resource res child))
spec)
(:otherwise (call-next-method))))
@@ -61,6 +62,14 @@
(setq spec next-spec)))
res)
+(defmethod parse-specification ((res resource-container) (spec t))
+ (with-parent-resource res
+ (call-next-method)
+ (do-resources (child) res
+ (resource-additional-specs child (host-os (current-host))))))
+
+(trace parse-specification)
+
#+nil
(parse-specification *localhost*
'(:hostname "arrakis.lowh.net"))
@@ -77,11 +86,11 @@
(nreverse r)))
(defun resource (type id &rest spec)
- (let ((r (or #1=(get-resource type id)
- (setf #1# (make-resource type id)))))
+ (let ((res (or #1=(get-resource type id)
+ (setf #1# (make-resource type id)))))
(when spec
- (parse-specification r spec))
- r))
+ (parse-specification res spec))
+ res))
(defmacro specify (&body specification)
`(macrolet ,(mapcar (lambda (c)
diff --git a/unix/ssh.lisp b/unix/ssh.lisp
index 2de01c0..43205d5 100644
--- a/unix/ssh.lisp
+++ b/unix/ssh.lisp
@@ -74,3 +74,17 @@
(run "mv " sh-ak-tmp " " sh-ak))
(when (position ensure '(:present nil))
(run "echo " (sh-quote type " " pubkey " " name) " >> " sh-ak))))
+
+(defmethod resource-additional-specs ((res ssh-authorized-key)
+ (os os-unix))
+ (let* ((user *parent-resource*)
+ (home (resource-id (get-specified user :home)))
+ (ssh-dir (str home "/.ssh"))
+ (ak (str dot-ssh "/authorized_keys")))
+ (with-parent-resource *host*
+ (resource 'directory ssh-dir
+ :ensure :present
+ :mode #o700)
+ (resource 'file ak
+ :ensure :present
+ :mode #o600))))