]> git.pld-linux.org Git - packages/cups.git/blob - cups-str1736.patch
b2cc0c50fbdfb146ac33ff6af5debc0bdb3631d5
[packages/cups.git] / cups-str1736.patch
1 --- cups-1.2.1/scheduler/client.c.orig  2006-05-22 17:34:01.000000000 +0200
2 +++ cups-1.2.1/scheduler/client.c       2006-06-05 14:54:53.436660500 +0200
3 @@ -1882,24 +1882,27 @@
4  
5  
6    if (con->filename)
7 +  {
8      fd = open(con->filename, O_RDONLY);
9 -  else
10 -    fd = open("/dev/null", O_RDONLY);
11  
12 -  if (fd < 0)
13 -  {
14 -    cupsdLogMessage(CUPSD_LOG_ERROR,
15 -                    "cupsdSendCommand: %d Unable to open \"%s\" for reading: %s",
16 -                    con->http.fd, con->filename ? con->filename : "/dev/null",
17 -                   strerror(errno));
18 -    return (0);
19 -  }
20 +    if (fd < 0)
21 +    {
22 +      cupsdLogMessage(CUPSD_LOG_ERROR,
23 +                     "cupsdSendCommand: %d Unable to open \"%s\" for reading: %s",
24 +                     con->http.fd, con->filename ? con->filename : "/dev/null",
25 +                     strerror(errno));
26 +      return (0);
27 +    }
28  
29 -  fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
30 +    fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
31 +  }
32 +  else
33 +    fd = -1;
34  
35    con->pipe_pid = pipe_command(con, fd, &(con->file), command, options, root);
36  
37 -  close(fd);
38 +  if (fd >= 0)
39 +    close(fd);
40  
41    cupsdLogMessage(CUPSD_LOG_INFO, "Started \"%s\" (pid=%d)", command,
42                    con->pipe_pid);
43 --- cups-1.2.1/scheduler/job.c.orig     2006-05-18 23:00:56.000000000 +0200
44 +++ cups-1.2.1/scheduler/job.c  2006-06-05 14:44:04.660114500 +0200
45 @@ -3090,28 +3090,6 @@
46    job->status = 0;
47    memset(job->filters, 0, sizeof(job->filters));
48  
49 -  filterfds[1][0] = open("/dev/null", O_RDONLY);
50 -
51 -  if (filterfds[1][0] < 0)
52 -  {
53 -    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open \"/dev/null\" - %s.",
54 -                    strerror(errno));
55 -    snprintf(printer->state_message, sizeof(printer->state_message),
56 -             "Unable to open \"/dev/null\" - %s.", strerror(errno));
57 -
58 -    cupsdAddPrinterHistory(printer);
59 -
60 -    cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
61 -                  "Job canceled because the server could not open /dev/null.");
62 -
63 -    goto abort_job;
64 -  }
65 -
66 -  fcntl(filterfds[1][0], F_SETFD, fcntl(filterfds[1][0], F_GETFD) | FD_CLOEXEC);
67 -
68 -  cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_job: filterfds[%d] = [ %d %d ]",
69 -                  1, filterfds[1][0], filterfds[1][1]);
70 -
71    for (i = 0, slot = 0, filter = (mime_filter_t *)cupsArrayFirst(filters);
72         filter;
73         i ++, filter = (mime_filter_t *)cupsArrayNext(filters))
74 @@ -3165,36 +3143,43 @@
75         else
76         {
77           job->print_pipes[0] = -1;
78 -         if (!strncmp(printer->device_uri, "file:/dev/", 10) &&
79 -             strcmp(printer->device_uri, "file:/dev/null"))
80 -           job->print_pipes[1] = open(printer->device_uri + 5,
81 -                                      O_WRONLY | O_EXCL);
82 -         else if (!strncmp(printer->device_uri, "file:///dev/", 12) &&
83 -                  strcmp(printer->device_uri, "file:///dev/null"))
84 -           job->print_pipes[1] = open(printer->device_uri + 7,
85 -                                      O_WRONLY | O_EXCL);
86 +         if (!strcmp(printer->device_uri, "file:/dev/null") ||
87 +             !strcmp(printer->device_uri, "file:///dev/null"))
88 +           job->print_pipes[1] = -1;
89           else
90 -           job->print_pipes[1] = open(printer->device_uri + 5,
91 -                                      O_WRONLY | O_CREAT | O_TRUNC, 0600);
92 -
93 -         if (job->print_pipes[1] < 0)
94           {
95 -            cupsdLogMessage(CUPSD_LOG_ERROR,
96 -                           "Unable to open output file \"%s\" - %s.",
97 -                           printer->device_uri, strerror(errno));
98 -            snprintf(printer->state_message, sizeof(printer->state_message),
99 -                    "Unable to open output file \"%s\" - %s.",
100 -                    printer->device_uri, strerror(errno));
101 +           if (!strncmp(printer->device_uri, "file:/dev/", 10))
102 +             job->print_pipes[1] = open(printer->device_uri + 5,
103 +                                        O_WRONLY | O_EXCL);
104 +           else if (!strncmp(printer->device_uri, "file:///dev/", 12))
105 +             job->print_pipes[1] = open(printer->device_uri + 7,
106 +                                        O_WRONLY | O_EXCL);
107 +           else if (!strncmp(printer->device_uri, "file:///", 8))
108 +             job->print_pipes[1] = open(printer->device_uri + 7,
109 +                                        O_WRONLY | O_CREAT | O_TRUNC, 0600);
110 +           else
111 +             job->print_pipes[1] = open(printer->device_uri + 5,
112 +                                        O_WRONLY | O_CREAT | O_TRUNC, 0600);
113  
114 -           cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
115 -                         "Job canceled because the server could not open the "
116 -                         "output file.");
117 +           if (job->print_pipes[1] < 0)
118 +           {
119 +              cupsdLogMessage(CUPSD_LOG_ERROR,
120 +                             "Unable to open output file \"%s\" - %s.",
121 +                             printer->device_uri, strerror(errno));
122 +              snprintf(printer->state_message, sizeof(printer->state_message),
123 +                      "Unable to open output file \"%s\" - %s.",
124 +                      printer->device_uri, strerror(errno));
125  
126 -            goto abort_job;
127 -         }
128 +             cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
129 +                           "Job canceled because the server could not open the "
130 +                           "output file.");
131  
132 -         fcntl(job->print_pipes[1], F_SETFD,
133 -               fcntl(job->print_pipes[1], F_GETFD) | FD_CLOEXEC);
134 +              goto abort_job;
135 +           }
136 +
137 +           fcntl(job->print_pipes[1], F_SETFD,
138 +                 fcntl(job->print_pipes[1], F_GETFD) | FD_CLOEXEC);
139 +          }
140         }
141  
142         cupsdLogMessage(CUPSD_LOG_DEBUG2,
143 @@ -3274,25 +3259,7 @@
144        argv[0] = sani_uri;
145  
146        filterfds[slot][0] = -1;
147 -      filterfds[slot][1] = open("/dev/null", O_WRONLY);
148 -
149 -      if (filterfds[slot][1] < 0)
150 -      {
151 -       cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open \"/dev/null\" - %s.",
152 -                       strerror(errno));
153 -       snprintf(printer->state_message, sizeof(printer->state_message),
154 -                "Unable to open \"/dev/null\" - %s.", strerror(errno));
155 -
156 -       cupsdAddPrinterHistory(printer);
157 -
158 -       cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
159 -                      "Job canceled because the server could not open a file.");
160 -
161 -        goto abort_job;
162 -      }
163 -
164 -      fcntl(filterfds[slot][1], F_SETFD,
165 -            fcntl(filterfds[slot][1], F_GETFD) | FD_CLOEXEC);
166 +      filterfds[slot][1] = -1;
167  
168        cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_job: backend=\"%s\"",
169                        command);
This page took 0.08233 seconds and 2 git commands to generate.