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.
I want all the users to be capable of chroot-ing to a folder without getting extra security risks. I need this because I have a folder structure with a program inside and I can't make the program work in the original root.
I tested the program with root by chrooting and it works fine, but I need that all the users can use this program.
My suggestion would be to make a little script in the user's path that is setuid root, which chroots them into that directory. Be very careful that the script is written correctly, else it's as dangerous as any other setuid root file.
My suggestion would be to make a little script in the user's path that is setuid root, which chroots them into that directory. Be very careful that the script is written correctly, else it's as dangerous as any other setuid root file.
At least on GNU/Linux, SUID doesn't work on scripts - only on binaries.
Really? To be honest, I'd never tried. Well, I suppose you could just setuid chroot itself, but I'd need to think about the security consequences of that before I can really recommend it.
Yeah. The commands in scripts are executed by the interpreter/shell (BASH, Perl, Python, etc), so the permissions on that will be what matters. As for the OP, I'd say perhaps one could write a small SUID program which does the chroot, then drops root privilages before executing the program? I don't know any C/C++ so I can't provide any working examples for my suggestion.
What’s wrong with something like jk_chrootsh (which comes as part of Jailkit)? Alternatively, you could create a script as PatrickNew suggested but instead of making it SUID (which won’t work on linux unless you use binfmt_misc), make an entry for it in sudoers.
You also can choose totally different approach:
use Ermine (http://magicErmine.com) or statifier (http://statifier.sf.net) to create standalone executablefrom you program in question.
Than this standalone executable can be run in the original root, eliminating the problem altogether.
You also can choose totally different approach:
use Ermine (http://magicErmine.com) or statifier (http://statifier.sf.net) to create standalone executablefrom you program in question.
Than this standalone executable can be run in the original root, eliminating the problem altogether.
While Ermine and statifier are useful, they aren't really related to the problem at hand. What the OP is looking for is a chroot substitute. 'Chroot'ing is creating a small 'jail' portion of the file system that the application cannot, in theory, escape from. In this way, you can run code you don't trust and limit your risks.
While Ermine and statifier are useful, they aren't really related to the problem at hand. What the OP is looking for is a chroot substitute. 'Chroot'ing is creating a small 'jail' portion of the file system that the application cannot, in theory, escape from. In this way, you can run code you don't trust and limit your risks.
I was (and am) under impression, that xowl words "can't make program under original root" means that program can't be run there due to it's dependencies, and not due to security consideration.
In this case Ermine/statifier are relevant.
If the reason is security, than indeed chroot based solution is way better.
@Valery Reznic: You're exactly right. You have my apologies.
@xowl: My recommendation is to pursue one of these two that Valery Reznic has referred to. They both sound like better options than chrooting for what you want to do.
@Valery Reznic: You're exactly right. You have my apologies.
@xowl: My recommendation is to pursue one of these two that Valery Reznic has referred to. They both sound like better options than chrooting for what you want to do.
[inserts foot into mouth] - it's a bit of overkill
After all may be you are right, and xowl's "can't run in original root..." is due to security consideration.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.