Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
I am trying to suid a small script which mounts a series of images.
I know that i can use sudo for that but the problem is that I dont want my brother to have access to the mount command at all.
I read about suid, and I thought i did it correctly:
the command I issued was "chmod 6755 mountemall.sh".
When i try to run the script as a normal user, it tells me that only root can run mount (of course) but I thought that it would run as root and simply not make an error for mount.
Am I understanding suid correctly? and if so, did I do it correctly?
Given the circumstances, you could add your user as a sudoer with rights to run /bin/mount. (Be sure to use the fully-qualified path in both the sudoers file and in your script.)
See the manpages for sudoers(5) for examples. Also, use visudo(8) to edit it.
as i said I did NOT want to allow mount in sudo, because my brother would mount other things that i dont want him to... Thats why i was looking for suid... I will try to allow my script in sudo.
--
EDIT
what i did is that i allowed my script in the sudo file instead of the mount command so he can mount only the images that i allow him to mount.
Derr, I misread. Yes, you can allow the FQ path to your script in sudoers. Alternatively: I haven't tested this, but you could likely put something together using e.g. python or php. Both have access to system commands on unix-like OSes. Then AFAIK that could be made suid.
@RaptorX; you only give your user sudo access to mount etc. You don't give it to other users, inc your brother. That's the whole point.
ie you define both the user and the cmd that's allowed.
Don't be confused by idiots who give
Derr, I misread. Yes, you can allow the FQ path to your script in sudoers. Alternatively: I haven't tested this, but you could likely put something together using e.g. python or php. Both have access to system commands on unix-like OSes. Then AFAIK that could be made suid.
Actually thats pretty neat, I will do that... in the mean time i have it setup with the script.
Quote:
Originally Posted by chrism01
@RaptorX; you only give your user sudo access to mount etc. You don't give it to other users, inc your brother. That's the whole point.
ie you define both the user and the cmd that's allowed.
Don't be confused by idiots who give
sudo su -
rights away.
yes I totally agree with you there... I only allow specific commands in sudoers, nothing more... but the thing was that I wanted to allow brother123 to mount some specific images and nothing else, I thought of allowing each mount command by separate but the time I would have to spend on that was not worth it...
I already had a little script with the list of commands he could use to mount the images so I just added THAT script to sudoers. Now he can mount only what the script says he can mount and as the file is owned by root he cannot modify it at all. I win.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.