Re: storing password in variable

From: foo (foo_at_bar.baz)
Date: 06/07/04


Date: Mon, 07 Jun 2004 00:04:13 -0700

Atom 'Smasher' wrote:

> using a script to encrypt (using openssl) some files to removable media,
> i'm prompted for a password (twice) each time openssl is invoked.
>
> i'm wondering if it's "safe" for the script to ask me for a password,
> store the password in a variable, and use it each time openssl is invoked
> throughout the script. (i can have the script not echo the password as i'm
> typing it, and ask for it to be typed twice)
>

If someone has read access to '/dev/mem', they can see your password in
plain-text; so this approach isn't advisable.

> in the environment where this is being used, my concern (and curiosity) is
> if the variable (containing the password) might be saved to disk cache
> while the shell script is running.

This can happen if your OS implements virtual memory (e.g., the page that
holds your password is paged-out to disk) or full-fledged process swapping.
I know Linux implements both.

Once again, if someone has read access to the swap partition or page-file,
they can see your password in plain-text.

>
> so i'm wondering how "safe" it is to do that, what else should i be
> concerned with, and how much of this is shell and OS dependant.
>

This is mostly OS dependent, unless of course you store your password in a
global environment variable using 'export' or 'declare -x' in BASH.

> thanks...



Relevant Pages

  • Re: compare values in the same field in consecutive rows--and store the result in an array
    ... this script to store more values, including some from line 102 in the ... of readers and awk users as it concerns data extraction and processing ... three questions on the modification of the latest script ... If you don't want n to increase twice, ...
    (comp.lang.awk)
  • Re: compare values in the same field in consecutive rows--and store the result in an array
    ... this script to store more values, including some from line 102 in the ... Your script works--in part, ... but obviously this ex[pression doesn't work as intended (the for loop ... If you don't want n to increase twice, ...
    (comp.lang.awk)
  • storing password in variable
    ... using a script to encrypt some files to removable media, ... prompted for a password (twice) each time openssl is invoked. ... while the shell script is running. ...
    (comp.unix.shell)
  • Re: OnClick Handler
    ... definately something wrong with storing the same thing twice if you have no good to do so. ... to store the same thing twice. ... Again with the tautology. ... your inflated sense of the importance of the reasons you've stated causes you to describe them as "fairly significant". ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: your number of trips to the supermkt per month?
    ... over to the grocery store for most of the other stuff. ... a time and go back once or twice during the week. ... don't have much of their fridge taken up with junk food either. ... Some things specifically like whole melons and cabbages. ...
    (rec.food.cooking)