Re: How to connect as different user using dbaccess ?
Posted in 2005
Topics: Server Administration, Security, Permissions & Auditing
Alexey Sonkin wrote:
> The problem is that is a very bad idea to pass the password in a
> command line. Any user who has access to that machine is able to
> get this password by simply issuing 'ps -ef'
With all of that, I agree. The feature is there - I don't
particularly recommend its use. The code in SQLCMD does attempt to
zap the password argument - empirically, this has no effect on
Solaris, and probably not on other platforms either.
The original question was asking to provide the password in the
connect statement - SQLCMD does support that (and permits you to write
PASSWORD instead of USING, and also to abbreviate WITH CONCURRENT
TRANSACTIONS to WCT).
CONNECT TO 'dbase' AS 'myconn' USER 'me' PASSWORD 'mine' WCT;
CONNECT TO 'dbase' AS 'yourconn' USER 'you' USING 'yours'
WITH CONCURRENT TRANSACTIONS;
> I don't have any complete solution for that.
>
> In some cases, the following approach works very well for me:
>
> 1. Connect to the database as a user with 'dba' privilege;
> 2. Issue 'SET SESSION AUTHORIZATION TO "any_other_user"'
>
> This approach works very well for me, when I want to connect to
> somebody's ANSI-mode database without knowing the user's password
> as 'informix' and access his objects without specifying object
> ownership in SQL statements
Ouch!
Yes, it works. It isn't a good general solution - it means everyone
has informix (or, at least, DBA) privileges...
>>On Behalf Of Art S. Kagel
>>
>>smitin@gmail.com wrote:
>>
>>
>>Do:
>> > connect to dbname user 'user';
>>
>> DBAccess will prompt for a passwd. DBAccess will not accesp the
>> USING clause. However, you cannot do this using a 'here script'
>> because the password prompt goes directly to the tty NOT to
>> stdin. Your best bet would be to use Jonathan Leffler's sqlcmd
>> utility instead:
>>
>>sqlcmd -d mydatabase -u username -p password <<!
>>SELECT.....
>>!
>>
>>Sqlcmd is available for download from the IIUG Software Repository.
>>> pretty stupid question but I can't find an answer yet : how to
>>> provide user name and password if I want to use dbaccess ?
>>>So far I tried dbaccess - - <<!
>>>connect to dbname user 'user' using 'passwd';
>>>!
>>>
>>>32412: USING clause unsupported. DB-Access will prompt you for a
>>>password.
>>>Error in line 1>>>Near character position 34
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
"Jonathan Leffler" <jleffler@earthlink.net> wrote > Alexey Sonkin wrote: > > The problem is that is a very bad idea to pass the password in a > > command line. Any user who has access to that machine is able to > > get this password by simply issuing 'ps -ef' > > With all of that, I agree. The feature is there - I don't > particularly recommend its use. The code in SQLCMD does attempt to > zap the password argument - empirically, this has no effect on > Solaris, and probably not on other platforms either. Jonathan, I remember going thru this with you when I was developing infotable, the tool which prints out the schema of a database in a very readable format. I rejected accepting user name and password as a command line option for the same reason mentioned above. I finally setteled for the following option: (a) set an environment variable INFOTPASS to point out to a file. (b) that file contains connect information in the format dbname|user name|password (c) set unix permission 600 to that file for security. infotable will read from this file before connecting. IMO it is quite secured as long as the password file's permission is not set incorrectly. Perhaps you can implement same approach for sqlcmd.