LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
LinkBack Search this Thread
Old 11-18-2007, 09:19 PM   #1
xowl
Member
 
Registered: Jan 2005
Distribution: Slackware current (and others)
Posts: 188

Rep: Reputation: 30
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
 
Old 11-18-2007, 10:02 PM   #2
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
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.
 
Old 11-18-2007, 10:51 PM   #3
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
Originally Posted by PatrickNew View Post
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.
 
Old 11-18-2007, 11:10 PM   #4
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
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.
 
Old 11-19-2007, 03:27 AM   #5
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
Originally Posted by PatrickNew View Post
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.
 
Old 11-19-2007, 04:31 AM   #6
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 663

Rep: Reputation: 132Reputation: 132
You can allow user to do chroot via sudo.


Valery.
 
Old 11-19-2007, 11:21 AM   #7
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 69
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.
 
Old 12-06-2007, 11:49 AM   #8
saulgoode
Member
 
Registered: May 2007
Distribution: Slackware
Posts: 205

Rep: Reputation: 63
Perhaps plash might be suitable for this application?
 
Old 12-07-2007, 02:13 AM   #9
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 663

Rep: Reputation: 132Reputation: 132
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.
 
Old 12-07-2007, 02:27 AM   #10
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
Quote:
Originally Posted by Valery Reznic View Post
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.
 
Old 12-08-2007, 11:27 AM   #11
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 663

Rep: Reputation: 132Reputation: 132
Quote:
Originally Posted by PatrickNew View Post
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.
 
Old 12-08-2007, 12:46 PM   #12
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
[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.
 
Old 12-10-2007, 06:02 AM   #13
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 663

Rep: Reputation: 132Reputation: 132
Quote:
Originally Posted by PatrickNew View Post
[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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vsftpd chroot for users bfay Linux - Software 0 07-21-2006 09:13 AM
open office appears in the root and not the users program file list reycapoy Linux - Software 5 02-24-2006 06:06 AM
Process or program to regain root control from chroot() hack? flailer Linux - General 2 09-09-2003 03:42 AM
Process or program to regain root control from chroot() hack? flailer Linux - Security 0 09-07-2003 04:47 PM
Chroot users thecrab Linux - Security 6 03-03-2002 05:21 PM


All times are GMT -5. The time now is 08:21 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration