Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding command line args from ps listing

Status
Not open for further replies.

Clairvoyant1332

Programmer
May 21, 2003
147
US
I have some programs that can take a password as a command line argument. Probelm is, if you pass the password that way you can see it in a ps listing. Not very secure.

How do you go about altering cleaning up these arg so ps doesn't see them? I know that the crypt command does this, but I haven't been able to figure out what it's doing.

The OS is Solaris.

Thanks,
Dennis
 
Once you've read the arguments, then you can do this

Code:
memset( argv[i], 0, strlen(argv[i]) );
Where 'i' is the position of the argument you want to erase.

--
 
>Once you've read the arguments, then you can do this

Code:
memset( argv[i], 0, strlen(argv[i]) );

>Where 'i' is the position of the argument you want to erase.

No good. The arguments still show up in ps.
 
Its probably a daft way of doing it, but if I want to control the "PID description", I create a programme which forks the real programme you want using execl() - which you can set the descripion that shows up in "ps".

But I'm fairly new to C, and I'm sure there is a better way ...

--------------------------------------------------
Free Database Connection Pooling Software
 
> Its probably a daft way of doing it, but if I want to control the "PID description", I create a programme which forks the real programme you want using execl() - which you can set the descripion that shows up in "ps".

That will change arg0, but not any of the other args.


If you run the Unix crypt command like so:

Code:
crypt my_password

It wait for input from stdin. Then, from another terminal if you run "ps -ef" command, you'll see this:

Code:
crypt -k

This is what I'm looking to do.
 
The typical Unix solutions to this problem are to store passwords in a file and allow an option to read them from there (e.g. [tt].netrc[/tt] for ftp, wget, and similar utilities), or to allow an "interactive mode" that prompts the user for the password.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top