diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2016-08-28 12:53:20 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2016-08-28 15:11:18 +0200 |
| commit | eb56ee027b4c6b5682f69fa885d16e55c4495bd8 (patch) | |
| tree | 0a0a348da697de4e59baa2adb50af6eadc44742f /gnu/build/activation.scm | |
| parent | 3eb2fca61274eb2ede550146c03c1ee86aa2a4c0 (diff) | |
system: Add 'create-home-directory?' field to <user-account>.
* gnu/system/shadow.scm (<user-account>)[create-home-directory?]: New
field.
(user-account->gexp): Serialize it.
* gnu/build/activation.scm (activate-users+groups)[activate-user]:
Update 'match-lambda' pattern accordingly. Pass #:create-home? to
'ensure-user'.
(add-user, modify-user, ensure-user): Add #:create-home? parameter and
honor it.
* doc/guix.texi (User Accounts): Document it.
Diffstat (limited to 'gnu/build/activation.scm')
| -rw-r--r-- | gnu/build/activation.scm | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm index 6666cb48568..10aa58d85cf 100644 --- a/gnu/build/activation.scm +++ b/gnu/build/activation.scm | |||
| @@ -110,7 +110,8 @@ owner-writable in HOME." | |||
| 110 | files))) | 110 | files))) |
| 111 | 111 | ||
| 112 | (define* (add-user name group | 112 | (define* (add-user name group |
| 113 | #:key uid comment home shell password system? | 113 | #:key uid comment home create-home? |
| 114 | shell password system? | ||
| 114 | (supplementary-groups '()) | 115 | (supplementary-groups '()) |
| 115 | (log-port (current-error-port))) | 116 | (log-port (current-error-port))) |
| 116 | "Create an account for user NAME part of GROUP, with the specified | 117 | "Create an account for user NAME part of GROUP, with the specified |
| @@ -139,7 +140,7 @@ properties. Return #t on success." | |||
| 139 | `("-G" ,(string-join supplementary-groups ",")) | 140 | `("-G" ,(string-join supplementary-groups ",")) |
| 140 | '()) | 141 | '()) |
| 141 | ,@(if comment `("-c" ,comment) '()) | 142 | ,@(if comment `("-c" ,comment) '()) |
| 142 | ,@(if home | 143 | ,@(if (and home create-home?) |
| 143 | (if (file-exists? home) | 144 | (if (file-exists? home) |
| 144 | `("-d" ,home) ; avoid warning from 'useradd' | 145 | `("-d" ,home) ; avoid warning from 'useradd' |
| 145 | `("-d" ,home "--create-home")) | 146 | `("-d" ,home "--create-home")) |
| @@ -158,7 +159,8 @@ properties. Return #t on success." | |||
| 158 | #t))))) | 159 | #t))))) |
| 159 | 160 | ||
| 160 | (define* (modify-user name group | 161 | (define* (modify-user name group |
| 161 | #:key uid comment home shell password system? | 162 | #:key uid comment home create-home? |
| 163 | shell password system? | ||
| 162 | (supplementary-groups '()) | 164 | (supplementary-groups '()) |
| 163 | (log-port (current-error-port))) | 165 | (log-port (current-error-port))) |
| 164 | "Modify user account NAME to have all the given settings." | 166 | "Modify user account NAME to have all the given settings." |
| @@ -186,7 +188,8 @@ logged in." | |||
| 186 | (zero? (system* "groupdel" name))) | 188 | (zero? (system* "groupdel" name))) |
| 187 | 189 | ||
| 188 | (define* (ensure-user name group | 190 | (define* (ensure-user name group |
| 189 | #:key uid comment home shell password system? | 191 | #:key uid comment home create-home? |
| 192 | shell password system? | ||
| 190 | (supplementary-groups '()) | 193 | (supplementary-groups '()) |
| 191 | (log-port (current-error-port)) | 194 | (log-port (current-error-port)) |
| 192 | #:rest rest) | 195 | #:rest rest) |
| @@ -207,7 +210,8 @@ numeric gid or #f." | |||
| 207 | 210 | ||
| 208 | (define activate-user | 211 | (define activate-user |
| 209 | (match-lambda | 212 | (match-lambda |
| 210 | ((name uid group supplementary-groups comment home shell password system?) | 213 | ((name uid group supplementary-groups comment home create-home? |
| 214 | shell password system?) | ||
| 211 | (let ((profile-dir (string-append "/var/guix/profiles/per-user/" | 215 | (let ((profile-dir (string-append "/var/guix/profiles/per-user/" |
| 212 | name))) | 216 | name))) |
| 213 | (ensure-user name group | 217 | (ensure-user name group |
| @@ -216,6 +220,7 @@ numeric gid or #f." | |||
| 216 | #:supplementary-groups supplementary-groups | 220 | #:supplementary-groups supplementary-groups |
| 217 | #:comment comment | 221 | #:comment comment |
| 218 | #:home home | 222 | #:home home |
| 223 | #:create-home? create-home? | ||
| 219 | #:shell shell | 224 | #:shell shell |
| 220 | #:password password) | 225 | #:password password) |
| 221 | 226 | ||
