]>
Commit | Line | Data |
---|---|---|
304fa3b3 JR |
1 | diff -up cups-1.5.0/config.h.in.systemd-socket cups-1.5.0/config.h.in |
2 | --- cups-1.5.0/config.h.in.systemd-socket 2012-01-17 16:22:39.776859041 +0000 | |
3 | +++ cups-1.5.0/config.h.in 2012-01-17 16:22:39.869857281 +0000 | |
4 | @@ -503,6 +503,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.5.0/config-scripts/cups-systemd.m4.systemd-socket cups-1.5.0/config-scripts/cups-systemd.m4 | |
19 | --- cups-1.5.0/config-scripts/cups-systemd.m4.systemd-socket 2012-01-17 16:22:39.870857262 +0000 | |
20 | +++ cups-1.5.0/config-scripts/cups-systemd.m4 2012-01-17 16:22:39.870857262 +0000 | |
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.5.0/configure.in.systemd-socket cups-1.5.0/configure.in | |
59 | --- cups-1.5.0/configure.in.systemd-socket 2010-11-20 01:03:46.000000000 +0000 | |
60 | +++ cups-1.5.0/configure.in 2012-01-17 16:22:39.876857149 +0000 | |
61 | @@ -37,6 +37,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-pdf.m4) | |
68 | sinclude(config-scripts/cups-scripting.m4) | |
69 | @@ -71,6 +72,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.5.0/cups/usersys.c.systemd-socket cups-1.5.0/cups/usersys.c | |
80 | --- cups-1.5.0/cups/usersys.c.systemd-socket 2012-01-17 16:22:39.691860648 +0000 | |
81 | +++ cups-1.5.0/cups/usersys.c 2012-01-17 16:22:39.877857130 +0000 | |
82 | @@ -770,7 +770,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.5.0/data/cups.path.in.systemd-socket cups-1.5.0/data/cups.path.in | |
92 | --- cups-1.5.0/data/cups.path.in.systemd-socket 2012-01-17 16:22:39.878857111 +0000 | |
93 | +++ cups-1.5.0/data/cups.path.in 2012-01-17 16:22:39.878857111 +0000 | |
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.5.0/data/cups.service.in.systemd-socket cups-1.5.0/data/cups.service.in | |
104 | --- cups-1.5.0/data/cups.service.in.systemd-socket 2012-01-17 16:22:39.878857111 +0000 | |
105 | +++ cups-1.5.0/data/cups.service.in 2012-01-17 16:29:04.259586106 +0000 | |
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.5.0/data/cups.socket.in.systemd-socket cups-1.5.0/data/cups.socket.in | |
118 | --- cups-1.5.0/data/cups.socket.in.systemd-socket 2012-01-17 16:22:39.878857111 +0000 | |
119 | +++ cups-1.5.0/data/cups.socket.in 2012-01-17 16:22:39.878857111 +0000 | |
120 | @@ -0,0 +1,11 @@ | |
121 | +[Unit] | |
122 | +Description=CUPS Printing Service Sockets | |
123 | + | |
124 | +[Socket] | |
125 | +ListenStream=@CUPS_DEFAULT_DOMAINSOCKET@ | |
126 | +ListenStream=631 | |
127 | +ListenDatagram=0.0.0.0:631 | |
128 | +BindIPv6Only=ipv6-only | |
129 | + | |
130 | +[Install] | |
131 | +WantedBy=sockets.target | |
132 | diff -up cups-1.5.0/data/Makefile.systemd-socket cups-1.5.0/data/Makefile | |
133 | --- cups-1.5.0/data/Makefile.systemd-socket 2011-05-12 06:21:56.000000000 +0100 | |
134 | +++ cups-1.5.0/data/Makefile 2012-01-17 16:22:39.879857092 +0000 | |
135 | @@ -112,6 +112,12 @@ install-data: | |
136 | $(INSTALL_DATA) $$file $(DATADIR)/ppdc; \ | |
137 | done | |
138 | $(INSTALL_DIR) -m 755 $(DATADIR)/profiles | |
139 | + if test "x$(SYSTEMD_UNITS)" != "x" ; then \ | |
140 | + $(INSTALL_DIR) -m 755 $(SYSTEMDUNITDIR); \ | |
141 | + for file in $(SYSTEMD_UNITS); do \ | |
142 | + $(INSTALL_DATA) $$file $(SYSTEMDUNITDIR); \ | |
143 | + done; \ | |
144 | + fi | |
145 | ||
146 | ||
147 | # | |
148 | @@ -159,6 +165,9 @@ uninstall: | |
149 | -$(RMDIR) $(DATADIR)/charsets | |
150 | -$(RMDIR) $(DATADIR)/banners | |
151 | -$(RMDIR) $(DATADIR) | |
152 | + for file in $(SYSTEMD_UNITS); do \ | |
153 | + $(RM) $(SYSTEMDUNITDIR)/$$file; \ | |
154 | + done | |
155 | ||
156 | ||
157 | # | |
158 | diff -up cups-1.5.0/Makedefs.in.systemd-socket cups-1.5.0/Makedefs.in | |
159 | --- cups-1.5.0/Makedefs.in.systemd-socket 2012-01-17 16:22:39.757859400 +0000 | |
160 | +++ cups-1.5.0/Makedefs.in 2012-01-17 16:22:39.879857092 +0000 | |
161 | @@ -143,6 +143,7 @@ CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ | |
162 | CXXLIBS = @CXXLIBS@ | |
163 | DBUS_NOTIFIER = @DBUS_NOTIFIER@ | |
164 | DBUS_NOTIFIERLIBS = @DBUS_NOTIFIERLIBS@ | |
165 | +SYSTEMD_UNITS = @SYSTEMD_UNITS@ | |
166 | DNSSD_BACKEND = @DNSSD_BACKEND@ | |
167 | DSOFLAGS = -L../cups @DSOFLAGS@ | |
168 | DSOLIBS = @DSOLIBS@ $(COMMONLIBS) | |
169 | @@ -151,6 +152,7 @@ FONTS = @FONTS@ | |
170 | IMGLIBS = @IMGLIBS@ | |
171 | IMGFILTERS = @IMGFILTERS@ | |
172 | LAUNCHDLIBS = @LAUNCHDLIBS@ | |
173 | +SDLIBS = @SDLIBS@ | |
174 | LDFLAGS = -L../cgi-bin -L../cups -L../filter -L../ppdc \ | |
175 | -L../scheduler @LDARCHFLAGS@ \ | |
176 | @LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM) | |
177 | @@ -267,6 +269,7 @@ PAMFILE = @PAMFILE@ | |
178 | ||
179 | DEFAULT_LAUNCHD_CONF = @DEFAULT_LAUNCHD_CONF@ | |
180 | DBUSDIR = @DBUSDIR@ | |
181 | +SYSTEMDUNITDIR = $(BUILDROOT)@systemdsystemunitdir@ | |
182 | ||
183 | ||
184 | # | |
185 | diff -up cups-1.5.0/scheduler/client.h.systemd-socket cups-1.5.0/scheduler/client.h | |
186 | --- cups-1.5.0/scheduler/client.h.systemd-socket 2011-03-25 21:25:38.000000000 +0000 | |
187 | +++ cups-1.5.0/scheduler/client.h 2012-01-17 16:22:39.880857073 +0000 | |
188 | @@ -75,6 +75,9 @@ typedef struct | |
189 | int fd; /* File descriptor for this server */ | |
190 | http_addr_t address; /* Bind address of socket */ | |
191 | http_encryption_t encryption; /* To encrypt or not to encrypt... */ | |
192 | +#ifdef HAVE_SYSTEMD | |
193 | + int is_systemd; /* Is this a systemd socket? */ | |
194 | +#endif /* HAVE_SYSTEMD */ | |
195 | } cupsd_listener_t; | |
196 | ||
197 | ||
198 | diff -up cups-1.5.0/scheduler/dirsvc.c.systemd-socket cups-1.5.0/scheduler/dirsvc.c | |
199 | --- cups-1.5.0/scheduler/dirsvc.c.systemd-socket 2012-01-17 16:22:39.813858341 +0000 | |
200 | +++ cups-1.5.0/scheduler/dirsvc.c 2012-01-17 16:22:39.885856979 +0000 | |
201 | @@ -1512,7 +1512,7 @@ cupsdStartBrowsing(void) | |
202 | } | |
203 | } | |
204 | ||
205 | - if (BrowseSocket >= 0) | |
206 | + if (BrowseSocket >= 0 && !BrowseSocketIsSystemd) | |
207 | { | |
208 | /* | |
209 | * Bind the socket to browse port... | |
210 | @@ -1556,13 +1556,17 @@ cupsdStartBrowsing(void) | |
211 | cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to set broadcast mode - %s.", | |
212 | strerror(errno)); | |
213 | ||
214 | + if (!BrowseSocketIsSystemd) | |
215 | + { | |
216 | #ifdef WIN32 | |
217 | - closesocket(BrowseSocket); | |
218 | + closesocket(BrowseSocket); | |
219 | #else | |
220 | - close(BrowseSocket); | |
221 | + close(BrowseSocket); | |
222 | #endif /* WIN32 */ | |
223 | ||
224 | - BrowseSocket = -1; | |
225 | + BrowseSocket = -1; | |
226 | + } | |
227 | + | |
228 | BrowseLocalProtocols &= ~BROWSE_CUPS; | |
229 | BrowseRemoteProtocols &= ~BROWSE_CUPS; | |
230 | ||
231 | @@ -1885,15 +1889,22 @@ cupsdStopBrowsing(void) | |
232 | if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_CUPS) && | |
233 | BrowseSocket >= 0) | |
234 | { | |
235 | - /* | |
236 | - * Close the socket and remove it from the input selection set. | |
237 | - */ | |
238 | + if (!BrowseSocketIsSystemd) | |
239 | + { | |
240 | + /* | |
241 | + * Close the socket. | |
242 | + */ | |
243 | ||
244 | #ifdef WIN32 | |
245 | - closesocket(BrowseSocket); | |
246 | + closesocket(BrowseSocket); | |
247 | #else | |
248 | - close(BrowseSocket); | |
249 | + close(BrowseSocket); | |
250 | #endif /* WIN32 */ | |
251 | + } | |
252 | + | |
253 | + /* | |
254 | + * Remove it from the input selection set. | |
255 | + */ | |
256 | ||
257 | cupsdRemoveSelect(BrowseSocket); | |
258 | BrowseSocket = -1; | |
259 | @@ -5683,11 +5694,14 @@ update_cups_browse(void) | |
260 | strerror(errno)); | |
261 | cupsdLogMessage(CUPSD_LOG_ERROR, "CUPS browsing turned off."); | |
262 | ||
263 | + if (!BrowseSocketIsSystemd) | |
264 | + { | |
265 | #ifdef WIN32 | |
266 | - closesocket(BrowseSocket); | |
267 | + closesocket(BrowseSocket); | |
268 | #else | |
269 | - close(BrowseSocket); | |
270 | + close(BrowseSocket); | |
271 | #endif /* WIN32 */ | |
272 | + } | |
273 | ||
274 | cupsdRemoveSelect(BrowseSocket); | |
275 | BrowseSocket = -1; | |
276 | diff -up cups-1.5.0/scheduler/dirsvc.h.systemd-socket cups-1.5.0/scheduler/dirsvc.h | |
277 | --- cups-1.5.0/scheduler/dirsvc.h.systemd-socket 2012-01-17 16:22:39.816858284 +0000 | |
278 | +++ cups-1.5.0/scheduler/dirsvc.h 2012-01-17 16:22:39.887856941 +0000 | |
279 | @@ -100,6 +100,8 @@ VAR int Browsing VALUE(TRUE), | |
280 | /* Short names for remote printers? */ | |
281 | BrowseSocket VALUE(-1), | |
282 | /* Socket for browsing */ | |
283 | + BrowseSocketIsSystemd VALUE(0), | |
284 | + /* BrowseSocket is systemd-provided? */ | |
285 | BrowsePort VALUE(IPP_PORT), | |
286 | /* Port number for broadcasts */ | |
287 | BrowseInterval VALUE(DEFAULT_INTERVAL), | |
288 | diff -up cups-1.5.0/scheduler/listen.c.systemd-socket cups-1.5.0/scheduler/listen.c | |
289 | --- cups-1.5.0/scheduler/listen.c.systemd-socket 2011-04-16 00:38:13.000000000 +0100 | |
290 | +++ cups-1.5.0/scheduler/listen.c 2012-01-17 16:22:39.888856922 +0000 | |
291 | @@ -401,7 +401,11 @@ cupsdStopListening(void) | |
292 | lis; | |
293 | lis = (cupsd_listener_t *)cupsArrayNext(Listeners)) | |
294 | { | |
295 | - if (lis->fd != -1) | |
296 | + if (lis->fd != -1 | |
297 | +#ifdef HAVE_SYSTEMD | |
298 | + && !lis->is_systemd | |
299 | +#endif /* HAVE_SYSTEMD */ | |
300 | + ) | |
301 | { | |
302 | #ifdef WIN32 | |
303 | closesocket(lis->fd); | |
304 | diff -up cups-1.5.0/scheduler/main.c.systemd-socket cups-1.5.0/scheduler/main.c | |
305 | --- cups-1.5.0/scheduler/main.c.systemd-socket 2012-01-17 16:22:39.830858019 +0000 | |
306 | +++ cups-1.5.0/scheduler/main.c 2012-01-17 16:22:39.890856884 +0000 | |
307 | @@ -26,6 +26,8 @@ | |
308 | * launchd_checkin() - Check-in with launchd and collect the listening | |
309 | * fds. | |
310 | * launchd_checkout() - Update the launchd KeepAlive file as needed. | |
311 | + * systemd_checkin() - Check-in with systemd and collect the | |
312 | + * listening fds. | |
313 | * parent_handler() - Catch USR1/CHLD signals... | |
314 | * process_children() - Process all dead children... | |
315 | * select_timeout() - Calculate the select timeout value. | |
316 | @@ -62,6 +64,10 @@ | |
317 | # endif /* !LAUNCH_JOBKEY_SERVICEIPC */ | |
318 | #endif /* HAVE_LAUNCH_H */ | |
319 | ||
320 | +#ifdef HAVE_SYSTEMD | |
321 | +#include <systemd/sd-daemon.h> | |
322 | +#endif /* HAVE_SYSTEMD */ | |
323 | + | |
324 | #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO) | |
325 | # include <malloc.h> | |
326 | #endif /* HAVE_MALLOC_H && HAVE_MALLINFO */ | |
327 | @@ -78,6 +84,9 @@ | |
328 | static void launchd_checkin(void); | |
329 | static void launchd_checkout(void); | |
330 | #endif /* HAVE_LAUNCHD */ | |
331 | +#ifdef HAVE_SYSTEMD | |
332 | +static void systemd_checkin(void); | |
333 | +#endif /* HAVE_SYSTEMD */ | |
334 | static void parent_handler(int sig); | |
335 | static void process_children(void); | |
336 | static void sigchld_handler(int sig); | |
337 | @@ -537,6 +546,13 @@ main(int argc, /* I - Number of comm | |
338 | } | |
339 | #endif /* HAVE_LAUNCHD */ | |
340 | ||
341 | +#ifdef HAVE_SYSTEMD | |
342 | + /* | |
343 | + * If we were started by systemd get the listen sockets file descriptors... | |
344 | + */ | |
345 | + systemd_checkin(); | |
346 | +#endif /* HAVE_SYSTEMD */ | |
347 | + | |
348 | /* | |
349 | * Startup the server... | |
350 | */ | |
351 | @@ -759,6 +775,15 @@ main(int argc, /* I - Number of comm | |
352 | } | |
353 | #endif /* HAVE_LAUNCHD */ | |
354 | ||
355 | +#ifdef HAVE_SYSTEMD | |
356 | + /* | |
357 | + * If we were started by systemd get the listen sockets file | |
358 | + * descriptors... | |
359 | + */ | |
360 | + | |
361 | + systemd_checkin(); | |
362 | +#endif /* HAVE_SYSTEMD */ | |
363 | + | |
364 | /* | |
365 | * Startup the server... | |
366 | */ | |
367 | @@ -1584,6 +1609,147 @@ launchd_checkout(void) | |
368 | } | |
369 | #endif /* HAVE_LAUNCHD */ | |
370 | ||
371 | +#ifdef HAVE_SYSTEMD | |
372 | +static void | |
373 | +systemd_checkin(void) | |
374 | +{ | |
375 | + int n, fd; | |
376 | + | |
377 | + n = sd_listen_fds(0); | |
378 | + if (n < 0) | |
379 | + { | |
380 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
381 | + "systemd_checkin: Failed to acquire sockets from systemd - %s", | |
382 | + strerror(-n)); | |
383 | + exit(EXIT_FAILURE); | |
384 | + return; | |
385 | + } | |
386 | + | |
387 | + if (n == 0) | |
388 | + return; | |
389 | + | |
390 | + for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd ++) | |
391 | + { | |
392 | + http_addr_t addr; | |
393 | + socklen_t addrlen = sizeof (addr); | |
394 | + int r; | |
395 | + cupsd_listener_t *lis; | |
396 | + char s[256]; | |
397 | + | |
398 | + r = sd_is_socket(fd, AF_UNSPEC, SOCK_STREAM, 1); | |
399 | + if (r < 0) | |
400 | + { | |
401 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
402 | + "systemd_checkin: Unable to verify socket type - %s", | |
403 | + strerror(-r)); | |
404 | + continue; | |
405 | + } | |
406 | + | |
407 | + if (!r) | |
408 | + { | |
409 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
410 | + "Browsing=%d", Browsing); | |
411 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
412 | + "BrowseLocalProtocols=%x", BrowseLocalProtocols); | |
413 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
414 | + "BrowseRemoteProtocols=%x", BrowseRemoteProtocols); | |
415 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
416 | + "BROWSE_CUPS=%x", BROWSE_CUPS); | |
417 | + if (Browsing && | |
418 | + ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_CUPS)) | |
419 | + { | |
420 | + r = sd_is_socket(fd, AF_UNSPEC, SOCK_DGRAM, 0); | |
421 | + if (r < 0) | |
422 | + { | |
423 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
424 | + "systemd_checkin: Unable to verify socket type - %s", | |
425 | + strerror(-r)); | |
426 | + continue; | |
427 | + } | |
428 | + | |
429 | + if (r) | |
430 | + { | |
431 | + /* | |
432 | + * This is the browse socket. | |
433 | + */ | |
434 | + | |
435 | + char addrstr[256]; | |
436 | + if (getsockname(fd, (struct sockaddr*) &addr, &addrlen)) | |
437 | + { | |
438 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
439 | + "systemd_checkin: Unable to get local address - %s", | |
440 | + strerror(errno)); | |
441 | + continue; | |
442 | + } | |
443 | + | |
444 | + httpAddrString (&addr, addrstr, sizeof (addrstr)); | |
445 | + BrowseSocket = fd; | |
446 | + BrowseSocketIsSystemd = 1; | |
447 | + cupsdLogMessage(CUPSD_LOG_DEBUG, | |
448 | + "systemd_checkin: Matched browse (port %d) with fd %d:%s...", | |
449 | + BrowsePort, fd, addrstr); | |
450 | + continue; | |
451 | + } | |
452 | + | |
453 | + } | |
454 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
455 | + "systemd_checkin: Socket not of the right type"); | |
456 | + continue; | |
457 | + } | |
458 | + | |
459 | + if (getsockname(fd, (struct sockaddr*) &addr, &addrlen)) | |
460 | + { | |
461 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
462 | + "systemd_checkin: Unable to get local address - %s", | |
463 | + strerror(errno)); | |
464 | + continue; | |
465 | + } | |
466 | + | |
467 | + /* | |
468 | + * Try to match the systemd socket address to one of the listeners... | |
469 | + */ | |
470 | + | |
471 | + for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners); | |
472 | + lis; | |
473 | + lis = (cupsd_listener_t *)cupsArrayNext(Listeners)) | |
474 | + if (httpAddrEqual(&lis->address, &addr)) | |
475 | + break; | |
476 | + | |
477 | + if (lis) | |
478 | + { | |
479 | + cupsdLogMessage(CUPSD_LOG_DEBUG, | |
480 | + "systemd_checkin: Matched existing listener %s with fd %d...", | |
481 | + httpAddrString(&(lis->address), s, sizeof(s)), fd); | |
482 | + } | |
483 | + else | |
484 | + { | |
485 | + cupsdLogMessage(CUPSD_LOG_DEBUG, | |
486 | + "systemd_checkin: Adding new listener %s with fd %d...", | |
487 | + httpAddrString(&addr, s, sizeof(s)), fd); | |
488 | + | |
489 | + if ((lis = calloc(1, sizeof(cupsd_listener_t))) == NULL) | |
490 | + { | |
491 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
492 | + "systemd_checkin: Unable to allocate listener - " | |
493 | + "%s.", strerror(errno)); | |
494 | + exit(EXIT_FAILURE); | |
495 | + } | |
496 | + | |
497 | + cupsArrayAdd(Listeners, lis); | |
498 | + | |
499 | + memcpy(&lis->address, &addr, sizeof(lis->address)); | |
500 | + } | |
501 | + | |
502 | + lis->fd = fd; | |
503 | + lis->is_systemd = 1; | |
504 | + | |
505 | +# ifdef HAVE_SSL | |
506 | + if (_httpAddrPort(&(lis->address)) == 443) | |
507 | + lis->encryption = HTTP_ENCRYPT_ALWAYS; | |
508 | +# endif /* HAVE_SSL */ | |
509 | + } | |
510 | +} | |
511 | +#endif /* HAVE_SYSTEMD */ | |
512 | ||
513 | /* | |
514 | * 'parent_handler()' - Catch USR1/CHLD signals... | |
515 | diff -up cups-1.5.0/scheduler/Makefile.systemd-socket cups-1.5.0/scheduler/Makefile | |
516 | --- cups-1.5.0/scheduler/Makefile.systemd-socket 2012-01-17 16:22:39.839857849 +0000 | |
517 | +++ cups-1.5.0/scheduler/Makefile 2012-01-17 16:22:39.891856865 +0000 | |
518 | @@ -382,7 +382,7 @@ cupsd: $(CUPSDOBJS) $(LIBCUPSMIME) ../cu | |
519 | $(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) -L. -lcupsmime \ | |
520 | $(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \ | |
521 | $(LIBPAPER) $(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBS) \ | |
522 | - $(LIBGSSAPI) $(LIBWRAP) | |
523 | + $(LIBGSSAPI) $(LIBWRAP) $(SDLIBS) | |
524 | ||
525 | cupsd-static: $(CUPSDOBJS) libcupsmime.a ../cups/$(LIBCUPSSTATIC) | |
526 | echo Linking $@... | |
527 | @@ -390,7 +390,7 @@ cupsd-static: $(CUPSDOBJS) libcupsmime.a | |
528 | $(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \ | |
529 | ../cups/$(LIBCUPSSTATIC) $(COMMONLIBS) $(LIBZ) $(LIBPAPER) \ | |
530 | $(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBGSSAPI) \ | |
531 | - $(LIBWRAP) | |
532 | + $(LIBWRAP) $(SDLIBS) | |
533 | ||
534 | ||
535 | # |