Deleted Added
full compact
printjob.c (5445) printjob.c (8094)
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 524 unchanged lines hidden (view full) ---

533 av[6] = 0;
534 fo = ofd;
535 goto start;
536 }
537 pipe(p);
538 if ((prchild = dofork(DORETURN)) == 0) { /* child */
539 dup2(fi, 0); /* file is stdin */
540 dup2(p[1], 1); /* pipe is stdout */
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 524 unchanged lines hidden (view full) ---

533 av[6] = 0;
534 fo = ofd;
535 goto start;
536 }
537 pipe(p);
538 if ((prchild = dofork(DORETURN)) == 0) { /* child */
539 dup2(fi, 0); /* file is stdin */
540 dup2(p[1], 1); /* pipe is stdout */
541 closelog();
541 for (n = 3; n < NOFILE; n++)
542 (void) close(n);
543 execl(_PATH_PR, "pr", width, length,
544 "-h", *title ? title : " ", "-F", 0);
542 for (n = 3; n < NOFILE; n++)
543 (void) close(n);
544 execl(_PATH_PR, "pr", width, length,
545 "-h", *title ? title : " ", "-F", 0);
546 openlog("lpd", LOG_PID, LOG_LPR);
545 syslog(LOG_ERR, "cannot execl %s", _PATH_PR);
546 exit(2);
547 }
548 (void) close(p[1]); /* close output side */
549 (void) close(fi);
550 if (prchild < 0) {
551 prchild = 0;
552 (void) close(p[0]);

--- 93 unchanged lines hidden (view full) ---

646 }
647start:
648 if ((child = dofork(DORETURN)) == 0) { /* child */
649 dup2(fi, 0);
650 dup2(fo, 1);
651 n = open(tempfile, O_WRONLY|O_CREAT|O_TRUNC, 0664);
652 if (n >= 0)
653 dup2(n, 2);
547 syslog(LOG_ERR, "cannot execl %s", _PATH_PR);
548 exit(2);
549 }
550 (void) close(p[1]); /* close output side */
551 (void) close(fi);
552 if (prchild < 0) {
553 prchild = 0;
554 (void) close(p[0]);

--- 93 unchanged lines hidden (view full) ---

648 }
649start:
650 if ((child = dofork(DORETURN)) == 0) { /* child */
651 dup2(fi, 0);
652 dup2(fo, 1);
653 n = open(tempfile, O_WRONLY|O_CREAT|O_TRUNC, 0664);
654 if (n >= 0)
655 dup2(n, 2);
656 closelog();
654 for (n = 3; n < NOFILE; n++)
655 (void) close(n);
656 execv(prog, av);
657 for (n = 3; n < NOFILE; n++)
658 (void) close(n);
659 execv(prog, av);
660 openlog("lpd", LOG_PID, LOG_LPR);
657 syslog(LOG_ERR, "cannot execv %s", prog);
658 exit(2);
659 }
660 (void) close(fi);
661 if (child < 0)
662 status.w_retcode = 100;
663 else
664 while ((pid = wait((int *)&status)) > 0 && pid != child)

--- 338 unchanged lines hidden (view full) ---

1003 register char *cp;
1004 char buf[100];
1005 struct stat stb;
1006 FILE *fp;
1007
1008 pipe(p);
1009 if ((s = dofork(DORETURN)) == 0) { /* child */
1010 dup2(p[0], 0);
661 syslog(LOG_ERR, "cannot execv %s", prog);
662 exit(2);
663 }
664 (void) close(fi);
665 if (child < 0)
666 status.w_retcode = 100;
667 else
668 while ((pid = wait((int *)&status)) > 0 && pid != child)

--- 338 unchanged lines hidden (view full) ---

1007 register char *cp;
1008 char buf[100];
1009 struct stat stb;
1010 FILE *fp;
1011
1012 pipe(p);
1013 if ((s = dofork(DORETURN)) == 0) { /* child */
1014 dup2(p[0], 0);
1015 closelog();
1011 for (i = 3; i < NOFILE; i++)
1012 (void) close(i);
1013 if ((cp = rindex(_PATH_SENDMAIL, '/')) != NULL)
1014 cp++;
1015 else
1016 cp = _PATH_SENDMAIL;
1017 sprintf(buf, "%s@%s", user, fromhost);
1018 execl(_PATH_SENDMAIL, cp, buf, 0);
1016 for (i = 3; i < NOFILE; i++)
1017 (void) close(i);
1018 if ((cp = rindex(_PATH_SENDMAIL, '/')) != NULL)
1019 cp++;
1020 else
1021 cp = _PATH_SENDMAIL;
1022 sprintf(buf, "%s@%s", user, fromhost);
1023 execl(_PATH_SENDMAIL, cp, buf, 0);
1024 openlog("lpd", LOG_PID, LOG_LPR);
1025 syslog(LOG_ERR, "cannot execl %s", _PATH_SENDMAIL);
1019 exit(0);
1020 } else if (s > 0) { /* parent */
1021 dup2(p[1], 1);
1022 printf("To: %s@%s\n", user, fromhost);
1023 printf("Subject: printer job\n\n");
1024 printf("Your printer job ");
1025 if (*jobname)
1026 printf("(%s) ", jobname);

--- 220 unchanged lines hidden (view full) ---

1247 if (!remote && OF) {
1248 int p[2];
1249 char *cp;
1250
1251 pipe(p);
1252 if ((ofilter = dofork(DOABORT)) == 0) { /* child */
1253 dup2(p[0], 0); /* pipe is std in */
1254 dup2(pfd, 1); /* printer is std out */
1026 exit(0);
1027 } else if (s > 0) { /* parent */
1028 dup2(p[1], 1);
1029 printf("To: %s@%s\n", user, fromhost);
1030 printf("Subject: printer job\n\n");
1031 printf("Your printer job ");
1032 if (*jobname)
1033 printf("(%s) ", jobname);

--- 220 unchanged lines hidden (view full) ---

1254 if (!remote && OF) {
1255 int p[2];
1256 char *cp;
1257
1258 pipe(p);
1259 if ((ofilter = dofork(DOABORT)) == 0) { /* child */
1260 dup2(p[0], 0); /* pipe is std in */
1261 dup2(pfd, 1); /* printer is std out */
1262 closelog();
1255 for (i = 3; i < NOFILE; i++)
1256 (void) close(i);
1257 if ((cp = rindex(OF, '/')) == NULL)
1258 cp = OF;
1259 else
1260 cp++;
1261 execl(OF, cp, width, length, 0);
1263 for (i = 3; i < NOFILE; i++)
1264 (void) close(i);
1265 if ((cp = rindex(OF, '/')) == NULL)
1266 cp = OF;
1267 else
1268 cp++;
1269 execl(OF, cp, width, length, 0);
1270 openlog("lpd", LOG_PID, LOG_LPR);
1262 syslog(LOG_ERR, "%s: %s: %m", printer, OF);
1263 exit(1);
1264 }
1265 (void) close(p[0]); /* close input side */
1266 ofd = p[1]; /* use pipe for output */
1267 } else {
1268 ofd = pfd;
1269 ofilter = 0;

--- 109 unchanged lines hidden ---
1271 syslog(LOG_ERR, "%s: %s: %m", printer, OF);
1272 exit(1);
1273 }
1274 (void) close(p[0]); /* close input side */
1275 ofd = p[1]; /* use pipe for output */
1276 } else {
1277 ofd = pfd;
1278 ofilter = 0;

--- 109 unchanged lines hidden ---