 | Senior Member with 307 posts. | | Join Date: Aug 2003 Experience: Advanced | | Running a script only under a certain user I'm running Koppix 3.4 (2.4.x kernel) on my laptop. Is there a way to have a script run only under a certain user? I'm trying to have a simple script execute the command: "pump -i ath0" only under a certain user. How would I go about doing this; if possible?
__________________ When you give everything and the feeling is gone
All the giving is fake, did you fake enough?
When there's nothing left, did you take enough? | | Senior Member with 1,246 posts. | | Join Date: Sep 2003 Experience: Linux~su | | the simpilist would be to change the permissions of the file to 700. That will make it so only the owner will be able to run it, others can't even read the file.
#chmod 700 (file)
edit: at least this should work, not sure about it working with the root account...not being able to run it though. It probably still can since root is just that powerful.
__________________ Gentoo Developer, and 64bit os user
"In feeding Mother Nature, you are fed in return" - Tsunam (2005). Concerning water conservation, and raising water tables. | | Senior Member with 307 posts. | | Join Date: Aug 2003 Experience: Advanced | | Thanks for the info. Now, two more questions: how would I go about making a script run for every user except for one? Also, where should I put the script to have it run? | | Distinguished Member with 14,983 posts. | | Join Date: Apr 2003 Location: 1265 Lombardi Ave Experience: IIAHYAYCESA,YAADA! | | Create a group with the users you want to run the script.
Create a folder and chown the folder with that group name. Put the script in their.
Now I am not sure if you can run the script based on what group they are in. You could try adding some checks in /etc/profile to see what group they are in and then run the script if they are. Otherwise you could just edit each users .bash_profile if that is what shell you are using. | | Senior Member with 307 posts. | | Join Date: Aug 2003 Experience: Advanced | | Ok, I'll try that later, thanks a lot! | | Senior Member with 1,410 posts. | | | | You might also consider using the id command in your script to identify the user attempting to run the script, and then either allow or deny execution. For example: Code: USERID=`id -ru`
if [ "$USERID" -eq 501 ] # allow only user with ID 501 to run script
then
echo allowed to run script
else
echo cannot run script
fi
if [ "$USERID" -ne 501 ] # allow any user other than 501
then
echo allowed to run script
else
echo cannot run script
fi
This has the advantage that you can change it easily (without creating/modifying groups and file permissions) and will also detect attempts to run the script with an effective ID that is different from the real ID.
Hope this helps.
__________________ The slowest component still sits at the keyboard. | | Distinguished Member with 14,983 posts. | | Join Date: Apr 2003 Location: 1265 Lombardi Ave Experience: IIAHYAYCESA,YAADA! | | Another lesson learned from CodeJockey! Thanks. | | Senior Member with 1,410 posts. | | | | Aw, shucks ... Subject line says it all. Glad I could contribute -- and for the record, I've gotten plenty of good advice/info from lots of folks here, including LwdSquashman (  ) | | Senior Member with 1,246 posts. | | Join Date: Sep 2003 Experience: Linux~su | | have to admit codejockey has helped me out with coding stuff more then he knows.
I think my next project will be to create a screenshot program that uses a secure ftp/encrypted something.
Since the one I made now has the pass and user just in the script....course someone would have to steal my laptop and know my logins to find it but still...
__________________ Gentoo Developer, and 64bit os user
"In feeding Mother Nature, you are fed in return" - Tsunam (2005). Concerning water conservation, and raising water tables. |  THIS THREAD HAS EXPIRED.
Are you having the same problem?
We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.
|
Smart Search
| Find your solution! | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |  WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
| You Are Using: |
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 10:24 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd. | |
|