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

The -h option is overridden by _cupsSetDefaults settings when the IPP port is not given #4675

Closed
michaelrsweet opened this issue Jul 16, 2015 · 3 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 2.0.3
CUPS.org User: vinc17

The -h option (e.g. for lpstat) is ignored when the server name is not followed by the port:

ypig:~> lpstat -h localhost -H -a
lipps.lip.ens-lyon.fr:443
[output: all remote printers]

ypig:~> lpstat -h localhost:631 -H -a
localhost:631
lpstat: No destinations added.

In latrace output, the first difference between the two invocations occurs in cupsSetServer [/usr/lib/x86_64-linux-gnu/libcups.so.2], here in cups/usersys.c:

if (cg->server[0] != '/' && (port = strrchr(cg->server, ':')) != NULL &&
    !strchr(port, ']') && isdigit(port[1] & 255))
{
  *port++ = '\0';

  cg->ipp_port = atoi(port);
}

This is expected. The next difference occurs here in ippPort() in cups/ipp-support.c:

if (!cg->ipp_port)
_cupsSetDefaults();

_cupsSetDefaults() is called only when the port is not provided. This means that by default, cg->ipp_port is 0. The default port should not be 0. This makes no sense!

My Debian bug report:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=711327
and the above explanation:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=711327#40

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Vincent,

The default port has to be 0 to force the call to _cupsSetDefaults, but afterwards it should no longer be 0...

Investigating...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

OK, looks like cupsSetServer did not set the default port while _cupsSetDefaults does. Fix attached.

@michaelrsweet
Copy link
Collaborator Author

"str4675.patch":

Index: cups/usersys.c

--- cups/usersys.c (revision 12810)
+++ cups/usersys.c (working copy)
@@ -68,6 +68,7 @@
static void cups_finalize_client_conf(_cups_client_conf_t *cc);
static void cups_init_client_conf(_cups_client_conf_t *cc);
static void cups_read_client_conf(cups_file_t *fp, _cups_client_conf_t *cc);
+static void cups_set_default_ipp_port(_cups_globals_t *cg);
static void cups_set_encryption(_cups_client_conf_t *cc, const char *value);
#ifdef HAVE_GSSAPI
static void cups_set_gss_service_name(_cups_client_conf_t *cc, const char *value);
@@ -382,6 +383,9 @@
cg->ipp_port = atoi(port);
}

  • if (!cg->ipp_port)
  •  cups_set_default_ipp_port(cg);
    
    if (cg->server[0] == '/')
    strlcpy(cg->servername, "localhost", sizeof(cg->servername));
    else
    @@ -392,6 +396,7 @@
    cg->server[0] = '\0';
    cg->servername[0] = '\0';
    cg->server_version = 20;
  • cg->ipp_port = 0;
    }

if (cg->http)
@@ -908,18 +913,8 @@
cupsSetServer(cc.server_name);

if (!cg->ipp_port)

  • {
  • const char ipp_port; / IPP_PORT environment variable */
  • cups_set_default_ipp_port(cg);
  • if ((ipp_port = getenv("IPP_PORT")) != NULL)
  • {
  •  if ((cg->ipp_port = atoi(ipp_port)) <= 0)
    
  •    cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
    
  • }
  • else
  •  cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
    

- }

if (!cg->user[0])
strlcpy(cg->user, cc.user, sizeof(cg->user));

@@ -1151,6 +1146,26 @@

/*

  • * 'cups_set_default_ipp_port()' - Set the default IPP port value.
  • */
    +
    +static void
    +cups_set_default_ipp_port(
  • _cups_globals_t cg) / I - Global data */
    +{
  • const char ipp_port; / IPP_PORT environment variable */
  • if ((ipp_port = getenv("IPP_PORT")) != NULL)
  • {
  • if ((cg->ipp_port = atoi(ipp_port)) <= 0)
  •  cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
    
  • }
  • else
  • cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
    +}

+/*

  • 'cups_set_encryption()' - Set the Encryption value.
    */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant