freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Modesto Sevilla <mpsevill AT uci.edu>
- To: freetds AT lists.ibiblio.org
- Subject: [freetds] Hiding password in bsqldb
- Date: Tue, 18 Aug 2009 10:39:28 -0700
Hello,
I had been searching for a solution to pass in the password to bsqldb and freebcp from an encrypted file which would not be displayed by using ps while the job is running. I found that someone was looking for the same solution but there was no concrete solution. While studying the code in freebcp.c I saw an undocumented feature that actually does the trick. You can use -P- and it will read the password from stdin.
253 case 'P':
254 pdata->Pflag++;
255 if ((strcmp(optarg, "-")) == 0) {
256 char pwd[255], *nl;
257 memset(pwd, 0, 255);
258 fgets(pwd, 255, stdin);
259 nl = strchr(pwd, '\n');
260 if(nl) *nl = '\0';
261 pdata->pass = strdup(pwd);
262 } else {
263 pdata->pass = strdup(optarg);
264 }
265 break;
In my shell script now I am able to do this and the password is not displayed in ps.
#!/bin/sh
getencryptedpw PW | freebcp TABLE out DATFILE -f FMTFILE -S SERVER -U USERNAME -P-
The password is resolved and piped into freebcp without displaying through ps.
I am not a C programmer so I was wondering if someone could make the same change to the other apps such as bsqldb. I was thinking that it would look something like this in bsqldb:
786 case 'P':
787 got_password = 1;
if ((strcmp(optarg, "-")) == 0) {
char pwd[255], *nl;
memset(pwd, 0, 255);
fgets(pwd, 255, stdin);
nl = strchr(pwd, '\n');
if(nl) *nl = '\0';
DBSETLPWD(login, pwd);
} else {
DBSETLPWD(login, optarg);
}
break;
Just wanted to see what people thought and if they find this useful.
Thank you.
*James K. Lowden* jklowden at freetds.org <mailto:freetds%40lists.ibiblio.org?Subject=%5Bfreetds%5D%20Hiding%20password%20in%20fisql%20and%20bsqldb&In-Reply-To=BB433306F449CD42BB0F5A06B2B49D0D24A4F8%40dc1mailbox03.mpls.digitalriver.com>
/Mon Dec 22 21:01:59 EST 2008/
* Previous message: [freetds] Hiding password in fisql and bsqldb
<https://lists.ibiblio.org/sympa/arc/freetds/2008q4/024186.html>
* Next message: [freetds] Hiding password in fisql and bsqldb
<https://lists.ibiblio.org/sympa/arc/freetds/2008q4/024190.html>
* *Messages sorted by:* [ date ]
<https://lists.ibiblio.org/sympa/arc/freetds/2008q4/date.html#24188>
[ thread ]
<https://lists.ibiblio.org/sympa/arc/freetds/2008q4/thread.html#24188>
[ subject ]
<https://lists.ibiblio.org/sympa/arc/freetds/2008q4/subject.html#24188>
[ author ]
<https://lists.ibiblio.org/sympa/arc/freetds/2008q4/author.html#24188>
------------------------------------------------------------------------
Peter Chase wrote:
/ I'm trying to use fisql and bsqldb in a bash script and I'm having/>/ problems finding a way to hide the password from the ps command without
/>/ requiring user input.
/
Yeah, it's a problem. On my agenda for some time is adding the ability to
use $HOME/.netrc for that purpose, as some ftp clients do. sqsh uses
.sqshrc to do the same thing (except limited to one
server+username+password tuple).
It would be a welcome patch.
--jkl
-
[freetds] Hiding password in bsqldb,
Modesto Sevilla, 08/18/2009
- Re: [freetds] Hiding password in bsqldb [NC], Cedric ROUVRAIS, 08/18/2009
Archive powered by MHonArc 2.6.24.