Skip to Content.
Sympa Menu

freetds - [freetds] Proposed patch to datacopy to allow passwords to be read from stdin

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "PublicMailbox AT benslade.com" <PublicMailbox AT benslade.com>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Proposed patch to datacopy to allow passwords to be read from stdin
  • Date: Thu, 16 Aug 2012 11:36:21 -0400

The patch below would permit the datacopy utility to use a dash for the
password in the source or destination server parameter to mean "read from
standard in". For example:

datacopy -Smyserver/myusername/-/mydatabase/mytable ...

Upon finding a dash for the password, datacopy would prompt for the password
and read it in.

Using a dash for a parameter to specify "read from stdin" is a typical style
for many Unix/Linux utilities.

This feature is needed to prevent the security violation of putting a
password on the command line (which makes it visible to ps -f in Unix/Linux).
For batch (non-interactive)
jobs in an enterprise environment, this is a mandatory requirement. Using
kerberos might be better, but that's a much harder change.

Ben Slade
DBA @ NCBI.NLM.NIH.gov


> diff -u datacopy.c.orig datacopy.c
--- datacopy.c.orig 2011-05-16 04:51:40.000000000 -0400
+++ datacopy.c 2012-08-16 11:18:55.583213000 -0400
@@ -246,6 +246,10 @@
if (!tok)
return FALSE;
pdata->spass = strdup(tok);
+ if( strcmp(pdata->spass,"-") == 0 ) {
+ printf("Enter Source Password : ");
+ pdata->spass = gets_alloc();
+ }

tok = strtok(NULL, "/");
if (!tok)
@@ -277,6 +281,10 @@
if (!tok)
return FALSE;
pdata->dpass = strdup(tok);
+ if( strcmp(pdata->dpass,"-") == 0 ) {
+ printf("Enter Destination Password
: ");
+ pdata->dpass = gets_alloc();
+ }

tok = strtok(NULL, "/");
if (!tok)







Archive powered by MHonArc 2.6.24.

Top of Page