> From [EMAIL PROTECTED] Tue Oct  2 12:07:04 2001
> Date: Tue, 02 Oct 2001 13:56:47 -0400
> To: [EMAIL PROTECTED]
> From: Rick Cochran <[EMAIL PROTECTED]>
> Subject: LPRng: Need real client IP address in filter
>
> I _desperately_ need for my print filter to know the REAL ip address of the 
> lpr client (from the socket connection, not from the data which it sends in 
> the control file).  Trust me.  I do.  Really.
>
> force_fqdn_hostname simply does not supply anything useful for that 
> purpose.  That does not appear to be its purpose.
>
> My next solution was to patch linelist.c to stick the request IP in an 
> environment variable which could be picked up by the filter.  This appeared 
> to work, but really did not.  The filter would get an IP address, but it 
> would not necessarily be the correct one.  I understand how this happens.
>
> I have now mercilessly hacked more code than I wanted to the effect that 
> the 'H' line in the control file ends up with "IPnnn.nnn.nnn.nnn" appended 
> to whatever seems to insist on being there no matter what I do.  This is 
> good enough for now, but is not what I would call an esthetically pleasing 
> solution.
>
> Any suggestions would be appreciated.
>
> -Rick
>
>
> |Rick Cochran                                   phone: 607-255-7618|
> |Network and Computing Systems, Cornell CIT       FAX: 607-255-8521|
> |730 Rhodes Hall, Ithaca, N.Y. 14853        email: [EMAIL PROTECTED]|


1. modify common/gethostinfo.c:

h110: {129} % rcsdiff -c common/gethostinfo.c
===================================================================
RCS file: common/RCS/gethostinfo.c,v
retrieving revision 1.23
diff -c -r1.23 common/gethostinfo.c
*** common/gethostinfo.c        2001/09/29 22:28:46     1.23
--- common/gethostinfo.c        2001/10/08 18:57:59
***************
*** 372,381 ****
  }
 
  char *Get_remote_hostbyaddr( struct host_information *info,
!       struct sockaddr *sinaddr )
  {
        char *fqdn;
!       fqdn = Get_hostinfo_byaddr( info, sinaddr, 0 );
        DEBUG3("Get_remote_hostbyaddr: %s", fqdn );
        Set_DYN( &FQDNRemote_FQDN, info->fqdn );
        Set_DYN( &ShortRemote_FQDN, info->shorthost );
--- 372,381 ----
  }
 
  char *Get_remote_hostbyaddr( struct host_information *info,
!       struct sockaddr *sinaddr, int force_ip_addr_use )
  {
        char *fqdn;
!       fqdn = Get_hostinfo_byaddr( info, sinaddr, force_ip_addr_use );
        DEBUG3("Get_remote_hostbyaddr: %s", fqdn );
        Set_DYN( &ShortRemote_FQDN, info->shorthost );
        Set_DYN( &ShortRemote_FQDN, info->shorthost );

2. Modify common/lpd.c:

*** common/lpd.c        2001/09/29 22:28:49     1.23
--- common/lpd.c        2001/10/08 19:47:36
***************
*** 595,601 ****
        /* get the remote name and set up the various checks */
        Perm_check.addr = &sinaddr;
  
!       Get_remote_hostbyaddr( &RemoteHost_IP, &sinaddr );
        Perm_check.remotehost  =  &RemoteHost_IP;
        Perm_check.host = &RemoteHost_IP;
        Perm_check.port =  ntohs(port);
--- 595,601 ----
        /* get the remote name and set up the various checks */
        Perm_check.addr = &sinaddr;
  
!       Get_remote_hostbyaddr( &RemoteHost_IP, &sinaddr, 0 );
        Perm_check.remotehost  =  &RemoteHost_IP;
        Perm_check.host = &RemoteHost_IP;
        Perm_check.port =  ntohs(port);

3. For your use, set:
        Get_remote_hostbyaddr( &RemoteHost_IP, &sinaddr, 1 );

4. Modify common/getqueue.c:


*** common/getqueue.c   2001/09/29 22:28:46     1.23
--- common/getqueue.c   2001/10/08 19:48:54
***************
*** 2085,2091 ****
        if( auth_id ){
                Set_str_value(&job->info,AUTHINFO,auth_id);
        }
!       if( !(s = Find_str_value(&job->info,FROMHOST,Value_sep)) || Is_clean_name(s) ){
                Set_str_value(&job->info,FROMHOST,FQDNRemote_FQDN);
                s = Find_str_value(&job->info,FROMHOST,Value_sep);
        }
--- 2085,2091 ----
        if( auth_id ){
                Set_str_value(&job->info,AUTHINFO,auth_id);
        }
!       if( 1 || !(s = Find_str_value(&job->info,FROMHOST,Value_sep)) || 
Is_clean_name(s) ){
                Set_str_value(&job->info,FROMHOST,FQDNRemote_FQDN);
                s = Find_str_value(&job->info,FROMHOST,Value_sep);
        }

5. Compile, etc.  Now you will have IP addresses instead of host names
   used.

Patrick Powell

-----------------------------------------------------------------------------
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