gnu: services: Fix pcscd activation bug.

Fixes: <https://bugs.gnu.org/32478>.

* gnu/services/security-token.scm (pcscd-activation): Idempotently create the
/var/lib/pcsc symlink so that it does not fail when it already exists.
This commit is contained in:
Chris Marusich 2018-08-20 00:16:06 -07:00
parent 6d863cdedd
commit 6fb6ac6857
No known key found for this signature in database
GPG Key ID: DD409A15D822469D
1 changed files with 17 additions and 8 deletions

View File

@ -20,6 +20,7 @@
#:use-module (gnu services) #:use-module (gnu services)
#:use-module (gnu services shepherd) #:use-module (gnu services shepherd)
#:use-module (gnu packages admin) #:use-module (gnu packages admin)
#:use-module (gnu packages base)
#:use-module (gnu packages security-token) #:use-module (gnu packages security-token)
#:use-module (gnu system shadow) #:use-module (gnu system shadow)
#:use-module (guix gexp) #:use-module (guix gexp)
@ -62,14 +63,22 @@
(define pcscd-activation (define pcscd-activation
(match-lambda (match-lambda
(($ <pcscd-configuration> pcsc-lite usb-drivers) (($ <pcscd-configuration> pcsc-lite usb-drivers)
#~(begin (with-imported-modules (source-module-closure
(use-modules (guix build utils)) '((guix build utils)))
(mkdir-p "/var/lib") #~(begin
(symlink #$(directory-union (use-modules (guix build utils))
"pcsc" ;; XXX: We can't use (guix utils) because it requires a
(map (cut file-append <> "/pcsc") ;; dynamically-linked Guile, hence the duplicate switch-symlinks.
usb-drivers)) (define (switch-symlinks link target)
"/var/lib/pcsc"))))) (let ((pivot (string-append link ".new")))
(symlink target pivot)
(rename-file pivot link)))
(mkdir-p "/var/lib")
(switch-symlinks "/var/lib/pcsc"
#$(directory-union
"pcsc"
(map (cut file-append <> "/pcsc")
usb-drivers))))))))
(define pcscd-service-type (define pcscd-service-type
(service-type (service-type