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

"PAGE: total NUMBER" messages arent parsed, so allways 1 is logged in pagelog #3887

Closed
michaelrsweet opened this issue Jul 13, 2011 · 4 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.5-current
CUPS.org User: nerve

In function cupsdLogPage at scheduler/log.c
there is no code to parse the log entry

PAGE: total 2

from the filters,
so these give a line at page_log in form of

P020 40 HDA [13/Jul/2011:13:34:36 +0200] 1 1 - chsfsr00106.sfs-intra.net 0059xMhd.T02 - -

which is wrong, in cups 1.3 these give the line

P020 40 HDA [13/Jul/2011:13:34:36 +0200] total 1 - chsfsr00xxx.sfs-intra.net

Please readd the code to parse the "PAGE: total N" log messages from
filters or backends correct.

Thank you.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

The current code in the scheduler is parsing PAGE: messages of the form "total NNN" and logs them accordingly.

What operating system/Linux distribution are you using?

What driver are you using?

Did you compile CUPS 1.4.6 from source or install an existing binary package?

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: nerve

I have compiled it from source.

The "PAGE: total nnn" messages are logged from a self developed filter
which calls pkpgcounter.

The total message is parsed in job.c and used for the internal
structure (e.g. Web Frontend) but this function is calling

cupsdLogPage(cupsd_job_t *job, const char *page)

With the page pointer pointing to the string "total 6"

so the code sniped (first part of cupsdLogPage function)
"
if (!PageLogFormat)
return (1);

number = 1;
strcpy(copies, "1");
sscanf(page, "%d%255s", &number, copies);

for (format = PageLogFormat, bufptr = buffer; *format; format ++)
"

look at the sscanf line which does the parsing.
The Pattern "%d%255s" doen't fit to the input "total 6" !
( Wrong order ! )

So sscanf returns nothing and and number is allways 1 and copies
also points allways to the string "1".

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"str3887.patch":

Index: scheduler/log.c

--- scheduler/log.c (revision 9862)
+++ scheduler/log.c (working copy)
@@ -444,7 +444,7 @@
va_end(ap);
}

while (status == 0);

  • if (status > 0)
    {
    if ((level > LogLevel ||
    @@ -567,8 +567,8 @@
    const char format, / Pointer into PageLogFormat /
    *nameend; /
    End of attribute name /
    ipp_attribute_t *attr; /
    Current attribute */
  • int number; /* Page number */
  • char copies[256]; /* Number of copies */
  • char number[256]; /* Page number */
  • int copies; /* Number of copies */

/*
@@ -578,9 +578,9 @@
if (!PageLogFormat)
return (1);

  • number = 1;
  • strcpy(copies, "1");
  • sscanf(page, "%d%255s", &number, copies);
  • strcpy(number, "1");
  • copies = 1;
  • sscanf(page, "%255s%d", number, &copies);

for (format = PageLogFormat, bufptr = buffer; *format; format ++)
{
@@ -619,12 +619,12 @@
break;

 case 'P' :         /* Page number */
  •   snprintf(bufptr, sizeof(buffer) - (bufptr - buffer), "%d", number);
    
  •   strlcpy(bufptr, number, sizeof(buffer) - (bufptr - buffer));
    bufptr += strlen(bufptr);
    break;
    
     case 'C' :         /* Number of copies */
    
  •   strlcpy(bufptr, copies, sizeof(buffer) - (bufptr - buffer));
    
  •   snprintf(bufptr, sizeof(buffer) - (bufptr - buffer), "%d", copies);
    bufptr += strlen(bufptr);
    break;
    

@@ -713,7 +713,7 @@
}

*bufptr = '\0';

#ifdef HAVE_VSYSLOG
/*

  • See if we are logging pages via syslog...
    @@ -875,8 +875,8 @@
    CUPSD_ACCESSLOG_ACTIONS,/* CUPS-Authenticate-Job /
    CUPSD_ACCESSLOG_ALL /
    CUPS-Get-PPD */
    };

  •  if ((op <= IPP_SCHEDULE_JOB_AFTER && standard_ops[op] > AccessLogLevel) ||
         (op >= CUPS_GET_DEFAULT && op <= CUPS_GET_PPD &&
     cups_ops[op - CUPS_GET_DEFAULT] > AccessLogLevel))
    

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