Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tunneling to LPD port problem (eg. lpd://remote:port/printer not working?) #247

Closed
michaelrsweet opened this issue Aug 27, 2003 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.1.5-2
CUPS.org User: kp.kyborg

Current version of CUPS doesn't support portnumber in lpd: style URI - this feature is necessary for tunneling lpd in some setups.

(eg tunnel from remote dynamic host to local via ssh mapping remote lpd port to a port number on local - is an effective way of handling dynamic ip printing).

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

The fix will be in 1.1.20rc1. Patch to follow for older versions...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in CVS for 1.1.20rc1.

Attached is a patch that adds support to 1.1.19; I doubt that the patch will work on 1.1.5-2.

@michaelrsweet
Copy link
Collaborator Author

"str247.patch":

Index: backend/lpd.c

RCS file: /development/cvs/cups/backend/lpd.c,v
retrieving revision 1.52
diff -u -r1.52 lpd.c
--- backend/lpd.c 2003/07/29 12:52:37 1.52
+++ backend/lpd.c 2003/08/28 14:23:45
@@ -119,8 +119,9 @@
*/

static int lpd_command(int lpd_fd, int timeout, char *format, ...);
-static int lpd_queue(char *hostname, char *printer, char *filename,

  •             char *user, char *title, int copies,
    

    +static int lpd_queue(const char *hostname, int port, const char *printer,

  •             const char *filename,
    
  •             const char *user, const char *title, int copies,
          int banner, int format, int order, int reserve,
          int manual_copies, int timeout);
    

    static void lpd_timeout(int sig);
    @@ -424,7 +425,7 @@
    copies = atoi(argv[4]);
    }

  • status = lpd_queue(hostname, resource + 1, filename,

  • status = lpd_queue(hostname, port, resource + 1, filename,
    argv[2] /* user */, title, copies,
    banner, format, order, reserve, manual_copies, timeout);

@@ -432,7 +433,7 @@
fprintf(stderr, "PAGE: 1 %d\n", atoi(argv[4]));
}
else

  • status = lpd_queue(hostname, resource + 1, filename,
  • status = lpd_queue(hostname, port, resource + 1, filename,
    argv[2] /* user */, title, 1,
    banner, format, order, reserve, 1, timeout);

@@ -517,24 +518,25 @@
*/

static int /* O - Zero on success, non-zero on failure /
-lpd_queue(char *hostname, /
I - Host to connect to */

  •      char _printer,       /_ I - Printer/queue name */
    
  • char _filename,       /_ I - File to print */
    
  •      char _user,          /_ I - Requesting user */
    
  • char _title,          /_ I - Job title */
    
  • int  copies,          /\* I - Number of copies */
    
  • int  banner,          /\* I - Print LPD banner? */
    
  •      int  format,         /\* I - Format specifier */
    
  •      int  order,          /\* I - Order of data/control files */
    
  • int  reserve,         /\* I - Reserve ports? */
    
  • int  manual_copies,       /\* I - Do copies by hand... */
    
  • int  timeout)         /\* I - Timeout... _/
    

    +lpd_queue(const char *hostname, /_ I - Host to connect to */

  •      int        port,     /\* I - Port to connect on */
    
  •      const char _printer,     /_ I - Printer/queue name */
    
  • const char _filename,     /_ I - File to print */
    
  •      const char _user,        /_ I - Requesting user */
    
  • const char _title,        /_ I - Job title */
    
  • int        copies,        /\* I - Number of copies */
    
  • int        banner,        /\* I - Print LPD banner? */
    
  •      int        format,       /\* I - Format specifier */
    
  •      int        order,        /\* I - Order of data/control files */
    
  • int        reserve,       /\* I - Reserve ports? */
    
  • int        manual_copies, /\* I - Do copies by hand... */
    
  • int        timeout)       /\* I - Timeout... _/
    

    {
    FILE *fp; /_ Job file /
    char localhost[255]; /
    Local host name /
    int error; /
    Error number /
    struct stat filestats; /
    File statistics */

  • int port; /* LPD connection port */

  • int lport; /* LPD connection local port /
    int fd; /
    LPD socket /
    char control[10240], /
    LPD control 'file' /
    *cptr; /
    Pointer into control file string */
    @@ -589,9 +591,9 @@
    memset(&addr, 0, sizeof(addr));
    memcpy(&(addr.sin_addr), hostaddr->h_addr, hostaddr->h_length);
    addr.sin_family = hostaddr->h_addrtype;

  • addr.sin_port = htons(515); /* LPD/printer service */

  • addr.sin_port = htons(port);

  • for (port = 732;;)

  • for (lport = 732;;)
    {
    if (getuid() || !reserve)
    {
    @@ -605,16 +607,16 @@
    return (1);
    }

  • port = 515;

  •    lport = 0;
    

    }
    else
    {
    /*

    • We're running as root and want to comply with RFC 1179. Reserve a
  • * priviledged port between 721 and 732...

    • priviledged lport between 721 and 732...
      */
  • if ((fd = rresvport(&port)) < 0)

  • if ((fd = rresvport(&lport)) < 0)
    {
    perror("ERROR: Unable to reserve port");
    sleep(30);
    @@ -651,7 +653,9 @@
    break;
    }

  • fprintf(stderr, "INFO: Connected from port %d...\n", port);

  • fprintf(stderr, "INFO: Connected to %s...\n", hostname);

  • fprintf(stderr, "DEBUG: Connected on ports %d (local %d)...\n", port,

  •        lport);
    

    /*

    • Next, open the print file and figure out its size...
      Index: cups/http-support.c

      RCS file: /development/cvs/cups/cups/http-support.c,v
      retrieving revision 1.5
      diff -u -r1.5 http-support.c
      --- cups/http-support.c 2003/02/04 05:08:43 1.5
      +++ cups/http-support.c 2003/08/28 14:23:45
      @@ -225,6 +225,8 @@
      *port = 443;
      else if (strcasecmp(method, "ipp") == 0)
      *port = ippPort();
  • else if (strcasecmp(method, "lpd") == 0)

  •  _port = 515;
    

    else if (strcasecmp(method, "socket") == 0) /_ Not registered yet... */
    *port = 9100;
    else

@michaelrsweet michaelrsweet added the enhancement New feature or request label Mar 17, 2016
@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant