From 45c5b47b96a238c764c2d32966267f7f897bcc3d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 13 Dec 2014 22:30:44 +0100 Subject: activation: Copy the account skeletons when creating the 'root' account. * gnu/build/activation.scm (%skeleton-directory): New variable. (dot-or-dot-dot?, copy-account-skeletons): New procedure. (add-user): Use 'copy-account-skeletons'. (activate-etc): Use 'dot-or-dot-dot?'. --- gnu/build/activation.scm | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'gnu/build/activation.scm') diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm index c27cda3666..dfadde326c 100644 --- a/gnu/build/activation.scm +++ b/gnu/build/activation.scm @@ -50,6 +50,25 @@ ,name))) (zero? (apply system* "groupadd" args)))) +(define %skeleton-directory + ;; Directory containing skeleton files for new accounts. + ;; Note: keep the trailing '/' so that 'scandir' enters it. + "/etc/skel/") + +(define (dot-or-dot-dot? file) + (member file '("." ".."))) + +(define* (copy-account-skeletons home + #:optional (directory %skeleton-directory)) + "Copy the account skeletons from DIRECTORY to HOME." + (let ((files (scandir directory (negate dot-or-dot-dot?) + string "~a:x:~a:~a:~a:~a:~a~%" name "0" "0" comment home shell)) (chmod "/etc/shadow" #o600) + (copy-account-skeletons (or home "/root")) #t) ;; Use 'useradd' from the Shadow package. @@ -198,9 +218,7 @@ numeric gid or #f." ;; XXX: Dirty hack to meet sudo's expectations. (when (string=? (basename target) "sudoers") (chmod target #o440)))) - (scandir etc - (lambda (file) - (not (member file '("." "..")))) + (scandir etc (negate dot-or-dot-dot?) ;; The default is 'string-locale