Here we go. The following code is according to the GPL, under which LPRng
is licensed, licensed under the GPL as well. If you spot any errors (they
creep in everywhere, even in this small amount of code) please let me
know.


--- LPRng-3.8.21/src/common/getqueue.c.orig     Wed Apr 16 01:37:42 2003
+++ LPRng-3.8.21/src/common/getqueue.c  Sat Jun 14 16:27:08 2003
@@ -2104,11 +2104,53 @@
        int status = 0, fd, i;
        struct stat statb;

+       struct line_list l, listv;
+       char *s, *t;
+       Init_line_list(&l);
+       Init_line_list(&listv);
+
        if(DEBUGL3) Dump_job( "Create_control: before fixing", job );

        /* deal with authentication */

        Make_identifier( job );
+
+       /*
+        * if we get a request from these hosts, change host name in control
+        * file (possibly faked if from untrusted host) to FQDN of remote host
+       */
+       if( Force_controlfile_originate_hostname_DYN ){
+               Free_line_list(&l);
+               
Split(&l,Force_controlfile_originate_hostname_DYN,File_sep,0,0,0,0,0,0);
+               if( Match_ipaddr_value( &l, &RemoteHost_IP ) == 0 ){
+                       DEBUG1("Create_control: remotehost '%s'", FQDNRemote_FQDN );
+                       Set_str_value(&job->info,FROMHOST,FQDNRemote_FQDN);
+                       fromhost = Find_str_value(&job->info,FROMHOST,Value_sep);
+               }
+               Free_line_list(&l);
+       }
+
+       /*
+        * if we get a request from these hosts, change user name in control
+        * file (possibly faked if from untrusted host) to specified
+       */
+       if( Force_controlfile_username_DYN ){
+               Free_line_list(&listv);
+               Split(&listv,Force_controlfile_username_DYN,File_sep,0,0,0,0,0,0);
+               for(i = 0; i < listv.count; ++i ){
+                       s = listv.list[i];
+                       if( (t = safestrpbrk(s,Value_sep)) ) *t++ = 0;
+                       Free_line_list(&l);
+                       Split(&l,t,Value_sep,0,0,0,0,0,0);
+                       if( Match_ipaddr_value( &l, &RemoteHost_IP ) == 0 ){
+                               DEBUG1("Create_control: username '%s'", s );
+                               Set_str_value(&job->info,LOGNAME,s);
+                               break;
+                       }
+               }
+                Free_line_list(&l);
+               Free_line_list(&listv);
+       }

        if( !(fromhost = Find_str_value(&job->info,FROMHOST,Value_sep)) || 
Is_clean_name(fromhost) ){
                Set_str_value(&job->info,FROMHOST,FQDNRemote_FQDN);


--- LPRng-3.8.21/src/include/lp.h.orig  Wed Apr 16 01:37:43 2003
+++ LPRng-3.8.21/src/include/lp.h       Sat Jun 14 16:25:38 2003
@@ -303,6 +303,8 @@
 EXTERN char* Filter_path_DYN;
 EXTERN int Fake_large_file_DYN;        /* fake large file size if you cannot use 0 */
 EXTERN int Filter_poll_interval_DYN; /* intervals at which to check filter */
+EXTERN char* Force_controlfile_originate_hostname_DYN; /* force control file 
originate host name for specified hostnames */
+EXTERN char* Force_controlfile_username_DYN;   /* force control file user name for 
specified hostnames */
 EXTERN int Force_FQDN_hostname_DYN; /* force FQDN Host name in control file */
 EXTERN int Force_IPADDR_hostname_DYN; /* force IPADDR for Host name in control file */
 EXTERN int Force_localhost_DYN;        /* force localhost for client job transfer */


--- LPRng-3.8.21/src/common/vars.c.orig Wed Apr 16 01:37:42 2003
+++ LPRng-3.8.21/src/common/vars.c      Sat Jun 14 16:27:13 2003
@@ -230,6 +230,10 @@
 { "filter_stderr_to_status_file", 0, FLAG_K, &Filter_stderr_to_status_file_DYN,0,0,0},
    /*  print a form feed when device is opened */
 { "fo", 0,  FLAG_K,  &FF_on_open_DYN,0,0,0},
+   /* force control file originate host name for specified hostnames */
+{ "force_controlfile_originate_hostname", 0, STRING_K, 
&Force_controlfile_originate_hostname_DYN,0,0,0},
+   /* force control file user name for specified hostnames */
+{ "force_controlfile_username", 0, STRING_K, &Force_controlfile_username_DYN,0,0,0},
    /* force FQDN HOST value in control file */
 { "force_fqdn_hostname", 0,  FLAG_K,  &Force_FQDN_hostname_DYN,0,0,0},
    /* force IPADDR of Originating host for host value in control file */

-----------------------------------------------------------------------------
YOU MUST BE A LIST MEMBER IN ORDER TO POST TO THE LPRNG MAILING LIST
The address you post from MUST be your subscription address

If you need help, send email to [EMAIL PROTECTED] (or lprng-requests
or lprng-digest-requests) with the word 'help' in the body.  For the impatient,
to subscribe to a list with name LIST,  send mail to [EMAIL PROTECTED]
with:                           | example:
subscribe LIST <mailaddr>       |  subscribe lprng-digest [EMAIL PROTECTED]
unsubscribe LIST <mailaddr>     |  unsubscribe lprng [EMAIL PROTECTED]

If you have major problems,  send email to [EMAIL PROTECTED] with the word
LPRNGLIST in the SUBJECT line.
-----------------------------------------------------------------------------

Reply via email to