Announcement

Collapse
No announcement yet.

Need some help with shell scripts.

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need some help with shell scripts.

    I've got some scripts that run when a person logs in and out of kde and the permissions for the commands in the shell scripts require root privileges.

    I've tried setting the UID flag (the owner of the files is root), but then when i run the scripts as another user, it says permission denied for every command in the script that needs root access.

    Any help would be greatly appreciated! I need to have these scripts be able to run for other users.

    #2
    Re: Need some help with shell scripts.

    log

    in
    Place program links that you wish to run on KDE startup into ~/.kde/Autostart

    Note
    Autostart Kubuntu package
    http://www.kde-apps.org/content/show.php?content=35038

    Description:
    Autostart is a KDE control center module for configuring which applications start up when KDE inits (after a login).

    out

    KDE runs /usr/bin/startkde when it starts. And there is:
    echo 'startkde: Running shutdown scripts...' 1>&2

    # Run scripts found in $KDEDIRS/shutdown
    This link (http://lists.suse.com/archive/suse-k...-Sep/0067.html)
    says that "So basically it should work if you create a directory '~/.kde/shutdown' and place your script there"



    For permission problems

    Have you tried chmod (change file access permissions) ?



    Before you edit, BACKUP !

    Why there are dead links ?
    1. Thread: Please explain how to access old kubuntu forum posts
    2. Thread: Lost Information

    Comment


      #3
      Re: Need some help with shell scripts.

      Originally posted by Rog131
      For permission problems

      Have you tried chmod (change file access permissions) ?
      That won't help if I understood correctly...gizzmoe needs to run root commands, a script run as a user can't execute those, even if the user has the rights to execute the script.

      And the autostart scripts are run as a user.

      Originally posted by gizzmoe
      I've got some scripts that run when a person logs in and out of kde and the permissions for the commands in the shell scripts require root privileges.

      I've tried setting the UID flag (the owner of the files is root), but then when i run the scripts as another user, it says permission denied for every command in the script that needs root access.

      Any help would be greatly appreciated! I need to have these scripts be able to run for other users.
      What are you trying to accomplish...there might be alternative ways of doing what you're trying to do?

      Subsequently...Is it essential the script runs when kde starts (as opposed to running at boot...or when xserver starts)?

      I'm sure there are many ways to go about this, one could be 'sudoing the script' in autostart:

      (NOTICE: There might be better ways of doing this, I thought this up on the fly, so wait for a bit if someone comes up with a better solution...also don't do it if you don't understand what you're doing )

      1. make the script owned by root:root in a root folder (for example /usr/local/bin...a good place for locally made scripts) to avoid users being able to edit the script

      2. edit /etc/sudoers to allow passwordless sudo for the script:
      Code:
      sudo visudo
      add entry like:
      ALL  ALL=NOPASSWD: /usr/local/bin/<YOURSCRIPT>
      (Note: this allows all users to run the script without a password at any time, so make sure your script is afe and secure to use. You can also the constrict the restrictions, for example:
      allison ALL=NOPASSWD: /usr/local/bin/<YOURSCRIPT>
      (user allison can run the script without a password)
      %trusted ALL=NOPASSWD: /usr/local/bin/<YOURSCRIPT>
      (members of the 'trusted' group can run the script)
      ...read 'man sudoers' for more information

      3. Put a launcher with the command 'sudo /usr/local/bin/<YOURSCRIPT>' in ~/.kde/Autostart for all users you need to run the script with (and who you have given the right to execute the script without a password in /etc/sudoers)


      (NOTICE2: Theoretically you could just 'suid' the root owned script 'chmod 4755'...but this is very insecure if you're not very careful...and using suid, though easy, is hazardous at best:
      http://www.samag.com/documents/s=114...106a/0106a.htm


      Comment


        #4
        Re: Need some help with shell scripts.

        I set up that entry in the sodoers file and everything works fine now

        Thanks!

        Apparently suid does not work...i'm not sure if it's somehow disabled in ubuntu or if having sudo installed disables it.

        Comment

        Working...
        X