OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: Douglas Atique (datiqueterra.com.br)
Date: Wed Feb 06 2002 - 09:25:15 CST

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    Hi, all.
    I have been in touch with David Corcoran, Ludovic Rousseau and Carlos
    Prados to try to fix several small problems I was having with pcsc-
    lite 1.0.1 on Solaris 8. To lower message traffic, we talked in
    private, but now that I have a conclusion, I'll post my results.
    At first, pcsc-lite 1.0.1 daemon was dying on Solaris in unexpected
    situations and on Solaris shutdown it seemed to hang the whole
    operating system. Ludovic Rousseau told me to try pcsc-lite 1.0.2b3
    which had some corrections, like uninitializing the smart card reader
    driver when the daemon gets killed by a signal (which is the way the
    daemon is always terminated).
    I tried building it and several problems arose:
    1. A system-dependent file sys_solaris.c wasn't present in the
    1.0.2b3 distribution. I tried to compose it from sys_solaris.c in
    1.0.1 and the changes I deduced from sys_unix.c (between 1.0.1 and
    1.0.2b3). I was only in doubt about the MS_INVALIDATE flag on msync
    call being used in sys_unix.c and not in sys_solaris.c. If it was
    intentional, then OK.
    2. The file winscard_msg.c has a conditional include of filio.h only
    when the macro PCSC_TARGET_SOLARIS is defined. This was working on
    1.0.1 because its src/Makefile had a DEFS=-DPCSC_TARGET_SOLARIS and
    1.0.2's src/Makefile hasn't. I made it build successfully by editing
    1.0.2's src/Makefile by hand, but don't know how to solve this for
    good. Anyone does?
    3. When I used --enable-runpid I noticed that pcscd wasn't unlinking
    the file when the daemon terminated. This doesn't seem to bother most
    people, but my init.d script tests [ -f runpidfile ] as an indication
    that the daemon is running. I sure wouldn't like it to signal another
    process that happened to have the same pid! Then I arranged to runpid
    file to be unlinked on at_exit().
    4. I found out why pcscd 1.0.1 died suddenly. pcscd 1.0.2 also did.
    It died when I closed the shell which started it. Carlos Prados told
    me in a private e-mail that this was because Solaris sends a SIGHUP
    to processes started by a shell when that shell exits. He told me to
    use nohup, but I read in the man pages that nohup makes the daemon
    ignore SIGQUIT also. So I decided to add a signal() call to ignore
    HUPs (this could be made conditional to Solaris if someone doesn't
    like it).
    5. I adapted one of Solaris init.d scripts to start and stop pcscd
    checking if the daemon executable and the reader.conf exist and
    testing for the runpid file to signal the running daemon. Don't know
    whether there are any copyright issues for this script being a
    derivative work from Sun's one.
    I have sent Dave, Ludovic and Carlos my modified files (except for
    item 4 which I discovered after that). If a diff is a better option,
    please tell me which options I should use on it and whether I should
    use gnu diff or Solaris diff.

    Regards,
    Douglas

    P.S.: I am attaching the last message I exchanged with Carlos Prados
    so that all discussed points are archived on the list. Sorry for the
    long post.

    ---------- Mensagem original -----------

    De : Carlos Prados <cpradosyahoo.com>
    Para : Douglas Atique <datiqueterra.com.br>,
    corcoranlinuxnet.com,ludovic.rousseaufree.fr
    Cc :
    Data : Mon, 4 Feb 2002 07:21:45 -0800 (PST)
    Assunto : Re: pcsc-lite-1.0.2 impressions on Solaris

    Hi,
    --- Douglas Atique <datiqueterra.com.br> wrote:
    > Ludovic, Dave, Carlos,
    > I have built pcsc-lite-1.0.2b3 on Solaris 8 and found some minor
    > problems, which I hadn't found on 1.0.1. In particular,
    sys_solaris.c
    > is absent on pcsc-lite-1.0.2. I copied it from 1.0.1 and that seems
    > to work. In fact I copied it from sys_unix.c and opened both files
    in
    > 1.0.1 and 1.0.2 and swept them looking for differences between
    > sys_unix.c and sys_solaris.c in 1.0.1 and redoing them in 1.0.2, so
    > that any changes between sys_unix.c 1.0.1 and sys_unix.c 1.0.2
    > wouldn't be lost (what would happen if I had copied sys_solaris from
    > 1.0.1 to 1.0.2 unchanged). I have a doubt in this file. I noticed in
    > 1.0.1 that sys_unix calls msync with two flags and sys_solaris.c
    > calls msync with only one flat. The flag that is absent in
    > sys_solaris.c is MS_INVALIDATE. I wonder why it is not used in
    > Solaris...
    > Another error I got was in compiling winscard_msg.c. What happened
    > was that the filio.h header, which is included only if
    > PCSC_TARGET_SOLARIS is defined, wasn't. I tracked down
    > PCSC_TARGET_SOLARIS and found that in 1.0.1 it is listed in
    > src/Makefile as DEFS= <lots of macros> -DPCSC_TARGET_SOLARIS=1 and
    in
    > 1.0.2 it gets defined in config.h but not in src/Makefile's DEFS. To
    > make it work I edited src/Makefile and appended -
    > DCPSC_TARGET_SOLARIS=1 to DEFS, but configure should do something
    > about it automatically, or maybe config.h should be included in
    > winscard_msg.c (I am not sure if this works).

    I guess the autoconf should be usinf #if's to select wich sys_*.c file
    to compile and link. A macro in configure.ac should set a variable. I
    think it's the way it's supposed to work now, I'm not sure. Maybe you
    can provide us with a patch with all your changes.

    > Another thing, I have used --enable-runpid=/var/run/pcscd.pid and
    > found out that on killing pcscd the pid file doesnt get removed, so
    I
    > added a sys_unlink call to at_exit in pcscdaemon.c just like the
    > other unlink's in at_exit.

    Normally the daemon does not need to remove this file, it gets
    overwritten when the daemon is started.

    > One more thing: I found out what is happening so that pcscd dies in
    > my system: when I start the daemon in a shell, it starts running and
    > works perfectly. The problem is when I exit that shell. Even running
    > as a daemon, pcscd gets killed, I guess the shell does it. What I
    > don't understand is why it gets killed, as I looked at ps -ef | grep
    > pcscd and it gets listed with a parent process of 1 (init), not the
    > shell from which I started it. Please take a look at it.

    This is normal under Solaris (at least it happens to me with other
    daemons under Solaris). I think you have to use nohup.

    > Finally, I have adapted one of the /etc/init.d scripts to launch and
    > kill pcscd on init state changes. I have tested it and it doesn't
    > hang Solaris on shutdown anymore. I thought it would be useful to go
    > into the distribution. I only dnn't know whether I can distribute a
    > copy of one of Solaris original files. Is there any problem?
    > Well. I guess pcsc-lite is now usable on my machine, as long as I
    > don't try to stop and start it on a shell.

    Better than modifiying the Solaris init.d scripts, I would create my
    own /etc/init.d/pcscd script and link it / copy it to /etc/rc2.d. The
    problem with including it in the global distribution is than this
    script is different depending on the OS and even for the same OS you
    can have different styles of init.d scripts. The Debian package has
    it's own init.d script, that uses Debian specific comman
    start-stop-daemon, that wouldn't run on SuSe, f.i. or in other UNIX's.
    So we would need to distribute a bunch of init scripts.

    ***************************************************************
    Unix Smart Card Developers - M.U.S.C.L.E.
    (Movement for the Use of Smart Cards in a Linux Environment)
    http://www.linuxnet.com/
    To unsubscribe send an email to majordomolinuxnet.com with
    unsubscribe sclinux
    ***************************************************************