Update lpadmin documentation and show a meaningful error message for interface scripts (Issue #5111)
diff --git a/CHANGES.md b/CHANGES.md
index a987bc6..865d497 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,6 +6,8 @@
 ----------------------
 
 - Dropped RSS subscription management from the web interface (Issue #5012)
+- The lpadmin command now provides a better error message when an unsupported
+  System V interface script is used (Issue #5111)
 - Dropped hard-coded CGI scripting language support (Issue #5124)
 - Fixed the ippserver sample code when threading is disabled or unavailable
   (Issue #5154)
diff --git a/man/lpadmin.man b/man/lpadmin.man
index 1760728..6d77655 100644
--- a/man/lpadmin.man
+++ b/man/lpadmin.man
@@ -1,7 +1,7 @@
 .\"
 .\" lpadmin man page for CUPS.
 .\"
-.\" Copyright 2007-2016 by Apple Inc.
+.\" Copyright 2007-2017 by Apple Inc.
 .\" Copyright 1997-2006 by Easy Software Products.
 .\"
 .\" These coded instructions, statements, and computer programs are the
@@ -10,7 +10,7 @@
 .\" which should have been included with this file.  If this file is
 .\" file is missing or damaged, see the license at "http://www.cups.org/".
 .\"
-.TH lpadmin 8 "CUPS" "29 March 2016" "Apple Inc."
+.TH lpadmin 8 "CUPS" "1 November 2017" "Apple Inc."
 .SH NAME
 lpadmin \- configure cups printers and classes
 .SH SYNOPSIS
@@ -80,8 +80,6 @@
 Adds the named \fIprinter\fR to \fIclass\fR.
 If \fIclass\fR does not exist it is created automatically.
 .TP 5
-\fB\-i \fIppd-file\fR
-.TP 5
 \fB\-P \fIppd-file\fR
 Specifies a PostScript Printer Description (PPD) file to use with the printer.
 .TP 5
@@ -189,6 +187,12 @@
 .TP 5
 \fB\-L "\fIlocation\fB"\fR
 Provides a textual location of the destination.
+.SH DEPRECATED OPTIONS
+The following \fBlpadmin\fR options are deprecated:
+.TP 5
+\fB\-i \fIfilename\fR
+This option historically has been used to provide either a System V interface script or (as an implementation side-effect) a PPD file.
+Since interface scripts are no longer supported, the \fI-P\fR option is preferred for providing a PPD file for a printer.
 .SH CONFORMING TO
 Unlike the System V printing system, CUPS allows printer names to contain any printable character except SPACE, TAB, "/", or "#".
 Also, printer and class names are \fInot\fR case-sensitive.
@@ -196,6 +200,7 @@
 This differs from the System V version which requires the root user to execute this command.
 .SH NOTES
 The CUPS version of \fBlpadmin\fR does not support all of the System V or Solaris printing system configuration options.
+Interface scripts are not supported for security reasons.
 .SH EXAMPLE
 Create an IPP Everywhere print queue:
 .nf
diff --git a/systemv/lpadmin.c b/systemv/lpadmin.c
index c608c2d..b36ea48 100644
--- a/systemv/lpadmin.c
+++ b/systemv/lpadmin.c
@@ -1,7 +1,7 @@
 /*
  * "lpadmin" command for CUPS.
  *
- * Copyright 2007-2016 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 1997-2006 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
@@ -218,6 +218,25 @@
 
 		file = argv[i];
 	      }
+
+	      if (*opt == 'i')
+	      {
+	       /*
+	        * Check to see that the specified file is, in fact, a PPD...
+	        */
+
+                cups_file_t *fp = cupsFileOpen(file, "r");
+                char line[256];
+
+                if (!cupsFileGets(fp, line, sizeof(line)) || strncmp(line, "*PPD-Adobe", 10))
+                {
+                  _cupsLangPuts(stderr, _("lpadmin: System V interface scripts are no longer supported for security reasons."));
+                  cupsFileClose(fp);
+                  return (1);
+                }
+
+                cupsFileClose(fp);
+	      }
 	      break;
 
 	  case 'E' : /* Enable the printer/enable encryption */