~ubuntu-branches/ubuntu/trusty/cups/trusty-proposed

55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
1
Description: Add support for creating pid files.
100.1.2 by Didier Raboud, Marc Deslauriers, Jamie Strandboge, Till Kamppeter, Martin Pitt, Didier Raboud
* New upstream release
2
Author: Martin Pitt <mpitt@debian.org>
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
3
Bug: http://www.cups.org/str.php?L2465
4
100.1.2 by Didier Raboud, Marc Deslauriers, Jamie Strandboge, Till Kamppeter, Martin Pitt, Didier Raboud
* New upstream release
5
Last-Update: 2012-11-29
6
62 by Martin Pitt, Till Kamppeter, Martin Pitt
[ Till Kamppeter ]
7
--- a/scheduler/conf.c
8
+++ b/scheduler/conf.c
99.1.28 by Till Kamppeter
* debian/patches/cups-1.6.4-changes.patch: Merged latest fixes from upstream,
9
@@ -178,7 +178,8 @@
100.1.2 by Didier Raboud, Marc Deslauriers, Jamie Strandboge, Till Kamppeter, Martin Pitt, Didier Raboud
* New upstream release
10
 #ifdef HAVE_AUTHORIZATION_H
99.1.7 by Didier Raboud
* Backport upstream configuration files split to address CVE-2012-5519.
11
   { "SystemGroupAuthKey",	&SystemGroupAuthKey,	CUPSD_VARTYPE_STRING },
104 by Till Kamppeter, Till Kamppeter, Martin Pitt
[ Till Kamppeter ]
12
 #endif /* HAVE_AUTHORIZATION_H */
100.1.2 by Didier Raboud, Marc Deslauriers, Jamie Strandboge, Till Kamppeter, Martin Pitt, Didier Raboud
* New upstream release
13
-  { "TempDir",			&TempDir,		CUPSD_VARTYPE_PATHNAME }
14
+  { "TempDir",			&TempDir,		CUPSD_VARTYPE_PATHNAME },
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
15
+  { "PidFile",			&PidFile,		CUPSD_VARTYPE_STRING }
16
 };
17
 
100.1.2 by Didier Raboud, Marc Deslauriers, Jamie Strandboge, Till Kamppeter, Martin Pitt, Didier Raboud
* New upstream release
18
 static int		default_auth_type = CUPSD_AUTH_AUTO;
99.1.28 by Till Kamppeter
* debian/patches/cups-1.6.4-changes.patch: Merged latest fixes from upstream,
19
@@ -594,6 +595,7 @@
100.1.5 by Didier Raboud
* New upstream release
20
   cupsdSetStringf(&ServerHeader, "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR,
85 by Martin Pitt, Till Kamppeter, Martin-Éric Racine, Martin Pitt
[ Till Kamppeter ]
21
                   CUPS_VERSION_MINOR);
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
22
   cupsdSetString(&StateDir, CUPS_STATEDIR);
23
+  cupsdSetString(&PidFile, "/var/run/cups/cupsd.pid");
24
 
25
   if (!strcmp(CUPS_DEFAULT_PRINTCAP, "/etc/printers.conf"))
26
     PrintcapFormat = PRINTCAP_SOLARIS;
99.1.28 by Till Kamppeter
* debian/patches/cups-1.6.4-changes.patch: Merged latest fixes from upstream,
27
@@ -3349,6 +3351,7 @@
100.1.2 by Didier Raboud, Marc Deslauriers, Jamie Strandboge, Till Kamppeter, Martin Pitt, Didier Raboud
* New upstream release
28
              !_cups_strcasecmp(line, "SystemGroup") ||
29
              !_cups_strcasecmp(line, "SystemGroupAuthKey") ||
30
              !_cups_strcasecmp(line, "TempDir") ||
31
+             !_cups_strcasecmp(line, "PidFile") ||
32
 	     !_cups_strcasecmp(line, "User"))
33
     {
99.1.22 by Didier Raboud, Didier Raboud, Brian Potkin
* New 1.6.3 upstream release:
34
       cupsdLogMessage(CUPSD_LOG_INFO,
62 by Martin Pitt, Till Kamppeter, Martin Pitt
[ Till Kamppeter ]
35
--- a/scheduler/conf.h
36
+++ b/scheduler/conf.h
99.1.28 by Till Kamppeter
* debian/patches/cups-1.6.4-changes.patch: Merged latest fixes from upstream,
37
@@ -245,6 +245,8 @@
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
38
 VAR int			SSLOptions		VALUE(CUPSD_SSL_NONE);
39
 					/* SSL/TLS options */
40
 #endif /* HAVE_SSL */
41
+VAR char		*PidFile		VALUE(NULL);
42
+					/* Debian CUPS pid file */
43
 
44
 #ifdef HAVE_LAUNCHD
104 by Till Kamppeter, Till Kamppeter, Martin Pitt
[ Till Kamppeter ]
45
 VAR int			LaunchdTimeout		VALUE(10);
62 by Martin Pitt, Till Kamppeter, Martin Pitt
[ Till Kamppeter ]
46
--- a/scheduler/main.c
47
+++ b/scheduler/main.c
100.1.5 by Didier Raboud
* New upstream release
48
@@ -90,6 +90,8 @@
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
49
 static void		sigterm_handler(int sig);
50
 static long		select_timeout(int fds);
104 by Till Kamppeter, Till Kamppeter, Martin Pitt
[ Till Kamppeter ]
51
 static void		usage(int status) __attribute__((noreturn));
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
52
+int			write_pid(void);
53
+int			remove_pid(void);
54
 
55
 
56
 /*
99.1.25 by Till Kamppeter
* New upstream release
57
@@ -645,6 +647,11 @@
58
     cupsdStartSystemMonitor();
59
 #endif /* __APPLE__ */
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
60
 
61
+  if (write_pid() == 0) {
62
+    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to write pid file");
63
+    return (1);
64
+  }
65
+
66
  /*
99.1.25 by Till Kamppeter
* New upstream release
67
   * Send server-started event...
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
68
   */
99.1.25 by Till Kamppeter
* New upstream release
69
@@ -1140,10 +1147,41 @@
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
70
 
71
   cupsdStopSelect();
72
 
73
+  remove_pid();
74
+
75
   return (!stop_scheduler);
76
 }
77
 
78
 
79
+/* 'write_pid()' - Write PID file.
80
+   'remove_pid()' - Delete PID file.
81
+*/
82
+int
83
+write_pid()
84
+{
85
+  FILE *f;
86
+  int fd;
87
+  int pid;
88
+  if (((fd = open(PidFile, O_RDWR|O_CREAT, 0644)) == -1)
89
+      || ((f = fdopen(fd, "r+")) == NULL) ) {
90
+    return 0;
91
+  }
92
+  pid = getpid();
93
+  if (!fprintf(f, "%d\n", pid)) {
94
+    close(fd);
95
+    return 0;
96
+  }
97
+  fflush(f);
98
+  close(fd);
99
+
100
+  return pid;
101
+}
102
+
103
+int
104
+remove_pid() {
105
+  return unlink(PidFile);
106
+}
107
+
108
 /*
62 by Martin Pitt, Till Kamppeter, Martin Pitt
[ Till Kamppeter ]
109
  * 'cupsdAddString()' - Copy and add a string to an array.
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
110
  */
62 by Martin Pitt, Till Kamppeter, Martin Pitt
[ Till Kamppeter ]
111
--- a/test/run-stp-tests.sh
112
+++ b/test/run-stp-tests.sh
99.1.25 by Till Kamppeter
* New upstream release
113
@@ -427,6 +427,7 @@
55 by Martin Pitt, Till Kamppeter, Martin Pitt
* New upstream version.
114
 DocumentRoot $root/doc
115
 RequestRoot /tmp/cups-$user/spool
116
 TempDir /tmp/cups-$user/spool/temp
117
+PidFile /tmp/cups-$user/cupsd.pid
118
 AccessLog /tmp/cups-$user/log/access_log
99.1.7 by Didier Raboud
* Backport upstream configuration files split to address CVE-2012-5519.
119
 ErrorLog /tmp/cups-$user/log/error_log
120
 PageLog /tmp/cups-$user/log/page_log