Author Topic: Error when enable jailkit to a user  (Read 4883 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Error when enable jailkit to a user
« on: June 15, 2021, 06:20:07 AM »
I tried to use jailkit for a user in CWP.
It create directory /home/jail/[user]/home/[user]
But after waiting for minutes, the page at CWP admin said: Error enabling jailkit.
I then switch to SFTP, and no problem.
But the problem is that I cant remove /home/jail/[user]
If I removed it, it automatically remove /home/[user] too. It looks like /home/[user] is symlinked to /home/jail[user]
If I remooved file inside /home/jail/[user], it removed the file inside /home/[user] too.

I tried to remove that symlink. But  I cant find it.
Even, I have uninstall jailkit, but still unable to remove /home/jail/ and the symlink still run.

How to fix it? where is the symlink configuration store?
Thanks.
we are web developer in Indonesia with address: Tatamedia Solusindo | web hosting with mutiple choices | discounted software store

Offline
*
Re: Error when enable jailkit to a user
« Reply #1 on: June 15, 2021, 08:28:33 AM »
I saw when selecting Jailkit In shell access at CWP Admin, there is a file careated name:
/run/systemd/generator/home-jail-[user_cwp]-home-[user_cwp].mount
It looks like mount the hard disk, so I checked at /etc/fstab, and I found this line
/home/[user_cwp] /home/jail/[user_cwp]/home/[user_cwp] none bind,nobootwait 0 0

It causes the /home/[user_cwp] has symlink to /home/jail/
So, how can I unmount this since I have disabled jailkit, because it was error when trying to use it.

Thanks.
we are web developer in Indonesia with address: Tatamedia Solusindo | web hosting with mutiple choices | discounted software store

Offline
*
Re: Error when enable jailkit to a user
« Reply #2 on: June 18, 2021, 05:01:12 AM »
After reviewing for days, I can figure out to fix the symlink of /home/[user] to /home/jail/[user]/home/[user] in cse jailkit failed to be enabled for a user.

Everytime we enable jailkit for a user, it will add a new line in
Code: [Select]
/etc/fstab/the new line is like this
Code: [Select]
/home/[user_cwp] /home/jail/[user_cwp]/home/[user_cwp] none bind,nobootwait 0 0
And it also automatically create file
Code: [Select]
/run/systemd/generator/home-jail-[user_cwp]-home-[user_cwp].mount
/run/systemd/generator/local-fs.target.requires/home-jail-[user_cwp]-home-[user_cwp].mount that symlink to /run/systemd/generator/home-jail-[user_cwp]-home-[user_cwp].mount

It causes we cant remove /home/jail/user when we do not use jailkit anymore. And everytime we reboot the server, the /home/jail/user will be created automatically.

So, to fix this issue, just follow this step
Code: [Select]
rm -rf /run/systemd/generator/home-jail-[user_cwp]-home-[user_cwp].mount
rm /run/systemd/generator/local-fs.target.requires/home-jail-[user_cwp]-home-[user_cwp].mount to remove the symlink
vi /etc/fstab
add comment (#) before /home/[user_cwp] /home/jail/[user_cwp]/home/[user_cwp] none bind,nobootwait 0 0 or delete that line
reboot server

Now /hom/jail/[user] will not exist anymore.
Remember, it just in case jailkit error when enabling for a user. You do not need to do this if jailkit is enabled successfully. It it enabled successfully, it will remove the line at /etc/fstab/ and /home/jail/[used] when you disable jailkit for that user.

Hope it helps.

we are web developer in Indonesia with address: Tatamedia Solusindo | web hosting with mutiple choices | discounted software store

Offline
*
Re: Error when enable jailkit to a user
« Reply #3 on: July 18, 2023, 10:17:47 PM »
Thanks a lot. really help me to solved this.