Author: gad
Date: Wed Apr 13 00:36:19 2011
New Revision: 220586
URL: http://svn.freebsd.org/changeset/base/220586

Log:
  - Fix the code that matches userids in match_jobspec().  It needs to check
    the username-for-accounting field (P), not the username-for-headerpage (L).
    These are usually the same value, except that control files do not have
    the username-for-headerpage field if the user has requested no header page.
  - Also rename the cji_username field to cji_headruser, to make it clear that
    the value should only be used for the header page.  (aka banner page)
  
  MFC after:    3 weeks

Modified:
  head/usr.sbin/lpr/common_source/ctlinfo.c
  head/usr.sbin/lpr/common_source/ctlinfo.h
  head/usr.sbin/lpr/common_source/matchjobs.c

Modified: head/usr.sbin/lpr/common_source/ctlinfo.c
==============================================================================
--- head/usr.sbin/lpr/common_source/ctlinfo.c   Wed Apr 13 00:03:49 2011        
(r220585)
+++ head/usr.sbin/lpr/common_source/ctlinfo.c   Wed Apr 13 00:36:19 2011        
(r220586)
@@ -1,6 +1,6 @@
 /*
  * 
------+---------+---------+---------+---------+---------+---------+---------*
- * Copyright (c) 2001  - Garance Alistair Drosehn <g...@freebsd.org>.
+ * Copyright (c) 2001,2011  - Garance Alistair Drosehn <g...@freebsd.org>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -248,7 +248,7 @@ ctl_freeinf(struct cjobinfo *cjinf)
        /* [cpriv->pub.cji_fname is part of cpriv-malloced area] */
        FREESTR(cpriv->pub.cji_jobname);
        FREESTR(cpriv->pub.cji_mailto);
-       FREESTR(cpriv->pub.cji_username);
+       FREESTR(cpriv->pub.cji_headruser);
 
        if (cpriv->cji_fstream != NULL) {
                fclose(cpriv->cji_fstream);
@@ -343,7 +343,7 @@ ctl_readcf(const char *ptrname, const ch
                        cpriv->pub.cji_jobname = strdup(lbuff);
                        break;
                case 'L':
-                       cpriv->pub.cji_username = strdup(lbuff);
+                       cpriv->pub.cji_headruser = strdup(lbuff);
                        break;
                case 'M':
                        /*
@@ -586,8 +586,8 @@ ctl_renametf(const char *ptrname, const 
                fprintf(newcf, "C%s\n", cjinf->cji_class);
        if (cjinf->cji_jobname != NULL)
                fprintf(newcf, "J%s\n", cjinf->cji_jobname);
-       if (cjinf->cji_username != NULL)
-               fprintf(newcf, "L%s\n", cjinf->cji_username);
+       if (cjinf->cji_headruser != NULL)
+               fprintf(newcf, "L%s\n", cjinf->cji_headruser);
 
        /*
         * This should probably add more sanity checks on mailto value.
@@ -832,7 +832,7 @@ ctl_dumpcji(FILE *dbg_stream, const char
        PRINTSTR("cf-fname", cpriv->pub.cji_fname);
        PRINTSTR("jobname.J", cpriv->pub.cji_jobname);
        PRINTSTR("mailto.M", cpriv->pub.cji_mailto);
-       PRINTSTR("hdruser.L", cpriv->pub.cji_username);
+       PRINTSTR("headruser.L", cpriv->pub.cji_headruser);
 
        ctl_dbgline++;
        fprintf(dbg_stream, "%4d] %12s = ", ctl_dbgline, "*cjprivate");

Modified: head/usr.sbin/lpr/common_source/ctlinfo.h
==============================================================================
--- head/usr.sbin/lpr/common_source/ctlinfo.h   Wed Apr 13 00:03:49 2011        
(r220585)
+++ head/usr.sbin/lpr/common_source/ctlinfo.h   Wed Apr 13 00:36:19 2011        
(r220586)
@@ -1,6 +1,6 @@
 /*
  * 
------+---------+---------+---------+---------+---------+---------+---------*
- * Copyright (c) 2001  - Garance Alistair Drosehn <g...@freebsd.org>.
+ * Copyright (c) 2001,2011  - Garance Alistair Drosehn <g...@freebsd.org>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@ struct cjobinfo {
        char    *cji_fname;             /* filename of the control file */
        char    *cji_jobname;           /* job-name (for banner) */
        char    *cji_mailto;            /* userid to send email to (or null) */
-       char    *cji_username;          /* "literal" user-name (for banner) or
+       char    *cji_headruser;         /* "literal" user-name (for banner) or
                                         * NULL if no banner-page is wanted */
        struct cjprivate *cji_priv;
 };

Modified: head/usr.sbin/lpr/common_source/matchjobs.c
==============================================================================
--- head/usr.sbin/lpr/common_source/matchjobs.c Wed Apr 13 00:03:49 2011        
(r220585)
+++ head/usr.sbin/lpr/common_source/matchjobs.c Wed Apr 13 00:36:19 2011        
(r220586)
@@ -1,6 +1,6 @@
 /*
  * 
------+---------+---------+---------+---------+---------+---------+---------*
- * Copyright (c) 2002   - Garance Alistair Drosehn <g...@freebsd.org>.
+ * Copyright (c) 2002,2011   - Garance Alistair Drosehn <g...@freebsd.org>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -453,7 +453,7 @@ match_jobspec(struct jobqueue *jq, struc
                cfinf = ctl_readcf("fakeq", jq->job_cfname);
                if (cfinf == NULL)
                        goto nomatch;
-               if (fnmatch(jspec->wanteduser, cfinf->cji_username, 0) != 0)
+               if (fnmatch(jspec->wanteduser, cfinf->cji_acctuser, 0) != 0)
                        goto nomatch;
        }
 
@@ -467,7 +467,7 @@ match_jobspec(struct jobqueue *jq, struc
                 * pattern), then the caller's "doentry()" routine might
                 * want to know the userid of this job that matched.
                 */
-               jspec->matcheduser = strdup(cfinf->cji_username);
+               jspec->matcheduser = strdup(cfinf->cji_acctuser);
        }
 #if DEBUG_SCANJS
        printf("\t [ job matched! ]\n");
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to