LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   chroot like program for non-root users (https://www.linuxquestions.org/questions/linux-security-4/chroot-like-program-for-non-root-users-600722/)

xowl 11-18-2007 09:19 PM

chroot like program for non-root users
 
Hi

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.

Any suggestion?

Thanx in advance

PatrickNew 11-18-2007 10:02 PM

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.

win32sux 11-18-2007 10:51 PM

Quote:

Originally Posted by PatrickNew (Post 2963633)
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.

PatrickNew 11-18-2007 11:10 PM

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.

win32sux 11-19-2007 03:27 AM

Quote:

Originally Posted by PatrickNew (Post 2963672)
Really? To be honest, I'd never tried.

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.

Valery Reznic 11-19-2007 04:31 AM

You can allow user to do chroot via sudo.


Valery.

osor 11-19-2007 11:21 AM

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.

saulgoode 12-06-2007 11:49 AM

Perhaps plash might be suitable for this application?

Valery Reznic 12-07-2007 02:13 AM

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.

PatrickNew 12-07-2007 02:27 AM

Quote:

Originally Posted by Valery Reznic (Post 2982930)
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.

Valery Reznic 12-08-2007 11:27 AM

Quote:

Originally Posted by PatrickNew (Post 2982944)
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.

PatrickNew 12-08-2007 12:46 PM

[inserts foot into mouth]

@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 12-10-2007 06:02 AM

Quote:

Originally Posted by PatrickNew (Post 2984171)
[inserts foot into mouth]

@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.

Valery


All times are GMT -5. The time now is 06:56 PM.