Find the answer to your Linux question:
Results 1 to 5 of 5
root password is a parameter of the script and the script can switch current user to root without pwd input prompt. how can i do?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2005
    Posts
    1

    How To Switch To Root By Script?


    root password is a parameter of the script and the script can switch current user to root without pwd input prompt.

    how can i do?

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    I'm not at my Linux computer currently, but you might try:
    Code:
    su << $root_pwd
    That is, redirect STDIN for the su command to the $root_pwd variable.

    I can't guarantee that this will work, though.

  3. #3
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    You should never pass the root password (or any password) as a command line parameter. The command line parameters of all processes can be read from /proc by any user, so if pass your root password as a command line parameter, any other local user on the system can read it by just running something like `ps axw'. Not to mention the fact that anyone can read the password from the console you're typing it from.

    I'd really, really recommend that you do whatever it is you want to do some other way.

  4. #4
    Linux User zacam87's Avatar
    Join Date
    Dec 2004
    Location
    Viriginia
    Posts
    284
    whats so hard about su then a password? lol... yea im with dolda on this one... i dont think ANY script that logs it self in as root is a good idea... what would the purpose of this script be anyway? becuase inorder for it to work... wouldent oyu need to execute the script... so instead ogf typing su password your typing ./whereever/evrreever/everever ... seems like an odd thing to me but what ever you like to do man hehe {;^)
    I can imagine a perfect world, a world without hate, a world without war. Then I can imagine us attacking that world because they\'d never expect it.

  5. #5
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Quote Originally Posted by Dolda2000
    You should never pass the root password (or any password) as a command line parameter. The command line parameters of all processes can be read from /proc by any user, so if pass your root password as a command line parameter, any other local user on the system can read it by just running something like `ps axw'. Not to mention the fact that anyone can read the password from the console you're typing it from.

    I'd really, really recommend that you do whatever it is you want to do some other way.
    I was under the impression that many programs that take passwords will take their input directly from /dev/stdin or something similar to that to avoid the whole redirection thing, so it wouldn't work anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •