jails Exit from root in Ubuntu Jail.

Hi All,
I have managed to install Ubuntu Jail in FreeBSD 13.1. However when I log into it, I am always at root. Is there a way that I could log in as a user please. I don't want to mess the system up. Just want to sudo the important tasks.
Thanks & Best Regards
Schroter Michael
 
This doesn't 'log in' actually. You're just starting a bash shell in a chroot(8). Has nothing to do with jails either.
Hi, I used this setup :https://wiki.freebsd.org/LinuxJails. So you are saying that this has nothing to do with jails? Please have look at root directories of FreeBSD and Ubuntu Linux installed on the same machine.
Thanks & Best Regards.
Schroter
 

Attachments

  • Screenshot_2022-08-25_00-40-26.png
    Screenshot_2022-08-25_00-40-26.png
    97.8 KB · Views: 128
So you are saying that this has nothing to do with jails?
It has nothing to do with jails. Do you see a jail.conf or the jail(8) command anywhere?

Please have look at root directories of FreeBSD and Ubuntu Linux installed on the same machine.
Just because the directories are on the same system doesn't mean it's a jail. The Linux compatibility layer isn't a jail.

A jail(8) and a chroot(8) are two entirely different things. A chroot(8) only puts boundaries on a filesystem, while a jail(8) process runs in an entirely different namespace on the kernel.
 
It has nothing to do with jails. Do you see a jail.conf or the jail(8) command anywhere?


Just because the directories are on the same system doesn't mean it's a jail. The Linux compatibility layer isn't a jail.

A jail(8) and a chroot(8) are two entirely different things. A chroot(8) only puts boundaries on a filesystem, while a jail(8) process runs in an entirely different namespace on the kernel.
Hi, Please find the following details below.

/compat/ubuntu/home/jails/newJail/usr/src/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_jail/jail.conf`
/usr/src/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_jail/jail.conf
find: /usr/home/jails/newJail/etc/ntp: Permission denied
/usr/home/jails/newJail/usr/src/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_jail/jail.conf

I am using 'apt' to install Linux packages. The tutorial is about how to create jails. In Linux compatibility layer I believe, only 'pkg' could be used to install packages that need Linux bindings. So could you please let me know how to change from root to a user after I chroot please. Do I need to create a new user in Ubuntu or could I use FreeBSD user as well. please? Please refer image below as well for your kind perusal. In the image 'schroter' is the FreeBSD user.

Thanks & Best Regards
Schroter Michael
 

Attachments

  • Screenshot_2022-08-25_13-44-31.png
    Screenshot_2022-08-25_13-44-31.png
    34.2 KB · Views: 114
A couple of suggestions.
Firstly, don't use screen shots. Put the text. Sceenshots are harder to look at, and most people won't bother. Use code blocks.
Code:
something
. It looks like this

You do that by typing (without spaces) a [, then the word code, and ]. To end the block you do [ /code ], again without the spaces.
Or click the three dots on the forum format menu, and click the inline code choice, which will create the code /code stuff.
Secondly, you haven't answered SirDice's questions. Do you have an /etc/jail.conf? If not, you probably don't have a jail. Does the command jls show anything? For example, on my system.
Code:
 jls
   JID  IP Address      Hostname                      Path
     1  192.168.2.5     webjail                       /jails/webjail
It's possible you erred at some point when trying to build the jail. If you do have a jail, that jls command will tell you its number. You can then do
with sudo, doas or as root
Code:
jexec 1 /bin/sh
If that works, you have a jail. If it doesn't, you don't have a jail.

If it does work, then, once in the jail
you should be able to add a user with Ubuntu commands, (I haven't run a Linux jail, so that's untested by me, but it works in a FreeBSD jail, adding a user with the pwd commmand.)

But, before anything, run the jls command so we can see if you have a jail. And don't use an image to show the result, copy the result and paste it in. Otherwise, I as I said, lots of people who might have helped just won't bother.
 
jexec 1 /bin/sh
With a 'real' jail I would recommend something like jexec 1 /usr/bin/login -f root or when you want to login as a user jexec 1 /usr/bin/login -f <username> (that user has to exist within that jail). You could use jexec 1 /bin/sh but you're not actually logging in that way, you are starting a shell in the namespace of that jail.


I think part of Schroter 's confusion is the wording in the wiki article.
This page describes the steps required to configure Ubuntu-based Linux jail or chroot

But the article only shows how to set up an Ubuntu based Linux environment, similar to what emulators/linux_base-c7 does with CentOS7. While you could use those instruction to create an actual Ubuntu jail(8), how you should do that isn't explained in the article.

Also note that the instructions don't describe how to manage the jail; take a look at this article for instructions on how to manage your Ubuntu jail using iocage, or this one for Bastille.
 
With a 'real' jail I would recommend something like jexec 1 /usr/bin/login -f root or when you want to login as a user jexec 1 /usr/bin/login -f <username> (that user has to exist within that jail). You could use jexec 1 /bin/sh but you're not actually logging in that way, you are starting a shell in the namespace of that jail.


I think part of Schroter 's confusion is the wording in the wiki article.


But the article only shows how to set up an Ubuntu based Linux environment, similar to what emulators/linux_base-c7 does with CentOS7. While you could use those instruction to create an actual Ubuntu jail(8), how you should do that isn't explained in the article.
Thanks for the reply. At this point I am unable to launch firefox within the chroot environment. it gives me the below results. Please let me know. I was able to log into user by creating a new user within the chroot subsystem. I was trying to log into the FreeBSD user previously. I tried that bacuse FreeBSD user was visible within the chroot subsystem home directory.

Code:
(newEnv) schroter1@SCHROTER:~$ firefox
No protocol specified
Unable to init server: Broadway display type not supported: unix:0.0
Error: cannot open display: unix:0.0

This is after I had installed firefox within the chroot subsystem. Would it be possible for the subsystem to access freeBSD's firefox please?

Thanks & Best Regards
Schroter Michael
 
Back
Top