Results 1 to 10 of 10

Thread: shell script permission?

  1. #1
    Join Date
    Apr 2007
    Location
    South Carolina
    Beans
    779
    Distro
    Ubuntu 10.04 Lucid Lynx

    shell script permission?

    Is there any way to make a shell scripts contents unreadable to the user yet still be executeable?

    The problem I have is I have a script that runs at start-up that uses sudo & automatically enters my password at boot up. I've tried to make it unreadable but if I do it won't run. Any ideas?
    Gary

    A wise man knows what he doesn't know.

  2. #2
    Join Date
    Jun 2007
    Location
    Poughkeepsie, NY
    Beans
    5,814
    Distro
    Ubuntu

    Re: shell script permission?

    Did you know Ubuntu has a autologin feature, no scripts needed. Also why do you need sudo at start up, operating as super user all the time is mighty dangerous

  3. #3
    Join Date
    Apr 2007
    Location
    South Carolina
    Beans
    779
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: shell script permission?

    Quote Originally Posted by LowSky View Post
    Did you know Ubuntu has a autologin feature, no scripts needed. Also why do you need sudo at start up, operating as super user all the time is mighty dangerous
    I might not have explained myself completely.
    I know about auto login but what I've done is written a small shell script that gives me a warning when my next boot will be a forced file check.
    I put it in my start up sessions so every boot it checks my numbers of boots since the last check. In order to run it needs sudo & my password to call the tune2fs command. I'm not logging in as root so its just for that one command. The script works fine but I'm just trying to figure a way that no one else could open up the script & read my password.
    Gary

    A wise man knows what he doesn't know.

  4. #4
    Join Date
    Oct 2006
    Location
    Lyon, France
    Beans
    839
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: shell script permission?

    Quote Originally Posted by garyed View Post
    what I've done is written a small shell script that gives me a warning when my next boot will be a forced file check.
    I think there's something like that in the repositories already...

    Anyway, "chmod 111 somefile" makes the file executable only (non-readable, non-writable) to everyone but root.
    This is the first age that's paid much attention to the future, which is a little ironic since we may not have one.
    -- Arthur C. Clarke

  5. #5
    Join Date
    Oct 2007
    Location
    USA - Indiana
    Beans
    557
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: shell script permission?

    I'm fairly confident that chmod 111 won't work properly. I don't think you can execute something that you can't read. Let me know if I'm wrong though.

  6. #6
    Join Date
    Oct 2006
    Location
    Lyon, France
    Beans
    839
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: shell script permission?

    Good call. I had to chmod 511 it. Never noticed before, but makes sense.

    511 works and will prevent anyone but you and root from reading it anyway. So if they're reading it, your password is busted already.
    This is the first age that's paid much attention to the future, which is a little ironic since we may not have one.
    -- Arthur C. Clarke

  7. #7
    Join Date
    Apr 2007
    Location
    South Carolina
    Beans
    779
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: shell script permission?

    The problem I see is that a shell script won't run unless it has read & execute permission so if any one can run it that means they can read my password. I have my machine set to auto logon so who ever starts it up has my user priviliges. I'm not really worried about it but I was thinking there should be some way to solve this problem without changing auto logon.
    Gary

    A wise man knows what he doesn't know.

  8. #8
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: shell script permission?

    write the program in another language (like c) and then compile it. Then you have a unreadable binary.

  9. #9
    Join Date
    Apr 2007
    Location
    South Carolina
    Beans
    779
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: shell script permission?

    Quote Originally Posted by hyper_ch View Post
    write the program in another language (like c) and then compile it. Then you have a unreadable binary.
    Its funny you say that because I actually wrote the first part that uses the password in C & compiled it & then called it in the script & it works. My programming skills are really very basic.
    Gary

    A wise man knows what he doesn't know.

  10. #10
    Join Date
    Jan 2008
    Beans
    4,757

    Re: shell script permission?

    You do know that there is always the sudoers file

    type in
    Code:
    export EDITOR="gedit"
    or nano, emacs, vim, leafpad, kwrite (whatever your fancy).

    Then run:
    Code:
    sudo -E visudo
    and at the bottom of the file, insert the following
    Code:
    %name    ALL=NOPASSWD: /path/to/script
    where name is your username and /path/to/script is the full file path to the script you wish to run.
    ie:
    /home/tinivole/bin/foobar.sh

    Save and quit.


    Then have in your sessions manager:
    Code:
    sudo /path/to/script.sh
    or
    Code:
    sudo script.sh
    if the script is within one of your $PATH paths.

    Regards
    Iain
    Last edited by ibuclaw; September 22nd, 2008 at 09:44 PM.

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
  •