jails "Adduser: UID 0 is already used" Error while I'm trying to install and configure teamviewer inside a Freebsd / Devuan jail.

Hello.​


I've configured a Devuan Linux jail on FreeBSD,following this tutorial :

https://forums.freebsd.org/threads/setting-up-a-debian-linux-jail-on-freebsd.68434/

it seems that everything is working properly,except for the fact that I don't know how to start a graphical desktop manager. My ultimate goal is to install and configure teamviewer inside the jail. Anyway,according with this tutorial :

https://zotovp.wordpress.com/2016/08/24/install-teamviewer-in-x86-chroot-on-x64-host-debian-jessie/

it seems that I can run correctly teamviewer inside a chroot. And maybe even inside a jail,since they are almost the same. Ok,I'm frozen at some point,precisely here where he says :

Создание пользователя с таким же uid, как и у username в хостовой системе. Посмотреть uidпользователя можно командой id username.

that translated from russian to english language sounds like this :

Create a user with the same uid as username on the host system. You can view the user uid with the id username command.

Code:
root@[chrooted_x86]# adduser --disabled-password --uid <id_rom> --gid <gid_rom> username

that in my scenario,it is something like this :
on the guest :

Code:
root@devuan:~# id
uid=0(root) gid=0(root) gruppi=0(root),5(tty)

on the host :

Code:
root@marietto:/usr/home/marietto # id
uid=0(root) gid=0(wheel) groups=0(wheel),5(operator)
so,I tried :

Code:
root@devuan:~# adduser --disabled-password --uid 0 --gid 0 mario

unfortunately I get this error that I don't know how to fix :

adduser: UID 0 is already used.

or maybe it is something like this ?

Code:
root@devuan:~# adduser --disabled-password --uid 0 --gid 0 0

adduser: Enter a username that matches the configured regular expression via the NAME_REGEX variable. To avoid this check, use the "--force-badname" option or reconfigure NAME_REGEX.

what do u suggest me to do ? I don't understand what he wants to achieve,how does it should work the trick ?. Please help me.
 
This is a Linux question, isn't it?

Anyway, UID 0 is reserved for root, you can't add another user with that id.

 
if you plan to run teamviewer as root you probably don't need do add a user
i suspect the user is need just because teamviewer wants to resolve your username from your uid
just like you have a passwd file for anon ftp chroot
 
This is a Linux question, isn't it?

Anyway, UID 0 is reserved for root, you can't add another user with that id.


I don't agree with you totally. I look more at the global question,not too much if it is offtopic or not. The global question is not merely : it talks about linux,so its off topic. For me it sounds like : how is the question useful for everyone ? I mean,I suppose there are a lot of people here that use FreeBSD and Linux together and they want that both the oses shares a lot of different resources using its own proper tools. Teamviewer is widely used on Linux,there could be the needing to run it on Linux and on FreeBSD. This can be done using two bhyve linux virtual machines. But why ? if it can run inside a lighter jail,we will not waste the resources.
 
if you plan to run teamviewer as root you probably don't need do add a user
i suspect the user is need just because teamviewer wants to resolve your username from your uid
just like you have a passwd file for anon ftp chroot

so,what u suggest to do,instead of doing what suggested by the author ?
 
I don't agree with you totally.
This is good! It would be boring if we all had the same opinion.

look more at the global question,not too much if it is offtopic or not.
I don't care if you post offtopic questions, that's why i answer them. But maybe the moderators think differently.

The global question is not merely : it talks about linux,so its off topic. For me it sounds like : how is the question useful for everyone ?
You want to add a user in Linux. This is offtopic for sure.

if it can run inside a lighter jail,we will not waste the resources.
If you don't want to waste resources, use a dedicated Linux installation via dual-boot.
 
If you don't want to waste resources, use a dedicated Linux installation via dual-boot.

which kind of reply is this ? it seems that u like drastic solutions,but more a solution is drastic more it is full of bad sides. In my opinion,compromise is the key,everytime.
 
if you run teamviewer as root do nothing
if not add your regular user to linux passwd/shadow. i dont know why the same uid as on host probably the original example has a shared $home somehow
 
I'm freezed again,here :

Add timelines before exit 0 in the host system file /etc/rc.local

This is how we mount the devices of the main system into the chroot system at boot. You can, of course, think about security here and mount only those devices that are required by TeamViewer, but I did not want to do this.

Code:
mount /dev /chroot/x86/dev -o bind
mount /proc /chroot/x86/proc -o bind
mount /tmp/.ICE-unix /chroot/x86/tmp/.ICE-unix -o bind
mount /tmp/.X11-unix /chroot/x86/tmp/.X11-unix -o bind

that,in my case it should be :

Code:
root@marietto:/opt/jails/devuan/tmp # mount /dev /opt/jails/devuan/dev -o bind

usage: mount [-adflpruvw] [-F fstab] [-o options] [-t ufs | external_type]
mount [-dfpruvw] special | node
mount [-dfpruvw] [-o options] [-t ufs | external_type] special node

or

root@marietto:/opt/jails/devuan/tmp # mount /dev /opt/jails/devuan/dev
 
mount: /dev: Block device required
 
I've skipped the instructions below :

Code:
mount /dev /chroot/x86/dev -o bind
mount /proc /chroot/x86/proc -o bind
mount /tmp/.ICE-unix /chroot/x86/tmp/.ICE-unix -o bind
mount /tmp/.X11-unix /chroot/x86/tmp/.X11-unix -o bind

and I've tried to launch teamviewer directly :

Code:
root@[devuan](~)13 ./teamviewer      

root@[devuan](~)14
Init...
xprop:  unable to open display ':0.0'
CheckCPU: SSE2 support: yes
Checking setup...
Launching TeamViewer ...
Launching TeamViewer GUI ...

freezed....
 
you can run X on host and run x protocol over tcp between jail and host

sounds good. can u explain better how to implement this ? I'm not so expert that I know what to do reading such a short sentence. Thanks very much.
 
haven't run X in ages but you have to make x listen on tcp first
once you see it listening in netstat
in jail export DISPLAY=hostip:0
on host firewall port 6000 from outside if you are directly connected to the net or allow connections only from jails ip to host 6000
open a xterminal on host and type xhost +
go to the jail term whrere you exported display and run teamviewer
test first with a linux xclock/eyes/term and if it works continue testing with teamviewer
 
This is what I did :

1) opened port 6000 on IP 192.168.1.6 (it's the host IP). The jail IP is 192.168.1.7,but I can't open the port 6000 on this IP because it is not in the list of the available IP numbers on my router admin page.

2) inside the jail :

Code:
root@[devuan](~) socat -d -d TCP-LISTEN:6000,fork,bind=localhost UNIX-CONNECT:/tmp/.X11-unix/X0

3) on the host :

Code:
root@marietto:/usr/home/marietto # ssh -Y root@192.168.1.7
root@192.168.1.7's password:

root@[devuan](~) xlogo -display localhost:0
Error: Can't open display: localhost:0

4) and again,inside the jail :

Code:
root@[devuan](~) 2021/11/25 22:40:36 socat[9151] N accepting connection from AF=2 192.168.1.7:64063 on AF=2 192.168.1.7:6000

2021/11/25 22:40:36 socat[9151] N forked off child process 14581
2021/11/25 22:40:36 socat[9151] N listening on AF=2 192.168.1.7:6000
2021/11/25 22:40:36 socat[14581] N opening connection to AF=1 "/tmp/.X11-unix/X0"
2021/11/25 22:40:36 socat[14581] E connect(5, AF=1 "/tmp/.X11-unix/X0", 19): No such file or directory
2021/11/25 22:40:36 socat[14581] N exit(1)
2021/11/25 22:40:36 socat[9151] N childdied(): handling signal 17

I have the folder /tmp/.X11-unix inside the jail,but I haven't the socket X0,but it is on the host system,on the same folder.
 
you need the socat thing on the host (when X is running)
and the on jail export DISPLAY=192.168.1.6:0
xclock
if it errors out with no authorization run xhost + from a xterm on host
also bind socat to 0.0.0.0 or 192.168.1.6
 
ok. on the host (freebsd) :

Code:
root@marietto:/tmp/.X11-unix # socat -d -d TCP-LISTEN:6000,fork,bind=192.168.1.6 UNIX-CONNECT:/tmp/.X11-unix/X0

2021/11/25 23:22:45 socat[14951] N listening on LEN=16 AF=2 192.168.1.6:6000

on the jail :

Code:
root@[devuan](~)221 xclock

Error: Can't open display: :0
 
instead,with 0.0.0.0 :

on the host :

Code:
root@marietto:/tmp/.X11-unix # socat -d -d TCP-LISTEN:6000,fork,bind=0.0.0.0 UNIX-CONNECT:/tmp/.X11-unix/
X0
2021/11/25 23:27:16 socat[14988] N listening on LEN=16 AF=2 0.0.0.0:6000
2021/11/25 23:27:20 socat[14988] N accepting connection from LEN=16 AF=2 192.168.1.7:64974 on LEN=16 AF=2
192.168.1.7:6000
2021/11/25 23:27:20 socat[14988] N forked off child process 14990
2021/11/25 23:27:20 socat[14988] N listening on LEN=16 AF=2 0.0.0.0:6000
2021/11/25 23:27:20 socat[14990] N opening connection to LEN=19 AF=1 "/tmp/.X11-unix/X0"
2021/11/25 23:27:20 socat[14990] N successfully connected from local address LEN=16 AF=1 ""
2021/11/25 23:27:20 socat[14990] N starting data transfer loop with FDs [6,6] and [5,5]
2021/11/25 23:27:20 socat[14990] N socket 2 (fd 5) is at EOF
2021/11/25 23:27:20 socat[14990] N socket 1 (fd 6) is at EOF
2021/11/25 23:27:20 socat[14990] N exiting with status 0
2021/11/25 23:27:20 socat[14988] N childdied(): handling signal 20

on the guest :

Code:
root@[devuan](~)223 xclock
No protocol specified
Error: Can't open display: :0
 
Screenshot_20211125_233027.png
 
Code:
root@marietto:/usr/home/marietto # jexec devuan /bin/bash

root@[devuan](/)1 export DISPLAY=192.168.1.6:0
root@[devuan](/)2 echo $DISPLAY
192.168.1.6:0


root@[devuan](/)3 xclock
No protocol specified
Error: Can't open display: 192.168.1.6:0
 
Back
Top