mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-25 12:09:15 -05:00
system: Add a 'system?' field to user accounts.
* gnu/system/shadow.scm (<user-account>)[system?]: New field. * gnu/system.scm (user-account->gexp): Add it. * guix/build/activation.scm (add-user): Add #:system? parameter and honor it. (activate-users+groups): Handle the 'system?' part of user tuples. Pass it to 'add-user'. Don't create PROFILE-DIR when SYSTEM? is true. * gnu/services/dbus.scm (dbus-service): Add 'system?' field for "messagebus" account. * gnu/services/base.scm (guix-build-accounts): Likewise. * gnu/services/avahi.scm (avahi-service): Likewise.
This commit is contained in:
parent
f2c403eab6
commit
459dd9eaf2
6 changed files with 18 additions and 8 deletions
|
@ -100,6 +100,7 @@ (define* (avahi-service #:key (avahi avahi)
|
||||||
(user-accounts (list (user-account
|
(user-accounts (list (user-account
|
||||||
(name "avahi")
|
(name "avahi")
|
||||||
(group "avahi")
|
(group "avahi")
|
||||||
|
(system? #t)
|
||||||
(comment "Avahi daemon user")
|
(comment "Avahi daemon user")
|
||||||
(home-directory "/var/empty")
|
(home-directory "/var/empty")
|
||||||
(shell
|
(shell
|
||||||
|
|
|
@ -327,6 +327,7 @@ (define* (guix-build-accounts count #:key
|
||||||
(lambda (n)
|
(lambda (n)
|
||||||
(user-account
|
(user-account
|
||||||
(name (format #f "guixbuilder~2,'0d" n))
|
(name (format #f "guixbuilder~2,'0d" n))
|
||||||
|
(system? #t)
|
||||||
(uid (+ first-uid n -1))
|
(uid (+ first-uid n -1))
|
||||||
(group group)
|
(group group)
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ (define* (dbus-service services #:key (dbus dbus))
|
||||||
(user-accounts (list (user-account
|
(user-accounts (list (user-account
|
||||||
(name "messagebus")
|
(name "messagebus")
|
||||||
(group "messagebus")
|
(group "messagebus")
|
||||||
|
(system? #t)
|
||||||
(comment "D-Bus system bus user")
|
(comment "D-Bus system bus user")
|
||||||
(home-directory "/var/run/dbus")
|
(home-directory "/var/run/dbus")
|
||||||
(shell
|
(shell
|
||||||
|
|
|
@ -369,7 +369,8 @@ (define (user-account->gexp account)
|
||||||
#$(user-account-comment account)
|
#$(user-account-comment account)
|
||||||
#$(user-account-home-directory account)
|
#$(user-account-home-directory account)
|
||||||
,#$(user-account-shell account) ; this one is a gexp
|
,#$(user-account-shell account) ; this one is a gexp
|
||||||
#$(user-account-password account)))
|
#$(user-account-password account)
|
||||||
|
#$(user-account-system? account)))
|
||||||
|
|
||||||
(define (operating-system-activation-script os)
|
(define (operating-system-activation-script os)
|
||||||
"Return the activation script for OS---i.e., the code that \"activates\" the
|
"Return the activation script for OS---i.e., the code that \"activates\" the
|
||||||
|
|
|
@ -34,6 +34,7 @@ (define-module (gnu system shadow)
|
||||||
user-account-comment
|
user-account-comment
|
||||||
user-account-home-directory
|
user-account-home-directory
|
||||||
user-account-shell
|
user-account-shell
|
||||||
|
user-account-system?
|
||||||
|
|
||||||
user-group
|
user-group
|
||||||
user-group?
|
user-group?
|
||||||
|
@ -63,7 +64,9 @@ (define-record-type* <user-account>
|
||||||
(comment user-account-comment (default ""))
|
(comment user-account-comment (default ""))
|
||||||
(home-directory user-account-home-directory)
|
(home-directory user-account-home-directory)
|
||||||
(shell user-account-shell ; gexp
|
(shell user-account-shell ; gexp
|
||||||
(default #~(string-append #$bash "/bin/bash"))))
|
(default #~(string-append #$bash "/bin/bash")))
|
||||||
|
(system? user-account-system? ; Boolean
|
||||||
|
(default #f)))
|
||||||
|
|
||||||
(define-record-type* <user-group>
|
(define-record-type* <user-group>
|
||||||
user-group make-user-group
|
user-group make-user-group
|
||||||
|
|
|
@ -47,7 +47,7 @@ (define* (add-group name #:key gid password
|
||||||
(zero? (apply system* "groupadd" args))))
|
(zero? (apply system* "groupadd" args))))
|
||||||
|
|
||||||
(define* (add-user name group
|
(define* (add-user name group
|
||||||
#:key uid comment home shell password
|
#:key uid comment home shell password system?
|
||||||
(supplementary-groups '())
|
(supplementary-groups '())
|
||||||
(log-port (current-error-port)))
|
(log-port (current-error-port)))
|
||||||
"Create an account for user NAME part of GROUP, with the specified
|
"Create an account for user NAME part of GROUP, with the specified
|
||||||
|
@ -82,6 +82,7 @@ (define* (add-user name group
|
||||||
'())
|
'())
|
||||||
,@(if shell `("-s" ,shell) '())
|
,@(if shell `("-s" ,shell) '())
|
||||||
,@(if password `("-p" ,password) '())
|
,@(if password `("-p" ,password) '())
|
||||||
|
,@(if system? '("--system") '())
|
||||||
,name)))
|
,name)))
|
||||||
(zero? (apply system* "useradd" args)))))
|
(zero? (apply system* "useradd" args)))))
|
||||||
|
|
||||||
|
@ -97,22 +98,24 @@ (define (touch file)
|
||||||
|
|
||||||
(define activate-user
|
(define activate-user
|
||||||
(match-lambda
|
(match-lambda
|
||||||
((name uid group supplementary-groups comment home shell password)
|
((name uid group supplementary-groups comment home shell password system?)
|
||||||
(unless (false-if-exception (getpwnam name))
|
(unless (false-if-exception (getpwnam name))
|
||||||
(let ((profile-dir (string-append "/var/guix/profiles/per-user/"
|
(let ((profile-dir (string-append "/var/guix/profiles/per-user/"
|
||||||
name)))
|
name)))
|
||||||
(add-user name group
|
(add-user name group
|
||||||
#:uid uid
|
#:uid uid
|
||||||
|
#:system? system?
|
||||||
#:supplementary-groups supplementary-groups
|
#:supplementary-groups supplementary-groups
|
||||||
#:comment comment
|
#:comment comment
|
||||||
#:home home
|
#:home home
|
||||||
#:shell shell
|
#:shell shell
|
||||||
#:password password)
|
#:password password)
|
||||||
|
|
||||||
;; Create the profile directory for the new account.
|
(unless system?
|
||||||
(let ((pw (getpwnam name)))
|
;; Create the profile directory for the new account.
|
||||||
(mkdir-p profile-dir)
|
(let ((pw (getpwnam name)))
|
||||||
(chown profile-dir (passwd:uid pw) (passwd:gid pw))))))))
|
(mkdir-p profile-dir)
|
||||||
|
(chown profile-dir (passwd:uid pw) (passwd:gid pw)))))))))
|
||||||
|
|
||||||
;; 'groupadd' aborts if the file doesn't already exist.
|
;; 'groupadd' aborts if the file doesn't already exist.
|
||||||
(touch "/etc/group")
|
(touch "/etc/group")
|
||||||
|
|
Loading…
Reference in a new issue