Skip to Content.
Sympa Menu

freetds - [freetds] idea: netrc

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: jklowden AT schemamania.org
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] idea: netrc
  • Date: Fri, 13 Oct 2006 14:47:23 -0400

The attached tarball implements the beginning of an idea. I'd like
some feedback on how easy it is to compile before I integrate it
into FreeTDS.

The idea: give users a place to cache their usernames and passwords,
so that scripts don't have to contain them. I know this isn't universally
popular; it would be a configure option.

With the option enabled, the library's behavior would change only
slightly: if no username were provided, it would try to look up
the username & password based on the servername. Thus, you could
do:

$ tsql -S server

instead of

$ tsql -S server -U user -P password

We could make this a feature of the utilities provided with FreeTDS, or
a feature of the libraries -- thus making it available to applications --
or both. I can see arguments for any combination. If the functionality
were neatly partitioned in its own little library/function, developers
could easily use it on a case-by-case basis.

I thought of two ways to this: the sqsh way and the ftp way. The
sqsh way (~/.sqshrc) is appealing for obvious reasons, but has two drawbacks,
one fatal: it supports only one server. So I opted for the ftp way.

Specifically, I looked at NetBSD's ftp client. It has a portable
version called tnftp (previously known as lukemftp). It reads a
file called ${HOME}/.netrc or ${NETRC}/.netrc. The file must be
owned by the user and readable only by him. It is not encrypted
in any way; if you don't want the root user on your system to be
able to learn what would be in the file, don't use it.

I'm not going to describe the file except to say it has
server-user-password tuples. You can read the man page here:

http://netbsd.gw.com/cgi-bin/man-cgi?ftp++NetBSD-current

(look for "THE .netrc FILE") and download the software here:

ftp://ftp.netbsd.org/pub/NetBSD/misc/tnftp/tnftp-20050625.tar.gz

All I've done so far is to lift the necesary code (it's BSD-licensed) from
tnftp and write a simple utility to call the lookup function and print
the results. I'm curious how easy/hard it is to compile on non-NetBSD
systems, which is another way of saying I wonder how many new replacement
functions we'd have to add to use this code. If not too much, then adding
it to our CVS tree would be reasonable.

Please give it a try and let me know your thoughts. Thanks.

--jkl

Attachment: netrc.pax.gz
Description: application/gunzip



  • [freetds] idea: netrc, jklowden, 10/13/2006

Archive powered by MHonArc 2.6.24.

Top of Page