httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike A Lyons <lyo...@netbistro.com>
Subject two new CGI variables
Date Thu, 01 Aug 1996 23:57:42 GMT

Hello,

This is a quick hack to provide CGI scripts with SERVER_ADDR and
REMOTE_PORT information.  I wanted it so I could leave a phf script laying
around that would try to ident whoever keeps probing at it, without having
to slow down everything by turning on ident everywhere. 

I figured someone else might find it useful.



*** util_script.c.dist  Thu Aug  1 16:06:08 1996
--- util_script.c       Thu Aug  1 16:32:31 1996
***************
*** 130,136 ****
      conn_rec *c = r->connection;
      const char *rem_logname;
      
!     char port[40],*env_path;
      
      array_header *hdrs_arr = table_elts (r->headers_in);
      table_entry *hdrs = (table_entry *)hdrs_arr->elts;
--- 130,136 ----
      conn_rec *c = r->connection;
      const char *rem_logname;
      
!     char port[40],remote_port[40],*env_path;
      
      array_header *hdrs_arr = table_elts (r->headers_in);
      table_entry *hdrs = (table_entry *)hdrs_arr->elts;
***************
*** 160,165 ****
--- 160,166 ----
      }
      
      sprintf(port, "%d", s->port);
+     sprintf(remote_port, "%d", ntohs(c->remote_addr.sin_port));
  
      if(!(env_path = getenv("PATH")))
          env_path=DEFAULT_PATH;
***************
*** 171,176 ****
--- 172,179 ----
      table_set (e, "REMOTE_HOST",
               get_remote_host(c, r->per_dir_config, REMOTE_NAME));
      table_set (e, "REMOTE_ADDR", c->remote_ip);
+     table_set (e, "REMOTE_PORT", remote_port);
+     table_set (e, "SERVER_ADDR", inet_ntoa(c->local_addr.sin_addr));
      table_set (e, "DOCUMENT_ROOT", document_root(r)); /* Apache */
      table_set (e, "SERVER_ADMIN", s->server_admin); /* Apache */
      table_set (e, "SCRIPT_FILENAME", r->filename); /* Shambhala */


Mime
View raw message