Magellan Linux

Annotation of /trunk/cups/patches/cups-1.6.1-systemd-socket.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2028 - (hide annotations) (download)
Wed Jan 16 10:59:19 2013 UTC (11 years, 3 months ago) by niro
File size: 12606 byte(s)
-patches for 1.6.1
1 niro 2028 diff -up cups-1.6b1/config.h.in.systemd-socket cups-1.6b1/config.h.in
2     --- cups-1.6b1/config.h.in.systemd-socket 2012-05-17 00:57:03.000000000 +0200
3     +++ cups-1.6b1/config.h.in 2012-05-28 11:16:35.657250584 +0200
4     @@ -506,6 +506,13 @@
5    
6    
7     /*
8     + * Do we have systemd support?
9     + */
10     +
11     +#undef HAVE_SYSTEMD
12     +
13     +
14     +/*
15     * Various scripting languages...
16     */
17    
18     diff -up cups-1.6b1/config-scripts/cups-systemd.m4.systemd-socket cups-1.6b1/config-scripts/cups-systemd.m4
19     --- cups-1.6b1/config-scripts/cups-systemd.m4.systemd-socket 2012-05-28 11:16:35.658250577 +0200
20     +++ cups-1.6b1/config-scripts/cups-systemd.m4 2012-05-28 11:16:35.658250577 +0200
21     @@ -0,0 +1,36 @@
22     +dnl
23     +dnl "$Id$"
24     +dnl
25     +dnl systemd stuff for CUPS.
26     +
27     +dnl Find whether systemd is available
28     +
29     +SDLIBS=""
30     +AC_ARG_WITH([systemdsystemunitdir],
31     + AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
32     + [], [with_systemdsystemunitdir=$($PKGCONFIG --variable=systemdsystemunitdir systemd)])
33     +if test "x$with_systemdsystemunitdir" != xno; then
34     + AC_MSG_CHECKING(for libsystemd-daemon)
35     + if $PKGCONFIG --exists libsystemd-daemon; then
36     + AC_MSG_RESULT(yes)
37     + SDCFLAGS=`$PKGCONFIG --cflags libsystemd-daemon`
38     + SDLIBS=`$PKGCONFIG --libs libsystemd-daemon`
39     + AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
40     + AC_DEFINE(HAVE_SYSTEMD)
41     + else
42     + AC_MSG_RESULT(no)
43     + fi
44     +fi
45     +
46     +if test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ; then
47     + SYSTEMD_UNITS="cups.service cups.socket cups.path"
48     +else
49     + SYSTEMD_UNITS=""
50     +fi
51     +
52     +AC_SUBST(SYSTEMD_UNITS)
53     +AC_SUBST(SDLIBS)
54     +
55     +dnl
56     +dnl "$Id$"
57     +dnl
58     diff -up cups-1.6b1/configure.in.systemd-socket cups-1.6b1/configure.in
59     --- cups-1.6b1/configure.in.systemd-socket 2012-04-23 19:26:57.000000000 +0200
60     +++ cups-1.6b1/configure.in 2012-05-28 11:16:35.658250577 +0200
61     @@ -33,6 +33,7 @@ sinclude(config-scripts/cups-pam.m4)
62     sinclude(config-scripts/cups-largefile.m4)
63     sinclude(config-scripts/cups-dnssd.m4)
64     sinclude(config-scripts/cups-launchd.m4)
65     +sinclude(config-scripts/cups-systemd.m4)
66     sinclude(config-scripts/cups-defaults.m4)
67     sinclude(config-scripts/cups-scripting.m4)
68    
69     @@ -66,6 +67,9 @@ AC_OUTPUT(Makedefs
70     conf/snmp.conf
71     cups-config
72     data/testprint
73     + data/cups.service
74     + data/cups.socket
75     + data/cups.path
76     desktop/cups.desktop
77     doc/help/ref-cupsd-conf.html
78     doc/help/standard.html
79     diff -up cups-1.6b1/cups/usersys.c.systemd-socket cups-1.6b1/cups/usersys.c
80     --- cups-1.6b1/cups/usersys.c.systemd-socket 2012-04-23 19:26:57.000000000 +0200
81     +++ cups-1.6b1/cups/usersys.c 2012-05-28 11:16:35.659250570 +0200
82     @@ -975,7 +975,7 @@ cups_read_client_conf(
83     struct stat sockinfo; /* Domain socket information */
84    
85     if (!stat(CUPS_DEFAULT_DOMAINSOCKET, &sockinfo) &&
86     - (sockinfo.st_mode & S_IRWXO) == S_IRWXO)
87     + (sockinfo.st_mode & (S_IROTH | S_IWOTH)) == (S_IROTH | S_IWOTH))
88     cups_server = CUPS_DEFAULT_DOMAINSOCKET;
89     else
90     #endif /* CUPS_DEFAULT_DOMAINSOCKET */
91     diff -up cups-1.6b1/data/cups.path.in.systemd-socket cups-1.6b1/data/cups.path.in
92     --- cups-1.6b1/data/cups.path.in.systemd-socket 2012-05-28 11:16:35.659250570 +0200
93     +++ cups-1.6b1/data/cups.path.in 2012-05-28 11:16:35.659250570 +0200
94     @@ -0,0 +1,8 @@
95     +[Unit]
96     +Description=CUPS Printer Service Spool
97     +
98     +[Path]
99     +PathExistsGlob=@CUPS_REQUESTS@/d*
100     +
101     +[Install]
102     +WantedBy=multi-user.target
103     diff -up cups-1.6b1/data/cups.service.in.systemd-socket cups-1.6b1/data/cups.service.in
104     --- cups-1.6b1/data/cups.service.in.systemd-socket 2012-05-28 11:16:35.659250570 +0200
105     +++ cups-1.6b1/data/cups.service.in 2012-05-28 11:16:35.659250570 +0200
106     @@ -0,0 +1,10 @@
107     +[Unit]
108     +Description=CUPS Printing Service
109     +
110     +[Service]
111     +ExecStart=@sbindir@/cupsd -f
112     +PrivateTmp=true
113     +
114     +[Install]
115     +Also=cups.socket cups.path
116     +WantedBy=printer.target
117     diff -up cups-1.6b1/data/cups.socket.in.systemd-socket cups-1.6b1/data/cups.socket.in
118     --- cups-1.6b1/data/cups.socket.in.systemd-socket 2012-05-28 11:16:35.660250563 +0200
119     +++ cups-1.6b1/data/cups.socket.in 2012-05-28 11:16:35.660250563 +0200
120     @@ -0,0 +1,8 @@
121     +[Unit]
122     +Description=CUPS Printing Service Sockets
123     +
124     +[Socket]
125     +ListenStream=@CUPS_DEFAULT_DOMAINSOCKET@
126     +
127     +[Install]
128     +WantedBy=sockets.target
129     diff -up cups-1.6b1/data/Makefile.systemd-socket cups-1.6b1/data/Makefile
130     --- cups-1.6b1/data/Makefile.systemd-socket 2011-08-27 11:23:01.000000000 +0200
131     +++ cups-1.6b1/data/Makefile 2012-05-28 11:16:35.660250563 +0200
132     @@ -100,6 +100,12 @@ install-data:
133     $(INSTALL_DATA) $$file $(DATADIR)/ppdc; \
134     done
135     $(INSTALL_DIR) -m 755 $(DATADIR)/profiles
136     + if test "x$(SYSTEMD_UNITS)" != "x" ; then \
137     + $(INSTALL_DIR) -m 755 $(SYSTEMDUNITDIR); \
138     + for file in $(SYSTEMD_UNITS); do \
139     + $(INSTALL_DATA) $$file $(SYSTEMDUNITDIR); \
140     + done; \
141     + fi
142    
143    
144     #
145     @@ -143,6 +149,9 @@ uninstall:
146     -$(RMDIR) $(DATADIR)/data
147     -$(RMDIR) $(DATADIR)/banners
148     -$(RMDIR) $(DATADIR)
149     + for file in $(SYSTEMD_UNITS); do \
150     + $(RM) $(SYSTEMDUNITDIR)/$$file; \
151     + done
152    
153    
154     #
155     diff -up cups-1.6b1/Makedefs.in.systemd-socket cups-1.6b1/Makedefs.in
156     --- cups-1.6b1/Makedefs.in.systemd-socket 2012-05-28 11:16:35.648250647 +0200
157     +++ cups-1.6b1/Makedefs.in 2012-05-28 11:16:35.660250563 +0200
158     @@ -134,11 +134,13 @@ CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@
159     CXXLIBS = @CXXLIBS@
160     DBUS_NOTIFIER = @DBUS_NOTIFIER@
161     DBUS_NOTIFIERLIBS = @DBUS_NOTIFIERLIBS@
162     +SYSTEMD_UNITS = @SYSTEMD_UNITS@
163     DNSSD_BACKEND = @DNSSD_BACKEND@
164     DSOFLAGS = -L../cups @DSOFLAGS@
165     DSOLIBS = @DSOLIBS@ $(COMMONLIBS)
166     DNSSDLIBS = @DNSSDLIBS@
167     LAUNCHDLIBS = @LAUNCHDLIBS@
168     +SDLIBS = @SDLIBS@
169     LDFLAGS = -L../cgi-bin -L../cups -L../filter -L../ppdc \
170     -L../scheduler @LDARCHFLAGS@ \
171     @LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM)
172     @@ -229,6 +231,7 @@ PAMFILE = @PAMFILE@
173    
174     DEFAULT_LAUNCHD_CONF = @DEFAULT_LAUNCHD_CONF@
175     DBUSDIR = @DBUSDIR@
176     +SYSTEMDUNITDIR = $(BUILDROOT)@systemdsystemunitdir@
177    
178    
179     #
180     diff -up cups-1.6b1/scheduler/client.h.systemd-socket cups-1.6b1/scheduler/client.h
181     --- cups-1.6b1/scheduler/client.h.systemd-socket 2012-03-22 21:30:20.000000000 +0100
182     +++ cups-1.6b1/scheduler/client.h 2012-05-28 11:16:35.661250556 +0200
183     @@ -77,6 +77,9 @@ typedef struct
184     int fd; /* File descriptor for this server */
185     http_addr_t address; /* Bind address of socket */
186     http_encryption_t encryption; /* To encrypt or not to encrypt... */
187     +#ifdef HAVE_SYSTEMD
188     + int is_systemd; /* Is this a systemd socket? */
189     +#endif /* HAVE_SYSTEMD */
190     } cupsd_listener_t;
191    
192    
193     diff -up cups-1.6b1/scheduler/listen.c.systemd-socket cups-1.6b1/scheduler/listen.c
194     --- cups-1.6b1/scheduler/listen.c.systemd-socket 2011-04-16 01:38:13.000000000 +0200
195     +++ cups-1.6b1/scheduler/listen.c 2012-05-28 11:16:35.661250556 +0200
196     @@ -401,7 +401,11 @@ cupsdStopListening(void)
197     lis;
198     lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
199     {
200     - if (lis->fd != -1)
201     + if (lis->fd != -1
202     +#ifdef HAVE_SYSTEMD
203     + && !lis->is_systemd
204     +#endif /* HAVE_SYSTEMD */
205     + )
206     {
207     #ifdef WIN32
208     closesocket(lis->fd);
209     diff -up cups-1.6b1/scheduler/main.c.systemd-socket cups-1.6b1/scheduler/main.c
210     --- cups-1.6b1/scheduler/main.c.systemd-socket 2012-05-28 11:16:35.612250897 +0200
211     +++ cups-1.6b1/scheduler/main.c 2012-05-28 12:49:32.698375139 +0200
212     @@ -26,6 +26,8 @@
213     * launchd_checkin() - Check-in with launchd and collect the listening
214     * fds.
215     * launchd_checkout() - Update the launchd KeepAlive file as needed.
216     + * systemd_checkin() - Check-in with systemd and collect the
217     + * listening fds.
218     * parent_handler() - Catch USR1/CHLD signals...
219     * process_children() - Process all dead children...
220     * select_timeout() - Calculate the select timeout value.
221     @@ -62,6 +64,10 @@
222     # endif /* !LAUNCH_JOBKEY_SERVICEIPC */
223     #endif /* HAVE_LAUNCH_H */
224    
225     +#ifdef HAVE_SYSTEMD
226     +#include <systemd/sd-daemon.h>
227     +#endif /* HAVE_SYSTEMD */
228     +
229     #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
230     # include <malloc.h>
231     #endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
232     @@ -78,6 +84,9 @@
233     static void launchd_checkin(void);
234     static void launchd_checkout(void);
235     #endif /* HAVE_LAUNCHD */
236     +#ifdef HAVE_SYSTEMD
237     +static void systemd_checkin(void);
238     +#endif /* HAVE_SYSTEMD */
239     static void parent_handler(int sig);
240     static void process_children(void);
241     static void sigchld_handler(int sig);
242     @@ -528,6 +537,13 @@ main(int argc, /* I - Number of comm
243     }
244     #endif /* HAVE_LAUNCHD */
245    
246     +#ifdef HAVE_SYSTEMD
247     + /*
248     + * If we were started by systemd get the listen sockets file descriptors...
249     + */
250     + systemd_checkin();
251     +#endif /* HAVE_SYSTEMD */
252     +
253     /*
254     * Startup the server...
255     */
256     @@ -738,6 +754,15 @@ main(int argc, /* I - Number of comm
257     }
258     #endif /* HAVE_LAUNCHD */
259    
260     +#ifdef HAVE_SYSTEMD
261     + /*
262     + * If we were started by systemd get the listen sockets file
263     + * descriptors...
264     + */
265     +
266     + systemd_checkin();
267     +#endif /* HAVE_SYSTEMD */
268     +
269     /*
270     * Startup the server...
271     */
272     @@ -1516,6 +1541,102 @@ launchd_checkout(void)
273     }
274     #endif /* HAVE_LAUNCHD */
275    
276     +#ifdef HAVE_SYSTEMD
277     +static void
278     +systemd_checkin(void)
279     +{
280     + int n, fd;
281     +
282     + n = sd_listen_fds(0);
283     + if (n < 0)
284     + {
285     + cupsdLogMessage(CUPSD_LOG_ERROR,
286     + "systemd_checkin: Failed to acquire sockets from systemd - %s",
287     + strerror(-n));
288     + exit(EXIT_FAILURE);
289     + return;
290     + }
291     +
292     + if (n == 0)
293     + return;
294     +
295     + for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd ++)
296     + {
297     + http_addr_t addr;
298     + socklen_t addrlen = sizeof (addr);
299     + int r;
300     + cupsd_listener_t *lis;
301     + char s[256];
302     +
303     + r = sd_is_socket(fd, AF_UNSPEC, SOCK_STREAM, 1);
304     + if (r < 0)
305     + {
306     + cupsdLogMessage(CUPSD_LOG_ERROR,
307     + "systemd_checkin: Unable to verify socket type - %s",
308     + strerror(-r));
309     + continue;
310     + }
311     +
312     + if (!r)
313     + {
314     + cupsdLogMessage(CUPSD_LOG_ERROR,
315     + "systemd_checkin: Socket not of the right type");
316     + continue;
317     + }
318     +
319     + if (getsockname(fd, (struct sockaddr*) &addr, &addrlen))
320     + {
321     + cupsdLogMessage(CUPSD_LOG_ERROR,
322     + "systemd_checkin: Unable to get local address - %s",
323     + strerror(errno));
324     + continue;
325     + }
326     +
327     + /*
328     + * Try to match the systemd socket address to one of the listeners...
329     + */
330     +
331     + for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
332     + lis;
333     + lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
334     + if (httpAddrEqual(&lis->address, &addr))
335     + break;
336     +
337     + if (lis)
338     + {
339     + cupsdLogMessage(CUPSD_LOG_DEBUG,
340     + "systemd_checkin: Matched existing listener %s with fd %d...",
341     + httpAddrString(&(lis->address), s, sizeof(s)), fd);
342     + }
343     + else
344     + {
345     + cupsdLogMessage(CUPSD_LOG_DEBUG,
346     + "systemd_checkin: Adding new listener %s with fd %d...",
347     + httpAddrString(&addr, s, sizeof(s)), fd);
348     +
349     + if ((lis = calloc(1, sizeof(cupsd_listener_t))) == NULL)
350     + {
351     + cupsdLogMessage(CUPSD_LOG_ERROR,
352     + "systemd_checkin: Unable to allocate listener - "
353     + "%s.", strerror(errno));
354     + exit(EXIT_FAILURE);
355     + }
356     +
357     + cupsArrayAdd(Listeners, lis);
358     +
359     + memcpy(&lis->address, &addr, sizeof(lis->address));
360     + }
361     +
362     + lis->fd = fd;
363     + lis->is_systemd = 1;
364     +
365     +# ifdef HAVE_SSL
366     + if (_httpAddrPort(&(lis->address)) == 443)
367     + lis->encryption = HTTP_ENCRYPT_ALWAYS;
368     +# endif /* HAVE_SSL */
369     + }
370     +}
371     +#endif /* HAVE_SYSTEMD */
372    
373     /*
374     * 'parent_handler()' - Catch USR1/CHLD signals...
375     diff -up cups-1.6b1/scheduler/Makefile.systemd-socket cups-1.6b1/scheduler/Makefile
376     --- cups-1.6b1/scheduler/Makefile.systemd-socket 2012-05-21 19:40:22.000000000 +0200
377     +++ cups-1.6b1/scheduler/Makefile 2012-05-28 11:16:35.663250542 +0200
378     @@ -371,7 +371,7 @@ cupsd: $(CUPSDOBJS) $(LIBCUPSMIME) ../cu
379     $(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) -L. -lcupsmime \
380     $(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \
381     $(LIBPAPER) $(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBS) \
382     - $(LIBGSSAPI) $(LIBWRAP)
383     + $(LIBGSSAPI) $(LIBWRAP) $(SDLIBS)
384    
385     cupsd-static: $(CUPSDOBJS) libcupsmime.a ../cups/$(LIBCUPSSTATIC)
386     echo Linking $@...
387     @@ -379,7 +379,7 @@ cupsd-static: $(CUPSDOBJS) libcupsmime.a
388     $(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \
389     ../cups/$(LIBCUPSSTATIC) $(COMMONLIBS) $(LIBZ) $(LIBPAPER) \
390     $(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBGSSAPI) \
391     - $(LIBWRAP)
392     + $(LIBWRAP) $(SDLIBS)
393    
394     tls.o: tls-darwin.c tls-gnutls.c tls-openssl.c
395