ports/java/openjdk7/files/patch-src-share-classes-sun-print-PSPrinterJob.java
Jung-uk Kim d7cffff692 - Fix printing services. When CUPS is used, ${LOCALBASE}/bin/lpr must be
used to print a generated PostScript file.  When lpd(8) is used, lpr(1) from
base must be used.  Also, status command for lpc(8) requires a printer name.
If no argument is specified, i.e., "/usr/sbin/lpc status", then it displays
the command usage, i.e., "usage: status  {all | printer ...}".
Unfortunately, "usage" is interpreted as a printer name because ":" is
included.  Add "all" and adjust an expression for grep(1). [1]
- Use /proc/curproc/file to find its executable path if available.  It fixes
java/icedtea-web, for example. [2]

PR:		ports/178856 [1]
PR:		java/189905 [2]
2014-05-21 20:03:14 +00:00

36 lines
1.6 KiB
Java

--- jdk/src/share/classes/sun/print/PSPrinterJob.java
+++ jdk/src/share/classes/sun/print/PSPrinterJob.java
@@ -1568,9 +1568,31 @@
}
String osname = System.getProperty("os.name");
- if (osname.equals("Linux") || osname.equals("FreeBSD") || osname.equals("NetBSD") || osname.equals("OpenBSD") || osname.equals("OS X")) {
+ if (osname.equals("Linux") || osname.endsWith("BSD") || osname.contains("OS X")) {
+ String lprPath = "/usr/bin/lpr";
+ if (osname.endsWith("BSD")) {
+ final PrintService pservice = getPrintService();
+ Boolean isIPPPrinter =
+ (Boolean)java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction() {
+ public Object run() {
+ try {
+ Class psClass =
+ Class.forName("sun.print.IPPPrintService");
+ if (psClass.isInstance(pservice)) {
+ return Boolean.TRUE;
+ }
+ } catch (Throwable t) {
+ }
+ return Boolean.FALSE;
+ }
+ });
+ if (isIPPPrinter) {
+ lprPath = "%%LOCALBASE%%/bin/lpr";
+ }
+ }
execCmd = new String[ncomps];
- execCmd[n++] = "/usr/bin/lpr";
+ execCmd[n++] = lprPath;
if ((pFlags & PRINTER) != 0) {
execCmd[n++] = "-P" + printer;
}