Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Perl Command Line Arguments

by celtic_coffee (Initiate)
on Jun 11, 2002 at 15:17 UTC ( [id://173511]=perlquestion: print w/replies, xml ) Need Help??

celtic_coffee has asked for the wisdom of the Perl Monks concerning the following question:

Hello all, Here is my delima, I have a perl program running using the Expect module and everything is fine. I have a C++ program that passes arguments to it. Everything works fine, but I don't want people who run ps -aux to see the arguments passed to perl from the wrapper program. The information contains passwords and new user information. Is there a way in hide the arguments being passed in with some kewl perl mastery. I thought about encryption, but since it is plain text that is not really viable. THanks, Greg javacodewarrior@yahoo.com

Replies are listed 'Best First'.
Re: Perl Command Line Arguments
by Abigail-II (Bishop) on Jun 11, 2002 at 16:13 UTC
    Just use a pipe. Command line arguments and environment variables can be read. Of course, people who have the same EUID as under which the process runs may still be able to get to the password.

    Abigail

Re: Perl Command Line Arguments
by Joost (Canon) on Jun 11, 2002 at 15:24 UTC
    Read the 'secret' arguments from STDIN. - This is not Real Good Security (tm) though.

    update: You can try toying with setting $0 - this might work on some systems. - see perldoc perlvar

    -- Joost downtime n. The period during which a system is error-free and immune from user input.
(ichi) Re: Perl Command Line Arguments
by ichimunki (Priest) on Jun 11, 2002 at 15:42 UTC
    You could store the information in a file rather than passing it on the command line. It should be trivial to keep prying eyes out of private files. Just make sure that the Perl script deletes the file as soon as it gets the information it needs.
Re: Perl Command Line Arguments
by DamnDirtyApe (Curate) on Jun 11, 2002 at 16:58 UTC
    $PROGRAM_NAME $0 Contains the name of the program being executed. On some operating systems assigning to "$0" modi­ fies the argument area that the ps program sees. This is more useful as a way of indicating the current program state than it is for hiding the program you're running. (Mnemonic: same as sh and ksh.) Note for BSD users: setting "$0" does not com­ pletely remove "perl" from the ps(1) output. For example, setting "$0" to ""foobar"" will result in ""perl: foobar (perl)"". This is an operating system feature.
    This worked for me.
    # test3.pl $0 = "bar" ; while ( 1 ) { 1 } ;
    ps -aux see this as bar, even when I run it as test3.pl foo.
    _______________
    D a m n D i r t y A p e
    Home Node | Email
Re: Perl Command Line Arguments
by rah (Monk) on Jun 12, 2002 at 01:21 UTC
    Have you thought about encrypting/decrypting the password information? That way the "visible" args wouldn't be much use to anyone that didn't know you encryption scheme. It would be fairly simple to add this to the perl script (I'm fond of Crypt::Blowfish and use it to store login and passwords for an ftp script). Don't know about adding this capability to your C++ program.
      I thank all of you for your help. I may see about using Gtk::perl for the GUI instead that way I don't have to pass arguments. It should be interesting to learn the tool set. THanks, Greg

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://173511]
Approved by ichimunki
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-12-08 03:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (50 votes). Check out past polls.