/*
- * "$Id: ipp.c,v 1.38.2.21 2003/01/29 15:38:43 mike Exp $"
+ * "$Id: ipp.c,v 1.38.2.22 2003/01/31 21:24:22 mike Exp $"
*
* IPP backend for the Common UNIX Printing System (CUPS).
*
#include <cups/language.h>
#include <cups/string.h>
#include <signal.h>
+#include <sys/wait.h>
/*
{
fprintf(stderr, "ERROR: Unable to get PPD file for printer \"%s\" - %s.\n",
printer, ippErrorString(cupsLastError()));
- return (-1);
+ /*return (-1);*/
+ }
+ else
+ {
+ snprintf(ppdenv, sizeof(ppdenv), "PPD=%s", ppdfile);
+ putenv(ppdenv);
}
-
- snprintf(ppdenv, sizeof(ppdenv), "PPD=%s", ppdfile);
- putenv(ppdenv);
/*
* Then create a temporary file for printing...
if ((fd = cupsTempFd(filename, length)) < 0)
{
fprintf(stderr, "ERROR: Unable to create temporary file - %s.\n",
- printer, strerror(errno));
+ strerror(errno));
+ if (ppdfile)
+ unlink(ppdfile);
return (-1);
}
stat(argv[6], &fileinfo);
+ if (ppdfile)
+ chown(ppdfile, fileinfo.st_uid, fileinfo.st_gid);
+
+ fchown(fd, fileinfo.st_uid, fileinfo.st_gid);
+
/*
* Finally, run the filter to convert the file...
*/
perror("ERROR: Unable to exec pictwpstops");
return (errno);
}
- else if (pid < 0)
+
+ close(fd);
+
+ if (pid < 0)
{
/*
* Error!
*/
perror("ERROR: Unable to fork pictwpstops");
- close(fd);
unlink(filename);
+ if (ppdfile)
+ unlink(ppdfile);
return (-1);
}
perror("ERROR: Unable to wait for pictwpstops");
close(fd);
unlink(filename);
+ if (ppdfile)
+ unlink(ppdfile);
return (-1);
}
+ if (ppdfile)
+ unlink(ppdfile);
+
close(fd);
if (status)
/*
- * End of "$Id: ipp.c,v 1.38.2.21 2003/01/29 15:38:43 mike Exp $".
+ * End of "$Id: ipp.c,v 1.38.2.22 2003/01/31 21:24:22 mike Exp $".
*/