httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dirk.vanGulik" <Dirk.vanGu...@jrc.it>
Subject Patch to mod_auth_msql.c
Date Thu, 03 Oct 1996 07:28:35 GMT
Some additions, by jeff@dresden.com, to mSQL, to allow port & device setting.

I've still got to confirm that this works on Irix and Sco. In the
past I had problems with trying this setenv() at run time; msql
would not pick it up. But this works on Solaris and (free|net)BSD.

I'll upload a full patch later; let me know if you have any 
thoughds.

Tha!

Dw.


----- Begin Included Message -----

Dirk,

I made an upgrade to the mod_auth_msql.c file that you wrote to allow
support for connecting to non-standard Unix/TCP mSQL ports.  This will
allow servers that run multiple mSQL daemons to utilize the mod_auth_msql
module for connecting to databases on other ports.

It has been tested using Apache 1.1.1 and mSQL 1.1.16 on Linux 2.0.20

If you would like the full file with the patch applied or have problems
with this patch, let me know.

I also have it on our ftp server at ftp.dresden.com in
/pub/unix/msql/mod_auth_msql.diff

I assume you'll want to add the patch yourself and put it up and sent it to
the other sites (bond.edu.au, vex.net, apache.org) -- if you would rather I
do it, let me know.

Thanks.

Jeff Haynie

::BEGIN PATCH:::


*** mod_auth_msql.c	Wed Oct  2 19:49:03 1996
--- mod_auth_msql.jeff	Wed Oct  2 19:47:58 1996
***************
*** 106,111 ****
--- 106,122 ----
   *			communication channel will be used. Otherwise
   *			it is the machine to contact by tcp/ip.
   *
+  *
+  * Auth_MSQLUnixPort	/dev/msql
+  *
+  *					Optionally, you can override the compiled in mSQL Unix port
+  *
+  *
+  * Auth_MSQLTCPPort		1112
+  *
+  *					Optionally, you can override the compiled in mSQL TCP port	
+  *
+  *
   * Auth_MSQLdatabase    www
   *
   *                      The name of the database on the above machine,
***************
*** 193,198 ****
--- 204,219 ----
   *		   	to use /dev/msql rather than the
   *		   	(slower) socket communication.
   *
+  * Auth_MSQLUnixPort	Unix Port to Connect to mSQL Daemon.
+  *			If this directive is ommited, the default compiled in mSQL
+  * 			port will be connected to. Otherwise, Apache will use this port
+  *			to connect to the mSQL daemon  (optional)
+  *
+  * Auth_MSQLTCPPort 	TCP Port to Connect to mSQL Daemon.
+  *			If this directive is ommited, the default compiled in mSQL
+  * 			port will be connected to. Otherwise, Apache will use this port
+  *			to connect to the mSQL daemon  (optional)
+  *
   * Auth_MSQLdatabase	Name of the database in which the following
   *			table(s) are contained.
   *
***************
*** 290,298 ****
--- 311,334 ----
   *		with the authorative stuff; caught by thomas@marvin.calvacom.fr.
   *	   1.3  Even more changes to get it right; that BACKWARD thing was a bad
   *		idea. 
+  *	   1.4 Added ability to connect to non-standard mSQL Ports by
+  *			Jeff Haynie (jeff@dresden.com)  - Added directives 
+  *			Auth_MSQLUnixPort & Auth_MSQLTCPPort in case mSQL is 
+  *			running on ports other than /dev/msql and 1112 - useful
+  *			for servers running multiple copies of mSQL and the 
+  *			auth database is on the non-standard mSQL port 
   */
  
  
+ #define MSQL_DEFAULT_UNIXPORT	"/dev/msql"
+ #define MSQL_DEFAULT_TCPPORT	"1112"
+ /* 
+  * Default values for connecting to mSQL via Unix/TCP ports
+  * Shouldn't need to change unless you want to always connect
+  * to a non-standard mSQL port by default
+  * You can override in .htaccess
+ */
+ 
  #define ONLY_ONCE 1
  /*
   * If the mSQL table containing the uid/passwd combination does
***************
*** 311,317 ****
   * uid field a primary key. Use at your own peril :-)
   */
  
! #undef KEEP_MSQL_CONNECTION_OPEN
  /*
   * Normally the (tcp/ip) connection with the database is opened and
   * closed for each SQL query. When the httpd-server and the database
--- 347,353 ----
   * uid field a primary key. Use at your own peril :-)
   */
  
! #define KEEP_MSQL_CONNECTION_OPEN
  /*
   * Normally the (tcp/ip) connection with the database is opened and
   * closed for each SQL query. When the httpd-server and the database
***************
*** 336,341 ****
--- 372,378 ----
   *
   * In short; use this at your own peril and only in a highly controled and
   * monitored environment
+  *
   */
  
  #define BACKWARD_VITEK
***************
*** 406,411 ****
--- 443,450 ----
  
      char *auth_msql_host;
      char *auth_msql_database;
+ 	char *auth_msql_unixport;
+ 	char *auth_msql_tcpport;
  
      char *auth_msql_pwd_table;
      char *auth_msql_grp_table;
***************
*** 426,431 ****
--- 465,473 ----
  
      sec->auth_msql_host        = NULL; /* just to enforce the default
'localhost' behaviour */
  
+ 	sec->auth_msql_unixport	   = NULL;
+ 	sec->auth_msql_tcpport	   = NULL;
+ 
      /* just in case, to be nice... */
      sec->auth_msql_database    = NULL;
      sec->auth_msql_pwd_table   = NULL;
***************
*** 481,486 ****
--- 523,536 ----
      (void*)XtOffsetOf(msql_auth_config_rec, auth_msql_database),
      OR_AUTHCFG, TAKE1, "Name of the mSQL database which contains the
password (and possibly the group) tables. " },
  
+ { "Auth_MSQLUnixPort", msql_set_string_slot,
+     (void*)XtOffsetOf(msql_auth_config_rec, auth_msql_unixport),
+     OR_AUTHCFG, TAKE1, "mSQL Unix Port which to connect to " },
+ 
+ { "Auth_MSQLTCPPort", msql_set_string_slot,
+     (void*)XtOffsetOf(msql_auth_config_rec, auth_msql_tcpport),
+     OR_AUTHCFG, TAKE1, "mSQL TCP Port which to connect to " },
+ 
  { "Auth_MSQLpwd_table", msql_set_string_slot,
      (void*)XtOffsetOf(msql_auth_config_rec, auth_msql_pwd_table),
      OR_AUTHCFG, TAKE1, "Name of the mSQL table containing the
password/user-name combination" },
***************
*** 522,527 ****
--- 572,583 ----
  { "AuthMSQLDB", set_string_slot,
      (void*)XtOffsetOf(msql_auth_config_rec, auth_msql_database),
      OR_AUTHCFG, TAKE1, "mSQL database name" },
+ { "AuthMSQLUnixPort", set_string_slot,
+     (void*)XtOffsetOf(msql_auth_config_rec, auth_msql_unixport),
+     OR_AUTHCFG, TAKE1, "mSQL Unix Port" },
+ { "AuthMSQLTCPPort", set_string_slot,
+     (void*)XtOffsetOf(msql_auth_config_rec, auth_msql_tcpport),
+     OR_AUTHCFG, TAKE1, "mSQL TCP Port" },
  { "AuthMSQLUserTable", set_string_slot,
      (void*)XtOffsetOf(msql_auth_config_rec, auth_msql_pwd_table),
      OR_AUTHCFG, TAKE1, "mSQL user table name" },
***************
*** 575,580 ****
--- 631,658 ----
  
    return out;
  }
+ /* Setup our mSQL Port Information
+ */
+ void setupPorts(msql_auth_config_rec *sec){
+ 
+ 	if (sec->auth_msql_unixport!=NULL)
+ 		setenv("MSQL_UNIX_PORT",sec->auth_msql_unixport,-1);
+ 	else
+ 		setenv("MSQL_UNIX_PORT",MSQL_DEFAULT_UNIXPORT,-1);
+ 
+ 	if (sec->auth_msql_tcpport!=NULL)
+ 		setenv("MSQL_TCP_PORT",sec->auth_msql_tcpport,-1);
+ 	else	
+ 		setenv("MSQL_TCP_PORT",MSQL_DEFAULT_TCPPORT,-1);
+ 
+ }
+ /* kill anything we set so we don't conflict with any other
+ ** mSQL calls the binary makes
+ */
+ void killPorts(){
+ 	unsetenv("MSQL_UNIX_PORT");
+ 	unsetenv("MSQL_TCP_PORT");
+ }
  
  /* get the password for uname=user, and copy it
   * into r. Assume that user is a string and stored
***************
*** 589,594 ****
--- 667,673 ----
  
   	char 		*result=NULL;
  	char		*host=sec->auth_msql_host;
+ 	char 		tmpstring[50];
  
  #ifndef KEEP_MSQL_CONNECTION_OPEN
          sock=-1;
***************
*** 599,604 ****
--- 678,687 ----
  	if ((host) && (!(strcasecmp(host,"localhost"))))
  		host=NULL;
  
+ 	/* set Unix Port & TCP Ports */
+ 
+ 	setupPorts(sec);
+ 
  	/* (re) open if nessecary
  	 */
      	if (sock==-1) if ((sock=msqlConnect(host)) == -1) {
***************
*** 606,611 ****
--- 689,695 ----
  			"mSQL: Could not connect to Msql DB %s (%s)",
  			(sec->auth_msql_host ? sec->auth_msql_host : "\'unset, assuming
localhost!\'"),
  			msqlErrMsg);
+ 		killPorts();
  		return NULL;
      		}
  
***************
*** 619,624 ****
--- 703,709 ----
  			msqlErrMsg);
  		msqlClose(sock);
  		sock=-1;
+ 		killPorts();
  		return NULL;
  		}
  
***************
*** 630,635 ****
--- 715,721 ----
  			( query ? query : "\'unset!\'") );
  		msqlClose(sock);
  		sock=-1;
+ 		killPorts();
  		return NULL;
  		}
  
***************
*** 641,646 ****
--- 727,733 ----
  			( query ? query : "\'unset!\'") );
  		msqlClose(sock);
  		sock=-1;
+ 		killPorts();
  		return NULL;
  		};
  
***************
*** 683,688 ****
--- 770,776 ----
  	sock=-1;
  #endif
  
+ 	killPorts();
  	return result;
  }
  









=======================================================================
dresden.com
Software and Database Development
Web Site Design & Development
(770) 992-8453
21 Cedar Run, Ste.O
Atlanta, GA 30350 USA



----- End Included Message -----


Mime
View raw message