[NOTE: subject should say "accounting" instead of "authentication", do not
want to change in case mailing list archiving software use the subject as
threading mechanism.]
Here is yet another fixed patch set that fixes a bug in the patch to
getqueue.c concerning the feature "force_controlfile_originate_hostname".
The variable I was using to get the real remote host name was only
available when an actual remote connection existed (when a job is
received) and did not exist when a job was moved from one queue to another
internally (from a load balancing queue to a serving queue).
The new patch to getqueue.c fetches the real remote host name from another
place (it is actually stored in the control file under "remotehost") and
sets the H control file to this value.
Regards, Henrik
--- 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 21 18:55:45 2003
@@ -230,6 +230,16 @@
{ "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 setting of user name as accounting name */
+{ "force_controlfile_accountingname", 0, FLAG_K,
&Force_controlfile_accountingname_DYN,0,0,0},
+ /* use specified user name as accounting name for host names not explicity
specified under trusted or untrusted */
+{ "force_controlfile_accountingname_default", 0, STRING_K,
&Force_controlfile_accountingname_default_DYN,0,0,0},
+ /* trust user names as accounting names from specified host names */
+{ "force_controlfile_accountingname_trusted", 0, STRING_K,
&Force_controlfile_accountingname_trusted_DYN,0,0,0},
+ /* use specified user names as accounting names for specified host names */
+{ "force_controlfile_accountingname_untrusted", 0, STRING_K,
&Force_controlfile_accountingname_untrusted_DYN,0,0,0},
+ /* force control file originate host name for specified host names */
+{ "force_controlfile_originate_hostname", 0, STRING_K,
&Force_controlfile_originate_hostname_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 */
--- LPRng-3.8.21/src/include/lp.h.orig Wed Apr 16 01:37:43 2003
+++ LPRng-3.8.21/src/include/lp.h Thu Jun 19 20:37:18 2003
@@ -303,6 +303,11 @@
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 int Force_controlfile_accountingname_DYN; /* force control file setting
of user name as accounting name */
+EXTERN char* Force_controlfile_accountingname_default_DYN; /* use specified user
name as accounting name for host names not explicity specified under trusted or
untrusted */
+EXTERN char* Force_controlfile_accountingname_trusted_DYN; /* trust user names as
accounting names from specified host names */
+EXTERN char* Force_controlfile_accountingname_untrusted_DYN; /* use specified user
names as accounting names for specified host names */
+EXTERN char* Force_controlfile_originate_hostname_DYN; /* force control file
originate host name for specified host names */
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/include/getqueue.h.orig Wed Apr 16 01:37:43 2003
+++ LPRng-3.8.21/src/include/getqueue.h Thu Jun 19 12:48:01 2003
@@ -15,6 +15,7 @@
EXTERN char *CTRL_A_str DEFINE( = "\001" );
/* SSL */
+EXTERN const char * ACCNTNAME DEFINE( = "R" );
EXTERN const char * ACTION DEFINE( = "action" );
EXTERN const char * ACTIVE_TIME DEFINE( = "active_time" );
EXTERN const char * ADDR DEFINE( = "addr" );
--- LPRng-3.8.21/src/common/getqueue.c.orig Wed Apr 16 01:37:42 2003
+++ LPRng-3.8.21/src/common/getqueue.c Fri Jun 27 11:09:24 2003
@@ -2104,11 +2104,76 @@
int status = 0, fd, i;
struct stat statb;
+ struct line_list l, listv;
+ Init_line_list(&l);
+ Init_line_list(&listv);
+
if(DEBUGL3) Dump_job( "Create_control: before fixing", job );
/* deal with authentication */
Make_identifier( job );
+
+ /*
+ * if enabled; change accounting name in control file to either user
+ * name (if coming from trusted host name), accounting name specified
+ * for specific host names, or default accounting name
+ */
+ if( Force_controlfile_accountingname_DYN ){
+ char *logname = Find_str_value(&job->info,LOGNAME,Value_sep);
+ char *accountingname = 0;
+ if( logname && Force_controlfile_accountingname_trusted_DYN ){
+ Free_line_list(&l);
+
Split(&l,Force_controlfile_accountingname_trusted_DYN,File_sep,0,0,0,0,0,0);
+ if( Match_ipaddr_value( &l, &RemoteHost_IP ) == 0 ){
+ Set_str_value(&job->info,ACCNTNAME,logname);
+ accountingname =
Find_str_value(&job->info,ACCNTNAME,Value_sep);
+ }
+ Free_line_list(&l);
+ }
+ if( !accountingname && Force_controlfile_accountingname_untrusted_DYN
){
+ char *s, *t;
+ Free_line_list(&listv);
+
Split(&listv,Force_controlfile_accountingname_untrusted_DYN,";",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,File_sep,0,0,0,0,0,0);
+ if( Match_ipaddr_value( &l, &RemoteHost_IP ) == 0 ){
+ Set_str_value(&job->info,ACCNTNAME,s);
+ accountingname =
Find_str_value(&job->info,ACCNTNAME,Value_sep);
+ break;
+ }
+ }
+ Free_line_list(&l);
+ Free_line_list(&listv);
+ }
+ if( !accountingname && Force_controlfile_accountingname_default_DYN ){
+
Set_str_value(&job->info,ACCNTNAME,Force_controlfile_accountingname_default_DYN );
+ accountingname =
Find_str_value(&job->info,ACCNTNAME,Value_sep);
+ }
+ if( accountingname ){
+ DEBUG1("Create_control: accountingname '%s'", accountingname );
+ }
+ }
+
+ /*
+ * 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
+ * or, if not available, to IP address 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 ){
+ char *remotehost =
Find_str_value(&job->info,REMOTEHOST,Value_sep);
+ DEBUG1("Create_control: remotehost '%s'", remotehost );
+ Set_str_value(&job->info,FROMHOST,remotehost);
+ fromhost = Find_str_value(&job->info,FROMHOST,Value_sep);
+ }
+ Free_line_list(&l);
+ }
if( !(fromhost = Find_str_value(&job->info,FROMHOST,Value_sep)) ||
Is_clean_name(fromhost) ){
Set_str_value(&job->info,FROMHOST,FQDNRemote_FQDN);