LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 03-23-2009, 03:40 PM   #1
sleeper0110
LQ Newbie
 
Registered: Oct 2008
Posts: 15

Rep: Reputation: 0
chroot and busybox


I've setup a chroot environment by setting up /bin, /lib and /etc/passwd in the chroot environment /tmp/chrootdir. As a root user I can run "chroot /tmp/chrootdir" and it works just fine. But, when I run it as a regular user, I get:
"chroot: can't change root directory to /tmp/chrootdir: Operation not permitted"

I'd like to be chrooted into a new environment as someone other than root.

Is this possible?

Thanks.
 
Old 03-23-2009, 04: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
chroot is intended to be run only by root. That said, allowing users to chroot is a relatively common request.

Basically, to do this, you would need to write a setuid program that did the following:
*Chrooted to the appropriate directory
*Dropped the root privileges back to their old level
*Ran the program specified, or /bin/sh if nothing is specified.

This is a perfect task for a shell script, but UNIX systems don't like setuid scripts. So, you'd probably have to write that little thing in C. Or maybe someone else has already done so, google around.
 
Old 03-23-2009, 04:15 PM   #3
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
What about letting users execute the chroot command with sudo?
 
Old 03-23-2009, 04:25 PM   #4
sleeper0110
LQ Newbie
 
Registered: Oct 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by PatrickNew View Post
chroot is intended to be run only by root. That said, allowing users to chroot is a relatively common request.
Hmmm, I was always under the assumption that a chrooted user that was still root was more insecure than a regular user in a chrooted environment. This is the only reason I'd rather be chrooted as a normal user rather than root. Is this not so? Is having a user chrooted as root secure enough?

I realize there are ways of getting around a chroot environment.

win32sux: Thanks, but I don't have sudo on this machine and would prefer not to put it on if at all possible
 
Old 03-24-2009, 03:11 AM   #5
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by sleeper0110 View Post
Hmmm, I was always under the assumption that a chrooted user that was still root was more insecure than a regular user in a chrooted environment. This is the only reason I'd rather be chrooted as a normal user rather than root. Is this not so? Is having a user chrooted as root secure enough?

I realize there are ways of getting around a chroot environment.

win32sux: Thanks, but I don't have sudo on this machine and would prefer not to put it on if at all possible
Untested, but I think it's should work.

Run chroot'ed sshd on non-standard port. (Non-standard port needed to preserve
ability ssh to this box as it was before)
Then users can ssh to this port and they should be chroot'ed
 
Old 03-24-2009, 12:19 PM   #6
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
I agree. My suggestion was to have your setuid wrapper program *drop* it's root privileges once inside the chroot. So the user calls the setuid executable, but it only stays root long enough to call chroot().
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting rid of busybox Grife DamnSmallLinux 3 05-27-2021 12:31 AM
Busybox httpd help i.you Linux - Software 1 03-10-2008 09:45 AM
chroot to run hd-installed distro's programs from chroot in live distro? silencestone Linux - Software 0 10-12-2007 06:29 AM
BusyBox doesn't go away Grife DamnSmallLinux 0 08-23-2007 02:01 AM
Busybox and vi krizzz Linux - Software 3 03-24-2005 05:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:20 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration