Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
while IFS=":" read name script
do
su
exit
...
<snip>
done < /path/to/file
Where I redirect the file into the loop, for some reason, I can't do an su when I redirect a file like that. I get the error, "su: must be run from a terminal." Why is this? How can I fix it? Thanks.
Last edited by x24804; 07-18-2010 at 04:50 PM.
Reason: Add some text
Hey, for anyone else with this problem, I think this happens because su thinks that it's going to get it's input non-interactively from the file. su doesn't allow that. Anyone have any solutions to this? Thanks.
If su allowed the password to be read from a re-directed [b]stdin[/] a simple shell script could be written to automate a cracking attempt by non-privileged users on your system. (Admittedly, this is more of a concern if your system had many different users, but UNIX was originally designed to run on a "large" main-frame computer with many (hundreds) users accessing it.)
If you really want your script run with "root" access, just run it as "root" instead of having the script change context in mid-stream.
Note that the same consideration means that sudo will also decline to accept input from a redirected stdin.
If you click the "Report" button at the end of your post and ask the moderators to move this thread to the "security" forum, you should get several additional answers from persons more expert than I am in these matters.
I didn't realize that su was taking the file that I defined as input. I only expected the read command to deal with the file, not su. I wanted it to prompt for the password like it normally does when there's no file redirect.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.