Subject: Re: [bug#32358] Add pcscd service

From: Arun Isaac <[email-masked]>
Date: Sun, 12 Aug 2018 13:55:52 +0530

> I'm having a little trouble testing this on my system due to the
> following unrelated bug:
>
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28144
>
> However, I'll keep trying and let you know once I've tested it out.

Sure, no problem.

> If you're feeling up to it, it would be great to add a system test,
> but it's not necessary, and we could add it later.

I'm ok with adding a system test right now. But, what kind of test? Can
you elaborate on any ideas you have?

> Shouldn't we also export pcscd-configuration-pcsc-lite and
> pcscd-configuration-usb-drivers?

Sure, will do.

>> +(define pcscd-shepherd-service
>> +  (match-lambda
>> +    (($ <pcscd-configuration> pcsc-lite)
>> +     (with-imported-modules (source-module-closure
>> +                             '((gnu build shepherd)))
>> +       (shepherd-service
>> +        (documentation "PC/SC Smart Card Daemon")
>> +        (provision '(pcscd))
>> +        (modules '((gnu build shepherd)))
>> +        (start #~(make-forkexec-constructor
>> +                  (list #$(file-append pcsc-lite "/sbin/pcscd") "-f")))
>> +        (stop #~(make-kill-destructor)))))))
>
> Does this work as written?  The make-forkexec-constructor and
> make-kill-destructor procedures are exported in (shepherd service), but
> it doesn't look like that module will be used, since it isn't in the
> modules list.  If it does work, then I don't understand how (shepherd
> service) is getting used, so I'd be curious to know why it works!

Yes, the service does work. But, I don't really know why. I copied this
bit of code from some other service and modified it incrementally until
it did what I wanted. :-P So, I'm not super-clear what exactly is
happening here.

>> +(define pcscd-activation
>> +  (match-lambda
>> +    (($ <pcscd-configuration> pcsc-lite usb-drivers)
>> +     #~(begin
>> +         (use-modules (guix build utils))
>> +         (mkdir-p "/var/lib")
>> +         (symlink #$(directory-union
>> +                     "pcsc"
>> +                     (map (cut file-append <> "/pcsc")
>> +                          usb-drivers))
>> +                  "/var/lib/pcsc")))))
>
> What happens if the symlink target already exists?  Will this crash the
> init process, or will the system come online and just report an error?
> Some people (such as myself) have already created this directory
> manually, so the directory might exist if they forget to delete it.

When the symlink already exists, the system reconfigures properly, but
reports an error. You will have to delete your existing /var/lib/pcsc
symlink before reconfiguring.

>> Subject: [PATCH 2/2] gnu: ccid: Move pcsc-lite from inputs to native-inputs.
>
> Patch 2/2 looks good to me!

I pushed this patch alone to master.