Open huschu opened 8 years ago
First htop maintains it's own username<->UID hashmap.
When simple jail name/JID started working, I was just happy that it works. As htop core provides username/UID mapper internally, it meshed nicely together on it's own.
But it turned out, if jail has custom users, UIDs will show only numerically, as you observe.
This is caused by a fact, that htop username/uid mapping is completely unaware of in-jail users.
Unfortunately "solution" is not so simple.
Problem with jails is, that they are really isolated from the rest of the system, and that you would need to either:
Even reuse of this functionality could be problematic. Solaris and SmartOS have Zones support, which should be similar to jails, but I don't know if you can "inject" probes into them from "host". Linux has much lower level, separate UID namespace "sub-component", for building up containers, and whether process probe design would mesh with that design even is questionable. I personally have no clue how Linux containers really work, but from what I read, they are very complex compared to jails and others. Maybe it' easy there though.
As you see this "simple" thing turns out not so simple to do correctly. Because of complexity, if I remember correctly, even native FreeBSD top doesn't show in-jail user names either.
Maybe somebody more experienced or hishamhm would be able to abstract all this machinery needed?
However with this two more interesting things surface:
Thus easiest solution, if you want to see usernames and which works right now, is administrative one. Just keep your UIDs and usernames synced between host and "jails", and make sure all jails have same UID:username pairs between them as well and you will get correct output.
On FreeBSD htop 2.0.1 shows the username of a jailed process apparently by looking up the id in the host system. Since htop knows in which jail the process is running (which is awesome, thanks!), could it somehow look up the correct username?