Results 1 to 10 of 15

Thread: Bash sudo and zenity --password

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Location
    Sweden
    Beans
    307
    Distro
    Ubuntu 14.04 Trusty Tahr

    Bash sudo and zenity --password

    Writing an installation-script for Minecraft, been trying to get the user to input password, check password and on wrong password as if the user would like to try again or abort. Finally came up with what seems a working solution (for adding a entry to the application-menu), but now I wonder if this unsafe in any way? Is there a better solution?


    Code:
      while ! zenity --password| sudo -S cat /dev/null >/dev/null; do
        if $(zenity --question --text="Wrong password, would you like to cancel the installation?"); then
          echo "no app-entry made, returning"
          return;
        fi
      done
        echo "$appEntry" | sudo -S tee ${launcher}
        sudo -K # remove privilege
    where appEntry is the text, launcher is the file.

    I might add that I would like to use zenity, not gksu or similar.

    Thanks
    Last edited by DarkAmbient; September 4th, 2012 at 02:09 PM.
    This is my signature

  2. #2

    Re: Bash sudo and zenity --password

    What logically happens when the user-run install script gets to:
    Code:
    sudo -S cat /dev/null >/dev/null; do
    ?
    Windows assumes the user is an idiot.
    Linux demands proof.

  3. #3
    Join Date
    Aug 2008
    Location
    Sweden
    Beans
    307
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Bash sudo and zenity --password

    Ok, the way I've understood things.. correct me if I'm wrong, I'm still kinda new to bash.

    The -S parameter with sudo tells sudo to read password from the stdin. And cat /dev/null > /dev/null really doesent do anything other than acting as a dummy to use with sudo, or atleast thats my guess. Found it like that one some site

    I guess using
    Code:
    while ! zenity --password | sudo -S echo ''; do
    (or something similar) does just about the same, or is there any difference?
    This is my signature

  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Bash sudo and zenity --password

    Use gksu or pkexec. It is NOT your job (as the writer of the script) to decide how many times the user is allowed to re-type the password.

  5. #5
    Join Date
    Aug 2008
    Location
    Sweden
    Beans
    307
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Bash sudo and zenity --password

    Quote Originally Posted by sisco311 View Post
    Use gksu or pkexec. It is NOT your job (as the writer of the script) to decide how many times the user is allowed to re-type the password.
    Point taken, I'll use gksu instead. gksu comes with Ubuntu as default right?
    This is my signature

  6. #6

    Re: Bash sudo and zenity --password

    Quote Originally Posted by DarkAmbient View Post
    ...correct me if I'm wrong, I'm still kinda new to bash.
    No, but I'll give you props for reading the man file.

    Quote Originally Posted by DarkAmbient View Post
    The -S parameter with sudo tells sudo to read password from the stdin...
    You missed it...the script assumes the user has sudo privs...
    Did you intend that?

    unless Wed Sep 05, 2012 - 6:40:03 AM EDT is too early to be reading forum posts?

    I'd have to defer to whatever sisco311 says, he's a master.

    Subscribed with interest,
    Windows assumes the user is an idiot.
    Linux demands proof.

  7. #7
    Join Date
    Aug 2008
    Location
    Sweden
    Beans
    307
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Bash sudo and zenity --password

    haha thank you

    Hm, I'm not following, what I've read about /dev/null is that it's a "special-file" that empties output thrown at it.

    Knowing that, I really didn't think that anything special would happen with "cat /dev/null > /dev/null", do you mean we assume the user has sudo-privileges because of that part, or because of the "sudo -S"?

    Soo slow after a 9h-workday, sorry... ><
    This is my signature

  8. #8

    Re: Bash sudo and zenity --password

    Well. I am going to back away from the keyboard on this one and let you resume your quest uninterrupted by me.

    Have a Great Day!
    Windows assumes the user is an idiot.
    Linux demands proof.

Tags for this Thread

Bookmarks

Posting Permissions

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