Commit 30e10951 authored by Ludovic Rousseau's avatar Ludovic Rousseau

Use libsystemd instead sd-daemon.{c,h}

Remove files src/sd-daemon.{c,h} and use libsystemd to get
sd_listen_fds() and sd_is_socket() implementations.
So we do not have to maintain systemd specific code.

Use --disable-systemd if you do not have libsystemd available. In that
case I think you do not use systemd either.
parent 69602394
......@@ -150,6 +150,17 @@ AC_CHECK_LIB(socket, socket, [LIBS="$LIBS -lsocket"])
# check for mq_getattr()
AC_CHECK_LIB(rt, mq_getattr, [LIBS="$LIBS -lrt"])
# check for libsystemd
AC_ARG_ENABLE(libsystemd,
AS_HELP_STRING([--disable)libsystemd],[do not use libsystemd]),
[ use_libsystemd="${enableval}" ], [ use_libsystemd="yes" ] )
if test "$use_libsystemd" != "no"; then
PKG_CHECK_MODULES(LIBSYSTEMD, libsystemd,,
[ AC_MSG_ERROR([install libsystemd-dev or use --disable-libsystemd]) ])
AC_DEFINE(USE_LIBSYSTEMD, 1, [Use libsystemd])
PCSCLITE_FEATURES="${PCSCLITE_FEATURES} libsystemd"
fi
# --disable-serial
AC_ARG_ENABLE(serial,
AS_HELP_STRING([--disable-serial],[do not use serial reader.conf file]),
......@@ -431,6 +442,7 @@ ATR parsing messages: ${debugatr}
ipcdir: ${ipcdir}
use serial: ${use_serial}
use usb: ${use_usb}
use libsystemd: ${use_libsystemd}
systemd unit directory: ${with_systemdsystemunitdir}
serial config dir.: ${confdir_exp}
filter: ${use_filter}
......
......@@ -63,8 +63,6 @@ pcscd_SOURCES = \
prothandler.h \
readerfactory.c \
readerfactory.h \
sd-daemon.c \
sd-daemon.h \
simclist.c \
simclist.h \
sys_generic.h \
......@@ -79,9 +77,9 @@ pcscd_SOURCES = \
winscard_svc.c \
winscard_svc.h
pcscd_CFLAGS = $(CFLAGS) $(PTHREAD_CFLAGS) $(LIBUSB_CFLAGS) $(LIBUDEV_CFLAGS) \
$(POLKIT_CFLAGS) \
$(POLKIT_CFLAGS) $(LIBSYSTEMD_CFLAGS) \
-DPCSCD -DSIMCLIST_NO_DUMPRESTORE
pcscd_LDFLAGS = $(LDFLAGS) -export-dynamic
pcscd_LDFLAGS = $(LDFLAGS) $(LIBSYSTEMD_LIBS) -export-dynamic
pcscd_LDADD = \
$(PTHREAD_LIBS) $(COREFOUNDATION) \
$(LIBUSB_LIBS) $(IOKIT) $(LIBUDEV_LIBS) \
......@@ -92,10 +90,6 @@ fix-rights: install-sbinPROGRAMS
chgrp pcscd $(DESTDIR)$(sbindir)/pcscd
chmod g+s $(DESTDIR)$(sbindir)/pcscd
update-systemd:
curl -O http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c
curl -O http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-daemon.h
testpcsc_SOURCES = testpcsc.c
testpcsc_LDADD = libpcsclite.la
......
......@@ -53,12 +53,14 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef USE_LIBSYSTEMD
#include <systemd/sd-daemon.h>
#endif
#include "misc.h"
#include "pcsclite.h"
#include "pcscd.h"
#include "debuglog.h"
#include "sd-daemon.h"
#include "winscard_msg.h"
#include "winscard_svc.h"
#include "sys_generic.h"
......@@ -430,6 +432,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
#ifdef USE_LIBSYSTEMD
/*
* Check if systemd passed us any file descriptors
*/
......@@ -449,6 +452,7 @@ int main(int argc, char **argv)
else
SocketActivated = FALSE;
}
#endif
/*
* test the presence of /var/run/pcscd/pcscd.comm
......@@ -706,9 +710,11 @@ int main(int argc, char **argv)
/*
* Initialize the comm structure
*/
#ifdef USE_LIBSYSTEMD
if (SocketActivated)
rv = ListenExistingSocket(SD_LISTEN_FDS_START + 0);
else
#endif
rv = InitializeSocket();
if (rv)
......
This diff is collapsed.
This diff is collapsed.
......@@ -57,10 +57,12 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h>
#endif
#ifdef USE_LIBSYSTEMD
#include <systemd/sd-daemon.h>
#endif
#include "misc.h"
#include "pcscd.h"
#include "sd-daemon.h"
#include "winscard.h"
#include "debuglog.h"
#include "winscard_msg.h"
......@@ -174,6 +176,7 @@ INTERNAL int32_t InitializeSocket(void)
* @retval 0 Success
* @retval -1 Passed FD is not an UNIX socket.
*/
#ifdef USE_LIBSYSTEMD
INTERNAL int32_t ListenExistingSocket(int fd)
{
if (!sd_is_socket(fd, AF_UNIX, SOCK_STREAM, -1))
......@@ -185,6 +188,7 @@ INTERNAL int32_t ListenExistingSocket(int fd)
commonSocket = fd;
return 0;
}
#endif
/**
* @brief Looks for messages sent by clients.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment