[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freetds
Subject:    Re: [freetds] Username and password in odbc.ini instead of command line
From:       "James K. Lowden" <jklowden () freetds ! org>
Date:       2012-01-18 23:19:07
Message-ID: 20120118181907.0b346c09.jklowden () freetds ! org
[Download RAW message or body]

On Wed, 18 Jan 2012 16:53:06 -0500
Ruiyuan Jiang <Ruiyuan_Jiang@liz.com> wrote:

> Since we will access MSSQL server through application, there is a
> request that whether I can put the username and password into
> odbc.ini instead of part of 'isql' command line. I appended
> "username=xxx" and "password=xxx" in the odbc.ini.
> 
> $ isql -v MSSQLSERVER
> [S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
...
> I have tried to use "user", "uid" and "userid" instead of
"username"
> in the odbc.ini but no luck. 

http://www.freetds.org/userguide/odbcconnattr.htm

The FreeTDS ODBC driver does not read user credentials from odbc.ini.  

Besides the obvious security issue, things like UID and PWD don't
belong in odbc.ini because they don't describe the server or the
connection.  Only one of many potential users could be the "DSN user".
Not much upside potential there.  

What to do?  

Best is to use Kerberos.  

Second-best is to keep the username and password in a file, and
read that at runtime.  For example, some ftp clients define a file
${HOME}/.netrc that must have 0600 permissions. Each line has the form

	machine M login U password P

where U and P are the username and password for machine M.  

You can use such a file to get the password without echoing it to the
log like this:

	$ bsqlodbc -S $S -U $U 
		-P $(awk "/^machine.*$S/ {print \$6}" {$HOME}/.netrc)

It's a neater if that awk bit is in a little script

	$ bsqlodbc -S $S -U $U -P $(password $S $U)

HTH.  

--jkl

_______________________________________________
FreeTDS mailing list
FreeTDS@lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic