LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-04-2004, 01:14 AM   #1
Smokey
Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 313

Rep: Reputation: 30
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?
 
Old 11-04-2004, 03:01 AM   #2
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
chroot <chroot_dir> <command_to_run>


eg. chroot /foo /bin/sh # run the shell in the chrooted environment
 
Old 11-04-2004, 03:05 PM   #3
Smokey
Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 313

Original Poster
Rep: Reputation: 30
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

?
 
Old 11-04-2004, 03:15 PM   #4
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
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".
 
Old 11-04-2004, 10:26 PM   #5
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
chroot is a privileged cmd, it will only run as root.
 
Old 11-05-2004, 12:12 AM   #6
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
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
 
Old 11-05-2004, 02:35 AM   #7
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
This could work if you compile a static version of sh and put in in /home/example/bin
 
Old 11-05-2004, 04:18 AM   #8
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
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.
 
Old 11-05-2004, 06:58 AM   #9
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
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
 
Old 02-23-2013, 01:18 AM   #10
leader1201
LQ Newbie
 
Registered: Feb 2013
Posts: 22

Rep: Reputation: Disabled
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.
 
Old 02-23-2013, 01:20 AM   #11
leader1201
LQ Newbie
 
Registered: Feb 2013
Posts: 22

Rep: Reputation: Disabled
need chroot example

hi

i need one command which successful executes with using chroot.
 
Old 02-23-2013, 02:25 AM   #12
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,058

Rep: Reputation: Disabled
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.
 
Old 02-23-2013, 04:03 AM   #13
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by ugge View Post
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.
 
Old 02-23-2013, 07:38 AM   #14
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
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.
 
Old 02-23-2013, 08:05 AM   #15
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
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
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo /usr/bin/chroot /home/chroot /bin/su - xxx| /bin/su: user xxx does not exist saavik Linux - General 3 07-04-2007 10:30 AM
CHROOT help quozt Linux - Networking 1 08-22-2003 02:12 PM
chRoot SpaceCadet Linux - Networking 3 08-14-2003 05:29 AM
Chroot chamkila Linux - General 1 06-13-2003 05:46 AM
Better than chroot? radnix Linux - Security 5 12-20-2002 06:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:16 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