Slackware This Forum is for the discussion of Slackware Linux.
|
| 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
11-04-2004, 01:14 AM
|
#1
|
|
Member
Registered: Jul 2004
Distribution: Slackware
Posts: 310
Rep:
|
chroot help
Im reading the man page but its short and it doesnt show examples......I want to chroot jail /home/example so that my user 'example' cannot cd into other directories?
|
|
|
|
11-04-2004, 03:01 AM
|
#2
|
|
Member
Registered: Apr 2002
Posts: 549
Rep:
|
chroot <chroot_dir> <command_to_run>
eg. chroot /foo /bin/sh # run the shell in the chrooted environment
|
|
|
|
11-04-2004, 03:05 PM
|
#3
|
|
Member
Registered: Jul 2004
Distribution: Slackware
Posts: 310
Original Poster
Rep:
|
Hmm........but I would like to assign a certain user that does not have root access. Is this going to cause problems?
chroot /home/example /bin/zsh
?
|
|
|
|
11-04-2004, 03:15 PM
|
#4
|
|
Senior Member
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028
Rep:
|
The chroot command is used to make a new root folder, this means that anyone, user or command, are totally unable to reach ANYTHING outside of that directory branch. So if you would set another root for a user he wouldn't be able to do anything (if he would be able to login at all), since all commands are outside of his "root-jail".
|
|
|
|
11-04-2004, 10:26 PM
|
#5
|
|
Member
Registered: Apr 2002
Posts: 549
Rep:
|
chroot is a privileged cmd, it will only run as root.
|
|
|
|
11-05-2004, 12:12 AM
|
#6
|
|
Senior Member
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145
Rep:
|
Add this to /etc/profile (at the end) but changing the uid to the user.
Code:
if [ "`id -u`" = UID ]; then
chroot /home/example /bin/sh
fi
|
|
|
|
11-05-2004, 02:35 AM
|
#7
|
|
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140
|
This could work if you compile a static version of sh and put in in /home/example/bin
|
|
|
|
11-05-2004, 04:18 AM
|
#8
|
|
Member
Registered: Apr 2002
Posts: 549
Rep:
|
Quote:
Originally posted by Cedrik
This could work if you compile a static version of sh and put in in /home/example/bin
|
Hard-linking to so the necessary dependencies would also work.
|
|
|
|
11-05-2004, 06:58 AM
|
#9
|
|
Senior Member
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028
Rep:
|
Quote:
|
Hard-linking to so the necessary dependencies would also work.
|
Be aware that you expose yourself to the possibility of jailbreakers.
http://www.unixwiz.net/techtips/chroot-practices.html
|
|
|
|
02-23-2013, 01:18 AM
|
#10
|
|
LQ Newbie
Registered: Feb 2013
Posts: 22
Rep: 
|
chroot command is not working
hi ,
i am trying to execute chroot command but i was not successful
chroot /mnt/ubuntu dpkg -i somepackage-name
it showing following error:
chroot : command fail to run dpkg:No such file or directory.
pleaes help me on this.
regards,
prasad.
|
|
|
|
02-23-2013, 01:20 AM
|
#11
|
|
LQ Newbie
Registered: Feb 2013
Posts: 22
Rep: 
|
need chroot example
hi
i need one command which successful executes with using chroot.
|
|
|
|
02-23-2013, 02:25 AM
|
#12
|
|
Senior Member
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware-14.0 on a Lenovo T61 6457-4XG
Posts: 2,789
|
Quote:
|
Originally Posted by leader1201
i am trying to execute chroot command but i was not successful
chroot /mnt/ubuntu dpkg -i somepackage-name
|
I guess that dpkg is to be found in your Ubuntu somwhere inside /mnt/ubuntu so it's not in root's $PATH when you run that command from Slackware.
This also answers you other question: try a command which is in root's path.
PS I just saw that you asked a similar question here. I'd suggest you open your own thread to attract more attention, including all details needed for the readers to understand what you try to achieve.
To do that, just go back there and hit "New thread".
Last edited by Didier Spaier; 02-23-2013 at 02:36 AM.
|
|
|
|
02-23-2013, 04:03 AM
|
#13
|
|
Member
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,OpenBSD
Posts: 500
Rep: 
|
Quote:
Originally Posted by ugge
The chroot command is used to make a new root folder, this means that anyone, user or command, are totally unable to reach ANYTHING outside of that directory branch. So if you would set another root for a user he wouldn't be able to do anything (if he would be able to login at all), since all commands are outside of his "root-jail".
|
The jail would contain copies of selected commands and files. The plash C library tool can provide limited communication with outside.
|
|
|
|
02-23-2013, 07:38 AM
|
#14
|
|
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 2,446
|
Have you looked at starting the user shell (probably BASH) in restricted mode? Form the manual page for BASH:
Quote:
restricted_shell
The shell sets this option if it is started in restricted mode (see
RESTRICTED SHELL below). The value may not be changed. This is not
reset when the startup files are executed, allowing the startup
files to discover whether or not a shell is restricted.
If bash is started with the name rbash, or the -r option is supplied at invocation,
the shell becomes restricted. A restricted shell is used to set up an environment
more controlled than the standard shell.
|
Seems like that's what you're really trying to do (the user cannot CD anywhere). Simply change the shell for the user in /etc/passwd from /bin/bash to /bin/rbash.
Hope this helps some.
|
|
|
|
02-23-2013, 08:05 AM
|
#15
|
|
Slackware Contributor
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 4,686
Rep: 
|
C'mon guys, don't feed the zombies. This was a NINE years old thread. The person who is trying to resurrect the thread apparently needs two posts (out of his LQ total of three) to ask the same Ubuntu-related question. This is a Slackware forum thread!
Eric
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:32 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|