LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-20-2006, 10:49 AM   #1
Frelov
Member
 
Registered: Sep 2003
Location: In a cave in the himalayas
Distribution: FC4 (currently)
Posts: 36

Rep: Reputation: 15
linux SU command closing script prematurely. help please?


I'm totally new to scripting. Please help me. I've tried reading http://www.freeos.com/guides/lsst/ but I haven't found anything to specifically address commandline interface with standard commands that require password entering.

Distribution:Fedora Core 4 linux

Issue:
Since the gnome network manager/configuration wizard doesn't recognize my ndiswrapper installed wireless I tried writing a script to activate the wireless card.

IF i manually open a terminal and switch to root I can successfully execute a single script to activate. I tried adding the su to the script so I could assign it to a pointer/shortcut on the launch panel

when I run the script with the su command in it requests the root password then just exits to the command line. This is what I've written:
su
sleep 2
echo configuring wireless card
/sbin/iwconfig wlan0 essid <ESSID>
/sbin/iwconfig wlan0 mode Managed
/sbin/iwconfig wlan0 key restricted <KEY>
/sbin/dhclient wlan0
sleep 5
/sbin/ifconfig wlan0 up
sleep 2
echo wireless card configured
sleep 2
exit
exit

This didn't work so I tried a script to execute other scripts with the first switching to root. always the su terminates all the scripts.

I've tried googling several different keywords in an effort to find something related to this but have had no luck.

I've asked in the wireless networking how to get the network manager to recognize the ndiswrapper installed system but have gotten zero responses.

The reason I need this to be simple is because my computer is used by others who aren't so computer literate (even less than me) and I'd like them to be able to just click on an icon, enter the root password and everything happen automatically,

I'd actually PREFER not having to share the root password but since I can't find an answer to the wireless network gui question this is my next approach.

Would someone please help me?
Thanks so much.

Last edited by Frelov; 02-20-2006 at 10:55 AM.
 
Old 02-20-2006, 11:00 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
remove the "su" command from your script, it launches a different shell and is unrelated to the remaining of the script.
Instead, have a look at the "sudo" command.
 
Old 02-20-2006, 12:06 PM   #3
Frelov
Member
 
Registered: Sep 2003
Location: In a cave in the himalayas
Distribution: FC4 (currently)
Posts: 36

Original Poster
Rep: Reputation: 15
Thanks,

After reading up on sudo and sudoers I added

%users ALL=(ALL) ALL

to the sudoers file

and prefaced each command with sudo. I tried a single command since the man file states it gives 5 minutes of privileges unless manually changed in sudoers but I had to put it in front of each one.

It works now but does not require a password, not even the user password. I thought that the above line in sudoers would not allow bypassing the password. Does this open my system to vulnerabilities? Thanks.
 
Old 02-20-2006, 01:01 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by Frelov
It works now but does not require a password, not even the user password.
Allowed users have already given their password to log in.

Quote:
I thought that the above line in sudoers would not allow bypassing the password. Does this open my system to vulnerabilities?
Less than having root's password stored on file !
 
Old 02-20-2006, 01:14 PM   #5
Frelov
Member
 
Registered: Sep 2003
Location: In a cave in the himalayas
Distribution: FC4 (currently)
Posts: 36

Original Poster
Rep: Reputation: 15
Ok, thanks. I appreciate the guidance and help. This certainly makes it much easier than having to teach people how to go to the command line and switch to root and run a script.

Thanks a ton.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command for closing ports psyklops Linux - General 1 03-26-2010 06:44 AM
How to get linux distribution with command bash or script gigix Linux - Distributions 5 04-28-2005 06:17 AM
qmail prematurely closes connection when trying to telnet... ivj Linux - Software 0 07-25-2004 04:47 AM
Closing a port in linux terminal..any command?? fhameed Linux - Security 1 07-20-2004 11:46 PM
while loop ending prematurely in a bash script meat-head Programming 7 05-08-2004 01:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration