summaryrefslogtreecommitdiff
path: root/gnu/installer/newt
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-04-24 17:59:06 +0200
committerLudovic Courtès <ludo@gnu.org>2019-04-25 00:45:34 +0200
commit898677ed17672130d20434cd88575d620c97c553 (patch)
tree6f554d1ed2073dbad96911d7f4839187f37e9e9c /gnu/installer/newt
parent3cc033f2a86d44da44f63ee45602dca0cb0932b2 (diff)
downloadpatches-898677ed17672130d20434cd88575d620c97c553.tar
patches-898677ed17672130d20434cd88575d620c97c553.tar.gz
installer: Ask for user password and initialize /etc/shadow.
Partly fixes <https://bugs.gnu.org/35399>. * gnu/installer/user.scm (<user>)[password]: New field. * gnu/installer/final.scm (%seed): New variable. (integer->alphanumeric-char, random-string) (create-user-database): New procedures. (install-system): Call 'create-user-database'. * gnu/installer/newt/final.scm (run-install-shell): Add #:users and pass it to 'install-system'. (run-final-page): Pass #:users to 'run-install-shell'. * gnu/installer/newt/user.scm (run-user-add-page): Add password entry. Pass its result as the 'password' field of <user>.
Diffstat (limited to 'gnu/installer/newt')
-rw-r--r--gnu/installer/newt/final.scm9
-rw-r--r--gnu/installer/newt/user.scm21
2 files changed, 21 insertions, 9 deletions
diff --git a/gnu/installer/newt/final.scm b/gnu/installer/newt/final.scm
index f492c5dbb7..f470a90004 100644
--- a/gnu/installer/newt/final.scm
+++ b/gnu/installer/newt/final.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -65,10 +66,11 @@ press the button to reboot.")))
(G_ "The final system installation step failed. You can retry the \
last step, or restart the installer.")))
-(define (run-install-shell locale)
+(define* (run-install-shell locale
+ #:key (users '()))
(clear-screen)
(newt-suspend)
- (let ((install-ok? (install-system locale)))
+ (let ((install-ok? (install-system locale #:users users)))
(newt-resume)
install-ok?))
@@ -76,12 +78,13 @@ last step, or restart the installer.")))
(let* ((configuration (format-configuration prev-steps result))
(user-partitions (result-step result 'partition))
(locale (result-step result 'locale))
+ (users (result-step result 'user))
(install-ok?
(with-mounted-partitions
user-partitions
(configuration->file configuration)
(run-config-display-page)
- (run-install-shell locale))))
+ (run-install-shell locale #:users users))))
(if install-ok?
(run-install-success-page)
(run-install-failed-page))))
diff --git a/gnu/installer/newt/user.scm b/gnu/installer/newt/user.scm
index 59b1913cfc..032f9b9276 100644
--- a/gnu/installer/newt/user.scm
+++ b/gnu/installer/newt/user.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -36,10 +37,14 @@
(make-label -1 -1 (pad-label (G_ "Name"))))
(label-home-directory
(make-label -1 -1 (pad-label (G_ "Home directory"))))
+ (label-password
+ (make-label -1 -1 (pad-label (G_ "Password"))))
(entry-width 30)
(entry-name (make-entry -1 -1 entry-width))
(entry-home-directory (make-entry -1 -1 entry-width))
- (entry-grid (make-grid 2 2))
+ (entry-password (make-entry -1 -1 entry-width
+ #:flags FLAG-PASSWORD))
+ (entry-grid (make-grid 3 4))
(button-grid (make-grid 1 1))
(ok-button (make-button -1 -1 (G_ "OK")))
(grid (make-grid 1 2))
@@ -52,6 +57,8 @@
(set-entry-grid-field 1 0 entry-name)
(set-entry-grid-field 0 1 label-home-directory)
(set-entry-grid-field 1 1 entry-home-directory)
+ (set-entry-grid-field 0 2 label-password)
+ (set-entry-grid-field 1 2 entry-password)
(set-grid-field button-grid 0 0 GRID-ELEMENT-COMPONENT ok-button)
@@ -62,8 +69,8 @@
(string-append "/home/" (entry-value entry-name)))))
(add-components-to-form form
- label-name label-home-directory
- entry-name entry-home-directory
+ label-name label-home-directory label-password
+ entry-name entry-home-directory entry-password
ok-button)
(make-wrapped-grid-window (vertically-stacked-grid
@@ -82,8 +89,9 @@
(when (eq? exit-reason 'exit-component)
(cond
((components=? argument ok-button)
- (let ((name (entry-value entry-name))
- (home-directory (entry-value entry-home-directory)))
+ (let ((name (entry-value entry-name))
+ (home-directory (entry-value entry-home-directory))
+ (password (entry-value entry-password)))
(if (or (string=? name "")
(string=? home-directory ""))
(begin
@@ -91,7 +99,8 @@
(run-user-add-page))
(user
(name name)
- (home-directory home-directory))))))))
+ (home-directory home-directory)
+ (password password))))))))
(lambda ()
(destroy-form-and-pop form)))))))