UNIX for Beginners Questions & Answers

If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Why does a fakechroot exist?


👤 Login to reply

    #1  
Old 1 Week Ago
sreyan32 sreyan32 is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 11 July 2018, 11:56 AM EDT
Posts: 57
Thanks: 25
Thanked 0 Times in 0 Posts
Why does a fakechroot exist?

I am really confused as to why a tool like fakechroot exists and what does it do.

Chroot is an ability only for root users, correct? Then a tool that allows to bypass that is clearly a security flaw, correct?

When and why would you need something like this?

Is there any relation between fakechroot and fakeroot?
Sponsored Links
    #2  
Old 1 Week Ago
hicksd8 hicksd8 is offline Forum Staff  
Moderator
 
Join Date: Feb 2012
Last Activity: 21 July 2018, 4:54 AM EDT
Location: Devon, UK
Posts: 1,924
Thanks: 291
Thanked 514 Times in 433 Posts
Such tools are to allow an (ordinary) user to create a root environment within their little bubble WITHOUT affecting anyone else on the system. It all happens within their individual user space. They do NOT get any enhanced privileges.

As I say, within their little bubble only.

For example, they could install a software package within their own 'fake root' and the install routine would be lead to believe that it was installing on the main system but it's not.
Sponsored Links
    #3  
Old 1 Week Ago
sreyan32 sreyan32 is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 11 July 2018, 11:56 AM EDT
Posts: 57
Thanks: 25
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by hicksd8 View Post
Such tools are to allow an (ordinary) user to create a root environment within their little bubble WITHOUT affecting anyone else on the system. It all happens within their individual user space. They do NOT get any enhanced privileges.

As I say, within their little bubble only.

For example, they could install a software package within their own 'fake root' and the install routine would be lead to believe that it was installing on the main system but it's not.

Okay, I have a couple of doubts about the whole thing.

Let me start by asking you why chroot is only permitted for root users?

What harm would there be if a normal user were to perform a chroot?
    #4  
Old 1 Week Ago
hicksd8 hicksd8 is offline Forum Staff  
Moderator
 
Join Date: Feb 2012
Last Activity: 21 July 2018, 4:54 AM EDT
Location: Devon, UK
Posts: 1,924
Thanks: 291
Thanked 514 Times in 433 Posts
To put it plainly, chroot is a real change root and not a fake change root and so it affects the whole system, i.e. all users. Therefore, it takes root privilege to action. The whole system is switched to running on a different root directory. Therefore, a standard user cannot be allowed to do this.

A fake chroot is playing around within a users own environment and nobody else sees any change.

An example of a real chroot can be when a system doesn't boot properly so the sysadmin boots the system from DVD into single user mode. Having booted that way, the system root is the root of the DVD. Now the sysadmin can use chroot to switch to the normal hard disk root to see how the system behaves; stable or wobbly?

Fake change root is exactly what is says; fake!

Last edited by hicksd8; 1 Week Ago at 03:53 AM..
The Following User Says Thank You to hicksd8 For This Useful Post:
Neo (1 Week Ago)
Sponsored Links
    #5  
Old 1 Week Ago
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 21 July 2018, 2:56 AM EDT
Location: Aachen, Germany
Posts: 13,081
Thanks: 452
Thanked 4,017 Times in 3,693 Posts
Don't mix up the root user and the file system's root.
Sponsored Links
    #6  
Old 1 Week Ago
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 21 July 2018, 4:00 AM EDT
Location: San Jose, CA, USA
Posts: 11,411
Thanks: 651
Thanked 3,971 Times in 3,394 Posts
I'm confused by a lot of the discussion in this thread. The chroot utility does not in any way, shape, or form change the system's root directory.

The chroot utility (and the underlying chroot() system call) starts a new process with the root directory for that process (and any descendants of that process) set to the directory specified on the command line in that chroot utility invocation.

The root directory of any processes that were running before chroot was invoked (and any descendants of those processes) continue to run with their original root directory.

From what I see in the manual pages, it appears that fakechroot is only available on Debian Linux systems. It also seems that fakechroot does not actually change the root directory of the process it starts, but the library used by the linker that fakechroot uses to link the process it starts fakes the behavior used to run the process as though it had been chrooted in some cases while ignoring chroot behavior in other cases.

I believe the chroot utility and system call are available on all recent UNIX, Linux, and BSD systems.
The Following 2 Users Say Thank You to Don Cragun For This Useful Post:
hicksd8 (1 Week Ago), Neo (1 Week Ago)
Sponsored Links
    #7  
Old 1 Week Ago
hicksd8 hicksd8 is offline Forum Staff  
Moderator
 
Join Date: Feb 2012
Last Activity: 21 July 2018, 4:54 AM EDT
Location: Devon, UK
Posts: 1,924
Thanks: 291
Thanked 514 Times in 433 Posts
Yes, I believe that is true but also consider the scenario where a Solaris Global Zone boots a non-global zone and then sets (ie, changes) that non-global zones root directory with chroot. The parent (kernel) process of that non-global is now set to a different root directory and that affects all future users logging into that zone.

Therefore my understanding was that if the root user changed the root directory of the global zone kernel (PID 1) that would affect future users that log in??

Interesting discussion this!
Sponsored Links
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Does ${%name} exist in csh? kristinu UNIX for Dummies Questions & Answers 2 01-10-2012 07:45 AM
if pid exist ? pelle Shell Programming and Scripting 4 08-17-2010 02:53 AM
su: user x does not exist user23 UNIX for Dummies Questions & Answers 3 10-23-2007 06:34 PM
does it exist in linux? pbonilla UNIX for Dummies Questions & Answers 1 08-03-2003 01:37 AM



All times are GMT -4. The time now is 07:35 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?