Bug #43430 Connector/ODBC for linux rewrites private odbc.ini file
Submitted: 5 Mar 2009 18:40 Modified: 6 Mar 2009 17:21
Reporter: Mike Peck Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:3.51.27 OS:Linux (RHEL4u6)
Assigned to: CPU Architecture:Any
Tags: ODBC, odbc.ini, write access

[5 Mar 2009 18:40] Mike Peck
Description:
I have an application provided by a vendor, that I tried to move from the unix ODBC driver 3.51.12 to 3.51.27.

unixODBC-2.2.11-1 is the actual ODBC driver in both cases (3.51.12 and 3.51.27), while the new library I'm using is from mysql-connector-odbc-3.51.27-linux-x86-32bit.tar.gz.

The application consistently failed with the 3.51.27 driver, giving slim indications that there was no database given in the odbc.ini file (the error returned was: Error executing query "USE null").

/etc/odbc.ini is empty in my environment, and I have a separate ini file that I specify on the command line (I execute "ODBCINI=/my/path/odbc.ini appname").

After running strace to find out why the app failed to connect, I found this:

open("/my/path/odbc.ini", O_WRONLY|O_CREAT|O_APPEND, 0666) = -1 EACCES (Permission denied)

I made this file writable by the user running the application, and things worked correctly.  Running 'md5sum' on the odbc.ini file before and after the application run shows that the file is not modified, however, the timestamp shown by the file system is updated.

I find it interesting to note that if /etc/odbc.ini is used rather than my supplying a value for ODBCINI, the file does not need to be rw, read-only access is good enough.

I don't think it's relevant, but just in case, I'm connecting to a version 4.1 server.

How to repeat:
Specify ODBCINI pointing to a read-only file, and an ODBC application will fail to connect to the database.
[6 Mar 2009 17:21] Jess Balint
Mike,
MyODBC is not responsible for doing this, it's unixODBC. I tried this on my machine and it works fine with a read-only file, although it does try to open the file with write permissions initially:

open("odbc.ini", O_WRONLY|O_APPEND|O_CREAT, 0666) = -1 EACCES (Permission denied)
open("odbc.ini", O_RDONLY)              = 3
[6 Mar 2009 19:18] Jim Zawisza
FYI, I work for the vendor providing the application in question, and the application is using iODBC (statically linked).
[6 Mar 2009 19:31] Jess Balint
This behaviour is not reproducible with iODBC.