Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 376021 | Differences between
and this patch

Collapse All | Expand All

(-)cups-1.5.0/config.h.in.systemd-socket (+7 lines)
Lines 503-508 Link Here
503
503
504
504
505
/*
505
/*
506
 * Do we have systemd support?
507
 */
508
509
#undef HAVE_SYSTEMD
510
511
512
/*
506
 * Various scripting languages...
513
 * Various scripting languages...
507
 */
514
 */
508
515
(-)cups-1.5.0/config-scripts/cups-systemd.m4.systemd-socket (+36 lines)
Line 0 Link Here
1
dnl
2
dnl "$Id$"
3
dnl
4
dnl   systemd stuff for CUPS.
5
6
dnl Find whether systemd is available
7
8
SDLIBS=""
9
AC_ARG_WITH([systemdsystemunitdir],
10
        AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
11
        [], [with_systemdsystemunitdir=$($PKGCONFIG --variable=systemdsystemunitdir systemd)])
12
if test "x$with_systemdsystemunitdir" != xno; then
13
        AC_MSG_CHECKING(for libsystemd-daemon)
14
        if $PKGCONFIG --exists libsystemd-daemon; then
15
		AC_MSG_RESULT(yes)
16
        	SDCFLAGS=`$PKGCONFIG --cflags libsystemd-daemon`
17
        	SDLIBS=`$PKGCONFIG --libs libsystemd-daemon`
18
		AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
19
		AC_DEFINE(HAVE_SYSTEMD)
20
	else
21
		AC_MSG_RESULT(no)
22
	fi
23
fi
24
25
if test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ; then
26
        SYSTEMD_UNITS="cups.service cups.socket cups.path"
27
else
28
        SYSTEMD_UNITS=""
29
fi
30
31
AC_SUBST(SYSTEMD_UNITS)
32
AC_SUBST(SDLIBS)
33
34
dnl
35
dnl "$Id$"
36
dnl
(-)cups-1.5.0/configure.in.systemd-socket (+4 lines)
Lines 37-42 sinclude(config-scripts/cups-pam.m4) Link Here
37
sinclude(config-scripts/cups-largefile.m4)
37
sinclude(config-scripts/cups-largefile.m4)
38
sinclude(config-scripts/cups-dnssd.m4)
38
sinclude(config-scripts/cups-dnssd.m4)
39
sinclude(config-scripts/cups-launchd.m4)
39
sinclude(config-scripts/cups-launchd.m4)
40
sinclude(config-scripts/cups-systemd.m4)
40
sinclude(config-scripts/cups-defaults.m4)
41
sinclude(config-scripts/cups-defaults.m4)
41
sinclude(config-scripts/cups-pdf.m4)
42
sinclude(config-scripts/cups-pdf.m4)
42
sinclude(config-scripts/cups-scripting.m4)
43
sinclude(config-scripts/cups-scripting.m4)
Lines 71-76 AC_OUTPUT(Makedefs Link Here
71
	  conf/snmp.conf
72
	  conf/snmp.conf
72
	  cups-config
73
	  cups-config
73
	  data/testprint
74
	  data/testprint
75
          data/cups.service
76
          data/cups.socket
77
          data/cups.path
74
	  desktop/cups.desktop
78
	  desktop/cups.desktop
75
	  doc/help/ref-cupsd-conf.html
79
	  doc/help/ref-cupsd-conf.html
76
	  doc/help/standard.html
80
	  doc/help/standard.html
(-)cups-1.5.0/cups/usersys.c.systemd-socket (-1 / +1 lines)
Lines 770-776 cups_read_client_conf( Link Here
770
    struct stat	sockinfo;		/* Domain socket information */
770
    struct stat	sockinfo;		/* Domain socket information */
771
771
772
    if (!stat(CUPS_DEFAULT_DOMAINSOCKET, &sockinfo) &&
772
    if (!stat(CUPS_DEFAULT_DOMAINSOCKET, &sockinfo) &&
773
	(sockinfo.st_mode & S_IRWXO) == S_IRWXO)
773
	(sockinfo.st_mode & (S_IROTH | S_IWOTH)) == (S_IROTH | S_IWOTH))
774
      cups_server = CUPS_DEFAULT_DOMAINSOCKET;
774
      cups_server = CUPS_DEFAULT_DOMAINSOCKET;
775
    else
775
    else
776
#endif /* CUPS_DEFAULT_DOMAINSOCKET */
776
#endif /* CUPS_DEFAULT_DOMAINSOCKET */
(-)cups-1.5.0/data/cups.path.in.systemd-socket (+8 lines)
Line 0 Link Here
1
[Unit]
2
Description=CUPS Printer Service Spool
3
4
[Path]
5
PathExistsGlob=@CUPS_REQUESTS@/d*
6
7
[Install]
8
WantedBy=multi-user.target
(-)cups-1.5.0/data/cups.service.in.systemd-socket (+9 lines)
Line 0 Link Here
1
[Unit]
2
Description=CUPS Printing Service
3
4
[Service]
5
ExecStart=@sbindir@/cupsd -f
6
7
[Install]
8
Also=cups.socket cups.path
9
WantedBy=printer.target
(-)cups-1.5.0/data/cups.socket.in.systemd-socket (+10 lines)
Line 0 Link Here
1
[Unit]
2
Description=CUPS Printing Service Sockets
3
4
[Socket]
5
ListenStream=@CUPS_DEFAULT_DOMAINSOCKET@
6
ListenStream=631
7
BindIPv6Only=ipv6-only
8
9
[Install]
10
WantedBy=sockets.target
(-)cups-1.5.0/data/Makefile.systemd-socket (+9 lines)
Lines 112-117 install-data: Link Here
112
		$(INSTALL_DATA) $$file $(DATADIR)/ppdc; \
112
		$(INSTALL_DATA) $$file $(DATADIR)/ppdc; \
113
	done
113
	done
114
	$(INSTALL_DIR) -m 755 $(DATADIR)/profiles
114
	$(INSTALL_DIR) -m 755 $(DATADIR)/profiles
115
	if test "x$(SYSTEMD_UNITS)" != "x" ; then \
116
		$(INSTALL_DIR) -m 755 $(SYSTEMDUNITDIR); \
117
		for file in $(SYSTEMD_UNITS); do \
118
			$(INSTALL_DATA) $$file $(SYSTEMDUNITDIR); \
119
		done; \
120
	fi
115
121
116
122
117
#
123
#
Lines 159-164 uninstall: Link Here
159
	-$(RMDIR) $(DATADIR)/charsets
165
	-$(RMDIR) $(DATADIR)/charsets
160
	-$(RMDIR) $(DATADIR)/banners
166
	-$(RMDIR) $(DATADIR)/banners
161
	-$(RMDIR) $(DATADIR)
167
	-$(RMDIR) $(DATADIR)
168
	for file in $(SYSTEMD_UNITS); do \
169
		$(RM) $(SYSTEMDUNITDIR)/$$file; \
170
	done
162
171
163
172
164
#
173
#
(-)cups-1.5.0/Makedefs.in.systemd-socket (+3 lines)
Lines 143-148 CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ Link Here
143
CXXLIBS		=	@CXXLIBS@
143
CXXLIBS		=	@CXXLIBS@
144
DBUS_NOTIFIER	=	@DBUS_NOTIFIER@
144
DBUS_NOTIFIER	=	@DBUS_NOTIFIER@
145
DBUS_NOTIFIERLIBS =	@DBUS_NOTIFIERLIBS@
145
DBUS_NOTIFIERLIBS =	@DBUS_NOTIFIERLIBS@
146
SYSTEMD_UNITS   =       @SYSTEMD_UNITS@
146
DNSSD_BACKEND	=	@DNSSD_BACKEND@
147
DNSSD_BACKEND	=	@DNSSD_BACKEND@
147
DSOFLAGS	=	-L../cups @DSOFLAGS@
148
DSOFLAGS	=	-L../cups @DSOFLAGS@
148
DSOLIBS		=	@DSOLIBS@ $(COMMONLIBS)
149
DSOLIBS		=	@DSOLIBS@ $(COMMONLIBS)
Lines 151-156 FONTS = @FONTS@ Link Here
151
IMGLIBS		=	@IMGLIBS@
152
IMGLIBS		=	@IMGLIBS@
152
IMGFILTERS	=	@IMGFILTERS@
153
IMGFILTERS	=	@IMGFILTERS@
153
LAUNCHDLIBS	=	@LAUNCHDLIBS@
154
LAUNCHDLIBS	=	@LAUNCHDLIBS@
155
SDLIBS		=	@SDLIBS@
154
LDFLAGS		=	-L../cgi-bin -L../cups -L../filter -L../ppdc \
156
LDFLAGS		=	-L../cgi-bin -L../cups -L../filter -L../ppdc \
155
			-L../scheduler @LDARCHFLAGS@ \
157
			-L../scheduler @LDARCHFLAGS@ \
156
			@LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM)
158
			@LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM)
Lines 267-272 PAMFILE = @PAMFILE@ Link Here
267
269
268
DEFAULT_LAUNCHD_CONF =	@DEFAULT_LAUNCHD_CONF@
270
DEFAULT_LAUNCHD_CONF =	@DEFAULT_LAUNCHD_CONF@
269
DBUSDIR		=	@DBUSDIR@
271
DBUSDIR		=	@DBUSDIR@
272
SYSTEMDUNITDIR  =       $(BUILDROOT)@systemdsystemunitdir@
270
273
271
274
272
#
275
#
(-)cups-1.5.0/scheduler/client.h.systemd-socket (+3 lines)
Lines 75-80 typedef struct Link Here
75
  int			fd;		/* File descriptor for this server */
75
  int			fd;		/* File descriptor for this server */
76
  http_addr_t		address;	/* Bind address of socket */
76
  http_addr_t		address;	/* Bind address of socket */
77
  http_encryption_t	encryption;	/* To encrypt or not to encrypt... */
77
  http_encryption_t	encryption;	/* To encrypt or not to encrypt... */
78
#ifdef HAVE_SYSTEMD
79
  int			is_systemd;	/* Is this a systemd socket? */
80
#endif /* HAVE_SYSTEMD */
78
} cupsd_listener_t;
81
} cupsd_listener_t;
79
82
80
83
(-)cups-1.5.0/scheduler/listen.c.systemd-socket (-1 / +5 lines)
Lines 401-407 cupsdStopListening(void) Link Here
401
       lis;
401
       lis;
402
       lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
402
       lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
403
  {
403
  {
404
    if (lis->fd != -1)
404
    if (lis->fd != -1
405
#ifdef HAVE_SYSTEMD
406
        && !lis->is_systemd
407
#endif /* HAVE_SYSTEMD */
408
        )
405
    {
409
    {
406
#ifdef WIN32
410
#ifdef WIN32
407
      closesocket(lis->fd);
411
      closesocket(lis->fd);
(-)cups-1.5.0/scheduler/main.c.systemd-socket (+119 lines)
Lines 26-31 Link Here
26
 *   launchd_checkin()     - Check-in with launchd and collect the listening
26
 *   launchd_checkin()     - Check-in with launchd and collect the listening
27
 *                           fds.
27
 *                           fds.
28
 *   launchd_checkout()    - Update the launchd KeepAlive file as needed.
28
 *   launchd_checkout()    - Update the launchd KeepAlive file as needed.
29
 *   systemd_checkin()     - Check-in with systemd and collect the
30
 *                           listening fds.
29
 *   parent_handler()      - Catch USR1/CHLD signals...
31
 *   parent_handler()      - Catch USR1/CHLD signals...
30
 *   process_children()    - Process all dead children...
32
 *   process_children()    - Process all dead children...
31
 *   select_timeout()      - Calculate the select timeout value.
33
 *   select_timeout()      - Calculate the select timeout value.
Lines 62-67 Link Here
62
#  endif /* !LAUNCH_JOBKEY_SERVICEIPC */
64
#  endif /* !LAUNCH_JOBKEY_SERVICEIPC */
63
#endif /* HAVE_LAUNCH_H */
65
#endif /* HAVE_LAUNCH_H */
64
66
67
#ifdef HAVE_SYSTEMD
68
#include <systemd/sd-daemon.h>
69
#endif /* HAVE_SYSTEMD */
70
65
#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
71
#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
66
#  include <malloc.h>
72
#  include <malloc.h>
67
#endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
73
#endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
Lines 78-83 Link Here
78
static void		launchd_checkin(void);
84
static void		launchd_checkin(void);
79
static void		launchd_checkout(void);
85
static void		launchd_checkout(void);
80
#endif /* HAVE_LAUNCHD */
86
#endif /* HAVE_LAUNCHD */
87
#ifdef HAVE_SYSTEMD
88
static void		systemd_checkin(void);
89
#endif /* HAVE_SYSTEMD */
81
static void		parent_handler(int sig);
90
static void		parent_handler(int sig);
82
static void		process_children(void);
91
static void		process_children(void);
83
static void		sigchld_handler(int sig);
92
static void		sigchld_handler(int sig);
Lines 537-542 main(int argc, /* I - Number of comm Link Here
537
  }
546
  }
538
#endif /* HAVE_LAUNCHD */
547
#endif /* HAVE_LAUNCHD */
539
548
549
#ifdef HAVE_SYSTEMD
550
 /*
551
  * If we were started by systemd get the listen sockets file descriptors...
552
  */
553
  systemd_checkin();
554
#endif /* HAVE_SYSTEMD */
555
540
 /*
556
 /*
541
  * Startup the server...
557
  * Startup the server...
542
  */
558
  */
Lines 759-764 main(int argc, /* I - Number of comm Link Here
759
	}
775
	}
760
#endif /* HAVE_LAUNCHD */
776
#endif /* HAVE_LAUNCHD */
761
777
778
#ifdef HAVE_SYSTEMD
779
       /*
780
	* If we were started by systemd get the listen sockets file
781
	* descriptors...
782
        */
783
784
        systemd_checkin();
785
#endif /* HAVE_SYSTEMD */
786
762
       /*
787
       /*
763
        * Startup the server...
788
        * Startup the server...
764
        */
789
        */
Lines 1584-1589 launchd_checkout(void) Link Here
1584
}
1609
}
1585
#endif /* HAVE_LAUNCHD */
1610
#endif /* HAVE_LAUNCHD */
1586
1611
1612
#ifdef HAVE_SYSTEMD
1613
static void
1614
systemd_checkin(void)
1615
{
1616
  int n, fd;
1617
1618
  n = sd_listen_fds(0);
1619
  if (n < 0)
1620
  {
1621
    cupsdLogMessage(CUPSD_LOG_ERROR,
1622
           "systemd_checkin: Failed to acquire sockets from systemd - %s",
1623
           strerror(-n));
1624
    exit(EXIT_FAILURE);
1625
    return;
1626
  }
1627
1628
  if (n == 0)
1629
    return;
1630
1631
  for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd ++)
1632
  {
1633
    http_addr_t addr;
1634
    socklen_t addrlen = sizeof (addr);
1635
    int r;
1636
    cupsd_listener_t *lis;
1637
    char s[256];
1638
1639
    r = sd_is_socket(fd, AF_UNSPEC, SOCK_STREAM, 1);
1640
    if (r < 0) {
1641
      cupsdLogMessage(CUPSD_LOG_ERROR,
1642
             "systemd_checkin: Unable to verify socket type - %s",
1643
             strerror(-r));
1644
      continue;
1645
    }
1646
1647
    if (!r) {
1648
      cupsdLogMessage(CUPSD_LOG_ERROR,
1649
             "systemd_checkin: Socket not of the right type");
1650
      continue;
1651
    }
1652
1653
    if (getsockname(fd, (struct sockaddr*) &addr, &addrlen))
1654
    {
1655
      cupsdLogMessage(CUPSD_LOG_ERROR,
1656
             "systemd_checkin: Unable to get local address - %s",
1657
             strerror(errno));
1658
      continue;
1659
    }
1660
1661
     /*
1662
    * Try to match the systemd socket address to one of the listeners...
1663
    */
1664
1665
    for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
1666
       lis;
1667
       lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
1668
      if (httpAddrEqual(&lis->address, &addr))
1669
      break;
1670
1671
    if (lis)
1672
    {
1673
      cupsdLogMessage(CUPSD_LOG_DEBUG,
1674
                      "systemd_checkin: Matched existing listener %s with fd %d...",
1675
                      httpAddrString(&(lis->address), s, sizeof(s)), fd);
1676
    }
1677
    else
1678
    {
1679
      cupsdLogMessage(CUPSD_LOG_DEBUG,
1680
                      "systemd_checkin: Adding new listener %s with fd %d...",
1681
                      httpAddrString(&addr, s, sizeof(s)), fd);
1682
1683
      if ((lis = calloc(1, sizeof(cupsd_listener_t))) == NULL)
1684
      {
1685
        cupsdLogMessage(CUPSD_LOG_ERROR,
1686
                        "systemd_checkin: Unable to allocate listener - "
1687
                        "%s.", strerror(errno));
1688
        exit(EXIT_FAILURE);
1689
      }
1690
1691
      cupsArrayAdd(Listeners, lis);
1692
1693
      memcpy(&lis->address, &addr, sizeof(lis->address));
1694
    }
1695
1696
    lis->fd = fd;
1697
    lis->is_systemd = 1;
1698
1699
#  ifdef HAVE_SSL
1700
    if (_httpAddrPort(&(lis->address)) == 443)
1701
      lis->encryption = HTTP_ENCRYPT_ALWAYS;
1702
#  endif /* HAVE_SSL */
1703
  }
1704
}
1705
#endif /* HAVE_SYSTEMD */
1587
1706
1588
/*
1707
/*
1589
 * 'parent_handler()' - Catch USR1/CHLD signals...
1708
 * 'parent_handler()' - Catch USR1/CHLD signals...
(-)cups-1.5.0/scheduler/Makefile.systemd-socket (-2 / +2 lines)
Lines 382-388 cupsd: $(CUPSDOBJS) $(LIBCUPSMIME) ../cu Link Here
382
	$(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) -L. -lcupsmime \
382
	$(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) -L. -lcupsmime \
383
		$(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \
383
		$(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \
384
		$(LIBPAPER) $(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBS) \
384
		$(LIBPAPER) $(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBS) \
385
		$(LIBGSSAPI) $(LIBWRAP)
385
		$(LIBGSSAPI) $(LIBWRAP) $(SDLIBS)
386
386
387
cupsd-static:	$(CUPSDOBJS) libcupsmime.a ../cups/$(LIBCUPSSTATIC)
387
cupsd-static:	$(CUPSDOBJS) libcupsmime.a ../cups/$(LIBCUPSSTATIC)
388
	echo Linking $@...
388
	echo Linking $@...
Lines 390-396 cupsd-static: $(CUPSDOBJS) libcupsmime.a Link Here
390
		$(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \
390
		$(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \
391
		../cups/$(LIBCUPSSTATIC) $(COMMONLIBS) $(LIBZ) $(LIBPAPER) \
391
		../cups/$(LIBCUPSSTATIC) $(COMMONLIBS) $(LIBZ) $(LIBPAPER) \
392
		$(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBGSSAPI) \
392
		$(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBGSSAPI) \
393
		$(LIBWRAP)
393
		$(LIBWRAP) $(SDLIBS)
394
394
395
395
396
#
396
#

Return to bug 376021