freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Patch to better log config file and env processing, w/ updated documentation
- From: Harry Felder <harry AT rentec.com>
- To: freetds AT franklin.metalab.unc.edu
- Subject: Patch to better log config file and env processing, w/ updated documentation
- Date: Tue, 07 May 2002 19:03:51 -0400
Hi all:
Below is a patch to the current cvs which will do the following:
1. Add an environment variable, TDSDUMPCONFIG, which will turn on
logging of the processing of environment variables, and freetds.conf
and interfaces files to set up the server configuration.
2. Add more detailed logging messages to the configuration
process.
3. Add appropriate comments to the example freetds.conf file to
explain the search path for freetds.conf files.
4. Fixed a buglet in freetds.conf files processing where the
server name was not all lower case.
5. Updated userguide.sgml so that it more accurately described
what the code did in using environment variables and searching
for a freetds.conf file or interfaces file to determine the
server configuration
The above is a result of my trying to set up FreeTDS under unixODBC
the first time and having a difficult time determining what was
happening without reading the code. It should be easier in the future
once this patch is incorporated.
hf
harry AT rentec.com
*** src/tds/config.c.ORIG Tue May 7 12:57:49 2002
--- src/tds/config.c Tue May 7 18:52:29 2002
***************
*** 68,80 ****
static char interf_file[MAXPATH];
- #define DEBUG_CONFIG 0
-
/*
** tds_get_config() will fill the tds config structure based on
configuration
** information gathered in the following order:
** 1) Program specified in TDSLOGIN structure
! ** 2) The environment variables TDSVER, TDSDUMP, TDSPORT
** 3) ~/.interfaces if exists
** 4) $SYBASE/interfaces if exists
** 5) TDS_DEF_* default values
--- 68,82 ----
static char interf_file[MAXPATH];
/*
** tds_get_config() will fill the tds config structure based on
configuration
** information gathered in the following order:
** 1) Program specified in TDSLOGIN structure
! ** 2) The environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY, TDSHOST
! ** 3) A config file with the following search order:
! ** a) a readable file specified by environment variable FREETDSCONF
! ** b) a readable file in ~/.freetds.conf
! ** c) a readable file in $prefix/etc/freetds.conf
** 3) ~/.interfaces if exists
** 4) $SYBASE/interfaces if exists
** 5) TDS_DEF_* default values
***************
*** 85,102 ****
TDSCONFIGINFO *tds_get_config(TDSSOCKET *tds, TDSLOGIN *login, TDSLOCINFO
*locale)
{
TDSCONFIGINFO *config;
!
!
/* allocate a new structure with hard coded and build-time defaults */
config = tds_alloc_config(locale);
! #if DEBUG_CONFIG
! tdsdump_open("/tmp/tdsconfig.log");
! #endif
! tdsdump_log(TDS_DBG_INFO1, "%L Attempting to read conf file\n");
if (! tds_read_conf_file(login->server_name, config)) {
/* fallback to interfaces file */
! tdsdump_log(TDS_DBG_INFO1, "%L Failed reading conf file.
Trying interfaces\n");
tds_read_interfaces(login->server_name, config);
}
--- 87,114 ----
TDSCONFIGINFO *tds_get_config(TDSSOCKET *tds, TDSLOGIN *login, TDSLOCINFO
*locale)
{
TDSCONFIGINFO *config;
! char *s;
! char path[MAXPATHLEN];
! pid_t pid;
/* allocate a new structure with hard coded and build-time defaults */
config = tds_alloc_config(locale);
! s=getenv("TDSDUMPCONFIG");
! if (s)
! {
! if ( !*s)
! {
! pid = getpid();
! sprintf(path,"/tmp/tdsconfig.log.%d",pid);
! s = path;
! }
! tdsdump_open(s);
! }
!
! tdsdump_log(TDS_DBG_INFO1, "%L Attempting to read conf files.\n");
if (! tds_read_conf_file(login->server_name, config)) {
/* fallback to interfaces file */
! tdsdump_log(TDS_DBG_INFO1, "%L Failed in reading conf file.
Trying interface files.\n");
tds_read_interfaces(login->server_name, config);
}
***************
*** 110,119 ****
/* And finally the login structure */
tds_config_login(config, login);
! #if DEBUG_CONFIG
! tdsdump_close();
! #endif
!
return config;
}
static int tds_read_conf_file(char *server, TDSCONFIGINFO *config)
--- 122,128 ----
/* And finally the login structure */
tds_config_login(config, login);
! if ( s && *s) tdsdump_close();
return config;
}
static int tds_read_conf_file(char *server, TDSCONFIGINFO *config)
***************
*** 122,141 ****
char *home, *path;
int found = 0;
- in = fopen(FREETDS_SYSCONFFILE, "r");
- if (in) {
- tdsdump_log(TDS_DBG_INFO1, "%L Found conf file in %s reading
sections\n",FREETDS_SYSCONFFILE);
- found = tds_read_conf_sections(in, server, config);
- fclose(in);
- }
-
/* FREETDSCONF env var, pkleef AT openlinksw.com 01/21/02 */
path = getenv ("FREETDSCONF");
! if (!found && path) {
if ((in = fopen (path, "r")) != NULL) {
tdsdump_log(TDS_DBG_INFO1,
! "%L Found conf file in %s reading
sections\n",path);
found = tds_read_conf_sections (in, server, config);
fclose (in);
}
}
--- 131,144 ----
char *home, *path;
int found = 0;
/* FREETDSCONF env var, pkleef AT openlinksw.com 01/21/02 */
path = getenv ("FREETDSCONF");
! if (path) {
if ((in = fopen (path, "r")) != NULL) {
tdsdump_log(TDS_DBG_INFO1,
! "%L Found conf file in %s (from $FREETDSCONF)
Reading section %s.\n",path,server);
found = tds_read_conf_sections (in, server, config);
+ if(found) tdsdump_log(TDS_DBG_INFO1, "%L
...Success.\n");
fclose (in);
}
}
***************
*** 147,154 ****
sprintf(path,"%s/.freetds.conf",home);
in = fopen(path, "r");
if (in) {
! tdsdump_log(TDS_DBG_INFO1, "%L Found conf
file in %s/.freetds.conf reading sections\n",home);
found = tds_read_conf_sections(in, server,
config);
fclose(in);
}
free(path);
--- 150,158 ----
sprintf(path,"%s/.freetds.conf",home);
in = fopen(path, "r");
if (in) {
! tdsdump_log(TDS_DBG_INFO1, "%L Found conf
file in %s Reading section %s.\n",path,server);
found = tds_read_conf_sections(in, server,
config);
+ if(found) tdsdump_log(TDS_DBG_INFO1, "%L
...Success.\n");
fclose(in);
}
free(path);
***************
*** 155,160 ****
--- 159,174 ----
}
}
+ if (!found) {
+ in = fopen(FREETDS_SYSCONFFILE, "r");
+ if (in) {
+ tdsdump_log(TDS_DBG_INFO1, "%L Found conf file in %s
Reading section %s.\n",FREETDS_SYSCONFFILE,server);
+ found = tds_read_conf_sections(in, server, config);
+ if(found) tdsdump_log(TDS_DBG_INFO1, "%L ...Success.\n");
+ fclose(in);
+ }
+ }
+
return found;
}
static int tds_read_conf_sections(FILE *in, char *server, TDSCONFIGINFO
*config)
***************
*** 177,185 ****
!strcmp(value, "on") ||
!strcmp(value, "true") ||
!strcmp(value, "1")) {
! return 1;
} else {
! return 0;
}
}
--- 191,201 ----
!strcmp(value, "on") ||
!strcmp(value, "true") ||
!strcmp(value, "1")) {
! tdsdump_log(TDS_DBG_INFO1, "%L %s is a
'yes/on/true'.\n",value);
! return 1;
} else {
! tdsdump_log(TDS_DBG_INFO1, "%L %s is a
'no/off/false'.\n",value);
! return 0;
}
}
***************
*** 192,197 ****
--- 208,214 ----
char tmp[256];
int found = 0;
+ tdsdump_log(TDS_DBG_INFO1, "%L Looking for section %s.\n", section);
while (fgets(line, 256, in)) {
s = line;
***************
*** 237,247 ****
if (option[0]=='[') {
s = &option[1];
while (*s) {
! if (*s==']') *s='\0';
s++;
}
if (!strcmp(section, &option[1])) {
! tdsdump_log(TDS_DBG_INFO1, "%L Found matching
section\n");
insection=1;
found=1;
} else {
--- 254,267 ----
if (option[0]=='[') {
s = &option[1];
while (*s) {
! if (*s==']') *s='\0';
! s = tolower(s);
s++;
}
+ tdsdump_log(TDS_DBG_INFO1, "%L ... Found section
%s.\n", &option[1]);
+
if (!strcmp(section, &option[1])) {
! tdsdump_log(TDS_DBG_INFO1, "%L Got a
match.\n");
insection=1;
found=1;
} else {
***************
*** 248,254 ****
insection=0;
}
} else if (insection) {
! /* fprintf(stderr,"option = '%s' value = '%s'\n",
option, value); */
if (!strcmp(option,TDS_STR_VERSION)) {
tds_config_verstr(value, config);
} else if (!strcmp(option,TDS_STR_BLKSZ)) {
--- 268,275 ----
insection=0;
}
} else if (insection) {
! /* fprintf(stderr,"option = '%s' value = '%s'\n",
option, value); */
! tdsdump_log(TDS_DBG_INFO1, "%L option = '%s' value
= '%s'.\n", option, value);
if (!strcmp(option,TDS_STR_VERSION)) {
tds_config_verstr(value, config);
} else if (!strcmp(option,TDS_STR_BLKSZ)) {
***************
*** 280,290 ****
if (atoi(value))
config->connect_timeout = atoi(value);
} else if (!strcmp(option,TDS_STR_HOST)) {
! tdsdump_log(TDS_DBG_INFO1, "%L Found host
entry %s\n",value);
lookup_host(value, NULL, tmp, NULL);
if (config->ip_addr) free(config->ip_addr);
config->ip_addr = strdup(tmp);
! tdsdump_log(TDS_DBG_INFO1, "%L IP addr is
%s\n",config->ip_addr);
} else if (!strcmp(option,TDS_STR_PORT)) {
if (atoi(value))
config->port = atoi(value);
--- 301,311 ----
if (atoi(value))
config->connect_timeout = atoi(value);
} else if (!strcmp(option,TDS_STR_HOST)) {
! tdsdump_log(TDS_DBG_INFO1, "%L Found host
entry %s.\n",value);
lookup_host(value, NULL, tmp, NULL);
if (config->ip_addr) free(config->ip_addr);
config->ip_addr = strdup(tmp);
! tdsdump_log(TDS_DBG_INFO1, "%L IP addr is
%s.\n",config->ip_addr);
} else if (!strcmp(option,TDS_STR_PORT)) {
if (atoi(value))
config->port = atoi(value);
***************
*** 305,310 ****
--- 326,332 ----
} else if (!strcmp(option,TDS_STR_APPENDMODE)) {
g_append_mode = tds_config_boolean(value);
}
+ else tdsdump_log(TDS_DBG_INFO1, "%L UNRECOGNIZED
option '%s'...ignoring.\n", option);
}
}
***************
*** 401,410 ****
{
char *s;
! if ((s=getenv("DSQUERY"))) {
if (s && strlen(s)) {
if (config->server_name) free(config->server_name);
config->server_name = strdup(s);
}
}
}
--- 423,434 ----
{
char *s;
! if ((s=getenv("TDSQUERY"))) {
if (s && strlen(s)) {
if (config->server_name) free(config->server_name);
config->server_name = strdup(s);
+ tdsdump_log(TDS_DBG_INFO1, "%L Setting
'server_name' to '%s' from $TDSQUERY.\n",s);
+
}
}
}
***************
*** 424,429 ****
--- 448,454 ----
if (config->dump_file) free(config->dump_file);
config->dump_file = strdup(s);
}
+ tdsdump_log(TDS_DBG_INFO1, "%L Setting 'dump_file' to '%s'
from $TDSDUMP.\n",config->dump_file);
}
}
static void tds_config_env_tdsport(TDSCONFIGINFO *config)
***************
*** 431,437 ****
char *s;
if ((s=getenv("TDSPORT"))) {
! config->port=atoi(s);
}
return;
}
--- 456,463 ----
char *s;
if ((s=getenv("TDSPORT"))) {
! config->port=atoi(s);
! tdsdump_log(TDS_DBG_INFO1, "%L Setting 'port' to %s from
$TDSPORT.\n",s);
}
return;
}
***************
*** 440,446 ****
char *tdsver;
if ((tdsver=getenv("TDSVER"))) {
! tds_config_verstr(tdsver, config);
}
return;
}
--- 466,474 ----
char *tdsver;
if ((tdsver=getenv("TDSVER"))) {
! tds_config_verstr(tdsver, config);
! tdsdump_log(TDS_DBG_INFO1, "%L Setting 'tdsver' to %s from
$TDSVER.\n",tdsver);
!
}
return;
}
***************
*** 455,460 ****
--- 483,490 ----
if (config->ip_addr)
free (config->ip_addr);
config->ip_addr = strdup (tmp);
+ tdsdump_log(TDS_DBG_INFO1, "%L Setting 'ip_addr' to %s (%s)
from $TDSHOST.\n",tmp, tdshost);
+
}
return;
}
***************
*** 614,620 ****
tmp_port[0] = '\0';
tmp_ver[0] = '\0';
! tdsdump_log(TDS_DBG_INFO1, "%L Searching interfaces file
%s/%s\n",dir,file);
pathname = (char *) malloc(strlen(dir) + strlen(file) + 10);
/*
--- 644,650 ----
tmp_port[0] = '\0';
tmp_ver[0] = '\0';
! tdsdump_log(TDS_DBG_INFO1, "%L Searching interfaces file
%s/%s.\n",dir,file);
pathname = (char *) malloc(strlen(dir) + strlen(file) + 10);
/*
***************
*** 637,646 ****
* parse the interfaces file and find the server and port
*/
if ((in = fopen(pathname,"r"))==NULL) {
! free(pathname);
return;
}
! tdsdump_log(TDS_DBG_INFO1, "%L Interfaces file opened\n");
while (fgets(line,sizeof(line)-1,in)) {
if (line[0]=='#') continue; /* comment */
--- 667,677 ----
* parse the interfaces file and find the server and port
*/
if ((in = fopen(pathname,"r"))==NULL) {
! tdsdump_log(TDS_DBG_INFO1, "%L Couldn't open %s.\n",
pathname);
! free(pathname);
return;
}
! tdsdump_log(TDS_DBG_INFO1, "%L Interfaces file %s opened.\n",
pathname);
while (fgets(line,sizeof(line)-1,in)) {
if (line[0]=='#') continue; /* comment */
***************
*** 649,655 ****
field = strtok(line,"\n\t ");
if (!strcmp(field,host)) {
found=1;
! tdsdump_log(TDS_DBG_INFO1, "%L Found matching
entry.\n");
}
else found=0;
} else if (found && isspace(line[0])) {
--- 680,686 ----
field = strtok(line,"\n\t ");
if (!strcmp(field,host)) {
found=1;
! tdsdump_log(TDS_DBG_INFO1, "%L Found matching
entry for host %s.\n,host");
}
else found=0;
} else if (found && isspace(line[0])) {
***************
*** 667,672 ****
--- 698,704 ----
sprintf(tmp_ip,"%d.%d.%d.%d",
hex2num(&field[10]),
hex2num(&field[12]),
hex2num(&field[14]),
hex2num(&field[16]));
+ tdsdump_log(TDS_DBG_INFO1,
"%L tmp_port = %d.mtp_ip = %s.\n", tmp_port, tmp_ip);
}
} else {
field = strtok(NULL,"\n\t "); /*
ether */
***************
*** 673,679 ****
strcpy(tmp_ver,field);
field = strtok(NULL,"\n\t "); /* host
*/
strcpy(tmp_ip,field);
! tdsdump_log(TDS_DBG_INFO1, "%L host
field %s\n",tmp_ip);
field = strtok(NULL,"\n\t "); /* port
*/
strcpy(tmp_port,field);
} /* else */
--- 705,711 ----
strcpy(tmp_ver,field);
field = strtok(NULL,"\n\t "); /* host
*/
strcpy(tmp_ip,field);
! tdsdump_log(TDS_DBG_INFO1, "%L host
field %s.\n",tmp_ip);
field = strtok(NULL,"\n\t "); /* port
*/
strcpy(tmp_port,field);
} /* else */
***************
*** 688,694 ****
* Look up the host and service
*/
lookup_host(tmp_ip, tmp_port, ip_addr, ip_port);
! tdsdump_log(TDS_DBG_INFO1, "%L Resolved IP %s\n",ip_addr);
strcpy(tds_ver,tmp_ver);
} /* search_interface_file() */
--- 720,726 ----
* Look up the host and service
*/
lookup_host(tmp_ip, tmp_port, ip_addr, ip_port);
! tdsdump_log(TDS_DBG_INFO1, "%L Resolved IP as '%s'.\n",ip_addr);
strcpy(tds_ver,tmp_ver);
} /* search_interface_file() */
***************
*** 718,728 ****
ip_port[0] = '\0';
tds_ver[0] = '\0';
if (!server || strlen(server) == 0) {
! server = getenv("DSQUERY");
if(!server || strlen(server) == 0) {
server = "SYBASE";
}
}
/*
--- 750,763 ----
ip_port[0] = '\0';
tds_ver[0] = '\0';
+ tdsdump_log(TDS_DBG_INFO1, "%L Looking for server....\n");
if (!server || strlen(server) == 0) {
! server = getenv("TDSQUERY");
if(!server || strlen(server) == 0) {
server = "SYBASE";
}
+ tdsdump_log(TDS_DBG_INFO1, "%L Setting server to %s from
$TDSQUERY.\n",server);
+
}
/*
***************
*** 729,736 ****
* Look for the server in the interf_file iff interf_file has been set.
*/
if (ip_addr[0]=='\0' && interf_file[0]!='\0') {
! search_interface_file("", interf_file, server, ip_addr,
! ip_port, tds_ver);
}
/*
--- 764,772 ----
* Look for the server in the interf_file iff interf_file has been set.
*/
if (ip_addr[0]=='\0' && interf_file[0]!='\0') {
! tdsdump_log(TDS_DBG_INFO1, "%L Looking for server in
interf_file %s.\n",interf_file);
! search_interface_file("", interf_file, server, ip_addr,
! ip_port, tds_ver);
}
/*
***************
*** 739,745 ****
if (ip_addr[0]=='\0') {
char *home = getenv("HOME");
if (home!=NULL && home[0]!='\0') {
! search_interface_file(home, ".interfaces", server,
ip_addr,
ip_port, tds_ver);
}
}
--- 775,782 ----
if (ip_addr[0]=='\0') {
char *home = getenv("HOME");
if (home!=NULL && home[0]!='\0') {
! tdsdump_log(TDS_DBG_INFO1, "%L Looking for server
in %s/.interfaces.\n", home);
! search_interface_file(home, ".interfaces", server,
ip_addr,
ip_port, tds_ver);
}
}
***************
*** 750,759 ****
if (ip_addr[0]=='\0') {
char *sybase = getenv("SYBASE");
if (sybase!=NULL && sybase[0]!='\0') {
! search_interface_file(sybase, "interfaces", server,
ip_addr,
ip_port, tds_ver);
} else {
! search_interface_file("/etc/freetds", "interfaces",
server,
ip_addr, ip_port, tds_ver);
}
}
--- 787,798 ----
if (ip_addr[0]=='\0') {
char *sybase = getenv("SYBASE");
if (sybase!=NULL && sybase[0]!='\0') {
! tdsdump_log(TDS_DBG_INFO1, "%L Looking for server
in %s/interfaces.\n", sybase);
! search_interface_file(sybase, "interfaces", server,
ip_addr,
ip_port, tds_ver);
} else {
! tdsdump_log(TDS_DBG_INFO1, "%L Looking for server
in /etc/freetds/interfaces.\n");
! search_interface_file("/etc/freetds", "interfaces",
server,
ip_addr, ip_port, tds_ver);
}
}
***************
*** 777,784 ****
--- 816,826 ----
/* FIX ME -- Need a symbolic constant for the environment
variable */
if (getenv("TDSPORT")!=NULL) {
tmp_port = getenv("TDSPORT");
+ tdsdump_log(TDS_DBG_INFO1, "%L Setting 'tmp_port'
to %s from $TDSPORT.\n",tmp_port);
}
+ else tdsdump_log(TDS_DBG_INFO1, "%L Setting 'tmp_port' to
%s as a guess.\n",tmp_port);
+
/*
* lookup the host and service
*/
*** freetds.conf.ORIG Tue May 7 12:57:48 2002
--- freetds.conf Tue May 7 12:13:10 2002
***************
*** 1,4 ****
--- 1,7 ----
#
+ #
+ # $Id$
+ #
# The freetds.conf file is a replacement for the original interfaces
# file developed by Sybase. You may use either this or the interfaces
# file, but not both.
***************
*** 8,19 ****
# 1) check if a file was set programatically via dbsetifile() and
# is in .conf format, if so use that,
#
! # 2) look in ~/.freetds.conf
#
! # 3) look in @sysconfdir@/freetds.conf
#
# If FreeTDS has found no suitable conf file it will then search for
! # an an interfaces file in the following order:
#
# 1) check if a file was set programatically via dbsetifile() and
# is in interfaces format, if so use that,
--- 11,25 ----
# 1) check if a file was set programatically via dbsetifile() and
# is in .conf format, if so use that,
#
! # 2) otherwise, if env variable FREETDSCONF specifies a properly
! # formatted config file, use it,
#
! # 3) otherwise, look in ~/.freetds.conf,
#
+ # 4) otherwise, look in @sysconfdir@/freetds.conf
+ #
# If FreeTDS has found no suitable conf file it will then search for
! # an interfaces file in the following order:
#
# 1) check if a file was set programatically via dbsetifile() and
# is in interfaces format, if so use that,
***************
*** 32,38 ****
# server's name which will have settings which override the global
# ones.
#
!
# Global settings, any value here may be overridden by a database
# server specific section
[global]
--- 38,49 ----
# server's name which will have settings which override the global
# ones.
#
! # Note that environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY,
! # and TDSHOST will override values set by a .conf or .interfaces file.
! #
! # To review the processing of the above, set env variable TDSDUMPCONFIG
! # to a file name to log configuration processing.
! #
# Global settings, any value here may be overridden by a database
# server specific section
[global]
*** doc/userguide.sgml.ORIG Tue May 7 12:57:49 2002
--- doc/userguide.sgml Tue May 7 18:34:44 2002
***************
*** 452,474 ****
</sect3>
<sect3><title><parameter>TDSVER</parameter></title>
<para>
! The other environment variable, <parameter>TDSVER</parameter> governs the
version of the TDS protocol used to connect to your server. For a given
server, FreeTDS ses three sources in the following order to determine which
TDS protocol version to use.
</para>
<orderedlist>
! <listitem><para>The Interfaces file entry
(see below)
</para></listitem>
! <listitem><para>The value of the TDSVER
environment variable
</para></listitem>
! <listitem><para>The --with-tdsver option
passed to <command>configure</command>
</para></listitem>
! </orderedlist>
! </sect3>
! </sect2>
!
<sect2>
! <title>Setting the TDSVER and SYBASE environment
variables</title>
<para>
! Of course, each shell is a little different. In ksh or bash:
<screen>
<prompt>$ </prompt><userinput>export SYBASE=/usr/local/freetds</userinput>
# (or your favorite directory)
<prompt>$ </prompt><userinput>export TDSVER=42</userinput>
--- 452,505 ----
</sect3>
<sect3><title><parameter>TDSVER</parameter></title>
<para>
! The environment variable <parameter>TDSVER</parameter> governs the version
of the TDS protocol used to connect to your server. For a given server,
FreeTDS inspects four sources in the following order to determine which TDS
protocol version to use.
</para>
<orderedlist>
! <listitem><para>The file specified in the
<parameter>TDSVER</parameter> environment variable
</para></listitem>
! <listitem><para>A freetds.conf file entry
(see below)
</para></listitem>
! <listitem><para>The Interfaces file entry
(see below)
</para></listitem>
! <listitem><para>The --with-tdsver option
passed to <command>configure</command>
! </para></listitem
! </orderedlist>
! </sect3>
! <sect3><title>The <parameter>TDSDUMP</parameter>,
<parameter>TDSPORT</parameter>, <parameter>TDSQUERY</parameter> and
<parameter>TDSHOST</parameter> environment variables</title>
! <para>
! The environment variables <parameter>TDSDUMP</parameter>,
<parameter>TDSPORT</parameter>, <parameter>TDSQUERY</parameter> and
! <parameter>TDSHOST</parameter> may also be use to override or force
certain key configuration parameters, namely the file to dump debugging
information, the port to connect to, the server name, and the host to connect
to.
! </para>
! <para>
! As with <parameter>TDSVER</parameter>, each of these environment variable
override the corresponding line found in the freetds.conf or interfaces file.
! </para>
! </sect3>
! <sect3><title>The <parameter>FREETDSCONF</parameter> environment
variable></title>
! <para>
! The <parameter>FREETDSCONF</parameter> environment variable> may be
! used to specify a freetds.conf file, as discussed below.
! </para>
! </sect3>
! <sect3><title>The <parameter>TDSDUMP</parameter> and
<parameter>TDSDUMPCONFIG</parameter> environment variables</title>
! <para>
! Unlike the above-discussed environment variables the
<parameter>TDSDUMP</parameter> and <parameter>TDSDUMPCONFIG</parameter>
variables are used to help diagnose problems in the operation of FreeTDS.
! </para>
! <para>
! Set <parameter>TDSDUMP</parameter> to a file to write debugging
! information to. Set <parameter>TDSDUMPCONFIG</parameter> to a file to
! write information to on how the configuration information is being
! obtained, e.g. from environment variables, a freetds.conf file, or
interface file.
! </para>
! <para>
! For more information on logging, see the section below so titled.
! </para>
! </sect3>
! </sect2>
<sect2>
! <title>Setting environment variables</title>
<para>
! Of course, each shell is a little different. In ksh or bash, to set
! <parameter>SYBASE</parameter> and <parameter>TDSVER</parameter> do:
<screen>
<prompt>$ </prompt><userinput>export SYBASE=/usr/local/freetds</userinput>
# (or your favorite directory)
<prompt>$ </prompt><userinput>export TDSVER=42</userinput>
***************
*** 501,511 ****
<para>
There are two methods of configuring FreeTDS. Under Sybase OpenClient
there is a file called <filename>interfaces</filename> that defines servers
available to the software. FreeTDS inherited this file structure with minor
alterations. Starting with version 0.52, we felt that the file format could
not support some of the more advanced options we needed. Thus FreeTDS
created a newer second format, loosely based on Samba's modified win ini
format. The <filename>interfaces</filename> remains supported for backward
compatiblity and those running in a mixed FreeTDS/Sybase environment.
</para>
<para>
! The <filename>freetds.conf</filename> defines the dataservers available to
freetds. When FreeTDS receives a request to connect to a database server, it
first looks up the servername in <filename>freetds.conf</filename>. There,
it finds a number of properties for the server such as the machine name (or
address), port number to connect to, and the protocol version to use.
</para>
<para>
! The conf file is composed of two types of sections a [global] section and
one section for each dataserver listed. Settings in the [global] section
affect all dataservers and can be overridden in the dataserver section. For
example
</para>
<example>
<title>An <filename>freetds.conf</filename> file example</title>
--- 532,550 ----
<para>
There are two methods of configuring FreeTDS. Under Sybase OpenClient
there is a file called <filename>interfaces</filename> that defines servers
available to the software. FreeTDS inherited this file structure with minor
alterations. Starting with version 0.52, we felt that the file format could
not support some of the more advanced options we needed. Thus FreeTDS
created a newer second format, loosely based on Samba's modified win ini
format. The <filename>interfaces</filename> remains supported for backward
compatiblity and those running in a mixed FreeTDS/Sybase environment.
</para>
+ <para>
+ The freetds.conf filename may be specified by the environment varible
+ <parameter>FREETDSCONF</parameter>, or be found at
+ <filename>~/.freetds.conf</filename>, or in sysconfdir
+ (/usr/local/freetds/etc by default). The first properly
+ configured (i.e., a readable file with a section for the server)
+ freetds.conf file will be the only one used.
+ </para>
<para>
! The freetds.conf file defines the dataservers available to freetds. When
FreeTDS receives a request to connect to a database server, it first looks up
the servername in freetds.conf. There, it finds a number of properties for
the server such as the machine name (or address), port number to connect to,
and the protocol version to use.
</para>
<para>
! The freetds.conf file is composed of two types of sections a [global]
section and one section for each dataserver listed. Settings in the [global]
section affect all dataservers and can be overridden in the dataserver
section. For example
</para>
<example>
<title>An <filename>freetds.conf</filename> file example</title>
***************
*** 1676,1682 ****
<sect1>
<title>Logging</title>
<para>
! Log files can be turned on using the TDSDUMP environment variable. For
instance, setting the location of a dumpfile
<screen>
<prompt>$ </prompt><userinput>export TDSDUMP=/tmp/freetds.log</userinput>
</screen>
--- 1715,1721 ----
<sect1>
<title>Logging</title>
<para>
! Log files can be turned on using the <parameter>TDSDUMP</parameter>
environment variable. For instance, setting the location of a dumpfile
<screen>
<prompt>$ </prompt><userinput>export TDSDUMP=/tmp/freetds.log</userinput>
</screen>
***************
*** 1683,1697 ****
Will generate a log file named freetds.log in the /tmp directory.
</para>
<para>
! This works well when you run a FreeTDS program from the command line, but
what if you were running Apache/PHP? Apache has many children. Setting the
TDSDUMP variable with a blank will cause FreeTDS to open a log under every
PID.
<screen>
<prompt>$ </prompt><userinput>export TDSDUMP=""</userinput>
</screen>
! The log files will be named /tmp/freetds/freetds.log.9999 where 9999 is the
pid number of the process generating the log.
</para>
<para>
! A couple of important notes about using the logs with FreeTDS. First, the
logs tend to grow large, so trim or archive them often. Secondly, FreeTDS
will record certain network packets to the log, <emphasis>this includes login
packets which can contain clear text or clear text equivelant
passwords.</emphasis> So, if this is a concern (most likely is) make sure
that the files are not world readable, and avoid posting them to mailing
lists.
! </para>
</sect1>
<sect1 id="pagenodata">
<title>"Page contains no data"</title>
--- 1722,1747 ----
Will generate a log file named freetds.log in the /tmp directory.
</para>
<para>
! This works well when you run a FreeTDS program from the command line,
! but what if you were running Apache/PHP? Apache has many children.
! Setting the <parameter>TDSDUMP</parameter> variable to a null string will
cause FreeTDS to open a log under every PID.
<screen>
<prompt>$ </prompt><userinput>export TDSDUMP=""</userinput>
</screen>
! The log files will be named <filename>/tmp/freetds.log.9999</filename>
where 9999 is the pid number of the process generating the log.
</para>
<para>
! A couple of important notes about using the logs with FreeTDS. First,
! the logs tend to grow large, so trim or archive them often. Secondly,
! FreeTDS will record certain network packets to the log, <emphasis>this
! includes login packets which can contain clear text or clear text
! equivelant passwords.</emphasis> So, if this is a concern (most likely
! is) make sure that the files are not world readable, and avoid posting
! them to mailing lists.
! </para>
! <para>
! To assist in determining how configuration files are processed, environment
variable <parameter>TDSDUMPCONFIG</parameter> may be set to the name of a
file to write configuration file processing information to. For obvious
reasons, unlike <parameter>TDSDUMP</parameter>, this can only be set via the
environment variable. If it is set to the null string the log file name will
default to /tmp/tdsconfig.log.9999 where 9999 is the pid of the process
generating the log.
! </para>
</sect1>
<sect1 id="pagenodata">
<title>"Page contains no data"</title>
- Patch to better log config file and env processing, w/ updated documentation, Harry Felder, 05/07/2002
Archive powered by MHonArc 2.6.24.