Havin_it Posted May 9, 2004 Report Share Posted May 9, 2004 (edited) Well, I guess the title says it all. I need to use shell commands to start my modem, so I'm thinking of writing a script to automate the three commands this involves. It's my first attempt at such a thing in Linux. So when I have it written, and sitting on my desktop, is there a way I can configure it so that it just runs when I double-click it? Also, the commands are privileged, so can the script also perform 'su' automatically by some command that includes the root password? Or is there a safer, permission-based way of setting-up the script so that this is possible? Any ideas or pointers would be ... well, great, ya know. Edit: moved from Software by spinynorman Edited February 27, 2005 by Havin_it Quote Link to comment Share on other sites More sharing options...
phunni Posted May 9, 2004 Report Share Posted May 9, 2004 If you right click on it, you should get some options - one of which I seem to remember is something like - run in a terminal. This might make it easier to run with a double click. As far as running commands as root - take a look at sudo. This allows you to specify commands that can be run as root, by a normal user (if that makes sense) without the need for a password - making it easier to run those scripts from a script Quote Link to comment Share on other sites More sharing options...
VeeDubb Posted May 9, 2004 Report Share Posted May 9, 2004 phuni is right about sudo, but getting it to run by double clicking is easy, All you need to do, is open up a console, navigate to the directory where the shel script is, and enter chmod -x nameofscript.sh If that doesn't work, tryit again as root. I KNOW that will work. Quote Link to comment Share on other sites More sharing options...
iphitus Posted May 10, 2004 Report Share Posted May 10, 2004 no, its chmod +x nameofscript.sh :) Quote Link to comment Share on other sites More sharing options...
Gowator Posted May 10, 2004 Report Share Posted May 10, 2004 its worth remembering WHY this is a bad idea .... Quote Link to comment Share on other sites More sharing options...
Havin_it Posted May 10, 2004 Author Report Share Posted May 10, 2004 Thanks guys. Just been checking out sudo (or more specifically visudo) and it's driving me frickin' nuts already. I think the syntax for the powers i want should be havinit ALL=NOPASSWD: (root) ALL But apparently not! So I guess this is now a plea for some sudoers knowledge. The manpages are not really great on this subject! I'm currently doing these edits in Kwrite because I couldn't make head or tail of visudo's control syntax. (I need the NOPASSWD bit so I can hopefully use these commands in a script) Quote Link to comment Share on other sites More sharing options...
Qchem Posted May 10, 2004 Report Share Posted May 10, 2004 (edited) Please don't try and allow your mortal to run any command as root - it's a BAD idea!! All the information you need should be in man sudoers, something like: havinit localhost = NOPASSWD: /first/command, /second/command should do it Edited May 10, 2004 by Qchem Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted May 11, 2004 Report Share Posted May 11, 2004 I could be totally wrong, because I'm no security person, but wouldn't it be better to just make the actual script setuid root, so that the actual script runs as root, but give his user permission to run it? Like this chown root:root /path/to/script chmod +s /path/to/script chmod 0755 /path/to/script Please correct me if I'm wrong. I remember reading a post about allowing normal users the ability to start the internet connection by doing something similar to pppd and/or /dev/modem. Quote Link to comment Share on other sites More sharing options...
Gowator Posted May 11, 2004 Report Share Posted May 11, 2004 Thats what I was saying steve.... you just explained it better :D There is a reason for most things in linux and circumventing them is deliberatly difficult to stop people doing it without reading the consequences. Quote Link to comment Share on other sites More sharing options...
Qchem Posted May 11, 2004 Report Share Posted May 11, 2004 You're right Steve, I always forget to KISS :P Quote Link to comment Share on other sites More sharing options...
Havin_it Posted May 12, 2004 Author Report Share Posted May 12, 2004 Thanks guys - yes, I see the point about not making myself able to SUDO everything with no password, so I'm reverting to the chmod method. The wierd thing is it doesn't seem to work as I'd hoped. In the scope of (having done the chmods on the programs in question) trying to run the commands as myself, what's now happening is the commands appear to return without error but are not actually succeeding - probably why the non-sudo script I wrote doesn't seem to succeed. The commands are: /usr/sbin/modem_run -m -f /usr/share/speedtouch/mgmt.o /usr/sbin/pppd call adsl sbin/ifconfig I'm still able to run these as root (and without the paths), but as myself, the ifconfig returns only eth0 and lo, not ppp0 as intended. modem_run appears to work, as the modem's LEDs cycle in the normal way, so I'm assuming pppd is the problem. Do I need to chmod the peer file for adsl as well? As it's basically a config file I didn't think it would need to be executable. Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted May 12, 2004 Report Share Posted May 12, 2004 Hang on. I think that old topic is still around here. (I hope it is not on the old board.) I'll look for it and get back to ya. Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted May 12, 2004 Report Share Posted May 12, 2004 (edited) chmod +s /usr/sbin/modem_run chmod +s /usr/sbin/pppd chmod 0755 /etc/ppp/peers/adsl The last one may possibly work with 0744 You will still probably have to use the whole path for each in your script, because /sbin is not in your normal user's path (for good reason) and I don't think /usr/sbin is either. With all of this, I don't think you'll need to make the owner of your script root nor will you have to chmod +s your script. Edited May 12, 2004 by Steve Scrimpshire Quote Link to comment Share on other sites More sharing options...
Havin_it Posted May 12, 2004 Author Report Share Posted May 12, 2004 Thanks, I will try chmodding adsl as well. BTW, is the 'in your path' thing really such a hacker-beater? If my user was possessed by evil (well, not by me anyway), wouldn't it just take a few educated guesses on system topology to locate the path and use it if permitted? Just a thought - forgive me if I'm missing something obvious, us noobs usually do! Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted May 12, 2004 Report Share Posted May 12, 2004 Well, 'in your path' is not meant to be a 'hacker-beater'. It's meant to protect you from yourself. (e.g. You would have to consciously think about hat exactly you were doing when you have to type the whole path.) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.