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

List:       freetds
Subject:    Re: [freetds] Hiding password in bsqldb [NC]
From:       Cedric ROUVRAIS <cedric.rouvrais () sgcib ! com>
Date:       2009-08-18 18:32:37
Message-ID: OF00B11F32.00E1CAE4-ON85257616.0065A24E-85257616.0065DE45 () us ! world ! socgen
[Download RAW message or body]

Hi Modesto,

The issue here that you need to think about is that many people send to
isql a specified set of commands. Thought will have to be given as to how
this change will affect behaviour :o)

I can compile for linux server if you wish, the only caveat is that my
version of bsqldb is different from the current trunk as I have changed to
make it identical Sybase ISQL as we are migrating from Sybase to SQL
Server.

a++ Cedric




> ------------------------------                                            
> Modesto Sevilla                                               
> <mpsevill@uci.edu                                             
> > 
> Sent by:                                                      
> freetds-bounces@l                                             
> ists.ibiblio.org                                              
> 
> 
> 08/18/2009 01:39                                              
> PM                                                            
> 
> 
> Please respond to                                             
> FreeTDS                                                  
> Development Group                                             
> <freetds@lists.ib                                             
> iblio.org>                                                 
> 
> 
                                                                           
                                                                           
                                                                        To 
                                               freetds@lists.ibiblio.org   
                                                                        cc 
                                                                           
                                                                   Subject 
                                               [freetds] Hiding password   
                                               in bsqldb                   
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




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%20fi \
sql%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
      <http://lists.ibiblio.org/pipermail/freetds/2008q4/024186.html>
    * Next message: [freetds] Hiding password in fisql and bsqldb
      <http://lists.ibiblio.org/pipermail/freetds/2008q4/024190.html>
    * *Messages sorted by:* [ date ]
      <http://lists.ibiblio.org/pipermail/freetds/2008q4/date.html#24188>
      [ thread ]
      <http://lists.ibiblio.org/pipermail/freetds/2008q4/thread.html#24188>
      [ subject ]
      <http://lists.ibiblio.org/pipermail/freetds/2008q4/subject.html#24188
> 
      [ author ]
      <http://lists.ibiblio.org/pipermail/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 mailing list
FreeTDS@lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds



*************************************************************************
This message and any attachments (the "message") are confidential, intended 
solely for the addressee(s), and may contain legally privileged information.  
Any unauthorised use or dissemination is prohibited.  E-mails are susceptible 
to alteration.  Neither SOCIETE GENERALE nor any of its subsidiaries or 
affiliates shall be liable for the message if altered, changed or falsified.
*************************************************************************

_______________________________________________
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