Bug 580321 - /usr/sbin/pcscd exit codes broken
Summary: /usr/sbin/pcscd exit codes broken
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: pcsc-lite
Version: 12
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Bob Relyea
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-04-08 00:20 UTC by Lennart Poettering
Modified: 2010-07-03 23:32 UTC (History)
3 users (show)

Fixed In Version: pcsc-lite-1.6.1-1.fc14
Clone Of:
Environment:
Last Closed: 2010-07-03 23:32:39 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Lennart Poettering 2010-04-08 00:20:55 UTC
The exit codes of /usr/sbin/pcscd seem to be broken.

If HAL is not around pcscd will complain about that to syslog and exit(0). The init script will pass that on, so that the caller thinks the service properly started up. However, it actually isn't, and a subsequent "/etc/init.d/pcscd stop" then fails, although it shouldn't if the start return code was 0.

Or short: when the daemon fails to start up you *must* return an exit code > 0. Not doing this is neither compatible with the fedora policy, nor the LSB.

Comment 1 Kalev Lember 2010-04-13 12:25:19 UTC
Adding upstream author Ludovic Rousseau to CC.

I looked at the code and it appears that pcscd first calls daemon(), which makes the forked parent process return with exit code 0.

After forking, the child process goes on to try to talk with hal. If the connection to hal fails, the _child_ process returns with a non-zero exit code.

Ludovic, do you think it would be possible to fix it somehow so that the error condition is checked _before_ forking?

Comment 2 Lennart Poettering 2010-04-13 12:40:41 UTC
You should not set up the HAL context before forking and then continue to use it after the fork. Most libraries cannot deal with forking and libdbus isn't any different there.

Instead, create a pipe before forking and then have the child signal success/failure writing to the pipe and reading it on the parent process side.

When daemonizing it is important that the child is fully providing its services when the parent process exits, since the exiting is used to synchronize startup. Hence you should do the pipe trick anyway.

Comment 3 Ludovic Rousseau 2010-05-31 09:15:42 UTC
It means I can't use daemon(3) and must (manually) use fork(2) instead.
daemon uses fork+exit but I need fork and later, after some code, exit.

I will try to implement this.

Comment 4 Ludovic Rousseau 2010-06-01 07:35:03 UTC
Fixed in revision 4969
http://lists.alioth.debian.org/pipermail/pcsclite-cvs-commit/2010-June/004521.html

Comment 5 Kalev Lember 2010-07-03 23:32:39 UTC
Thanks for fixing it, Ludovic!

I just built pcsc-lite 1.6.1 in rawhide which includes the fix; closing the ticket.


Note You need to log in before you can comment on or make changes to this bug.