Skip to Content.
Sympa Menu

freetds - [freetds] patch for freebcp: take password from stdin instead of command line

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Constantin Vasilyev <vasilyev AT ncbi.nlm.nih.gov>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] patch for freebcp: take password from stdin instead of command line
  • Date: Tue, 3 Oct 2006 22:41:13 -0400 (EDT)

It is useful for database client tool to be able to hide password.
Patch below makes freebcp to read password from stdin if '-' is supplied
as a parameter for -P option ( -P- ). This way the password can't be seen
by others via ps -f.

Constantin Vasilyev
NCBI Contractor, DBA


---8<--------------------------------------------------------------


Index: freebcp.c
===================================================================
RCS file: /cvsroot/freetds/freetds/src/apps/freebcp.c,v
retrieving revision 1.45
diff -u -r1.45 freebcp.c
--- freebcp.c 12 Jun 2006 19:45:59 -0000 1.45
+++ freebcp.c 4 Oct 2006 02:14:02 -0000
@@ -257,7 +257,16 @@
break;
case 'P':
pdata->Pflag++;
- pdata->pass = strdup(optarg);
+ if ((strcmp(optarg, "-")) == 0) {
+ char pwd[255], *nl;
+ memset(pwd, 0, 255);
+ fgets(pwd, 255, stdin);
+ nl = strchr(pwd, '\n');
+ if(nl) *nl = '\0';
+ pdata->pass = strdup(pwd);
+ } else {
+ pdata->pass = strdup(optarg);
+ }
break;
case 'I':
pdata->Iflag++;




Archive powered by MHonArc 2.6.24.

Top of Page