This is sort of a continuation from bug#60722. Eshell gets the user's UID/GID in a few places, e.g. to decide when to prompt before deleting a file with "rm" (if you're root, it should prompt). However, these aren't connection-aware. That means that if you start Emacs as a normal user and then run "cd /sudo::", it doesn't recognize that you're now root, so it doesn't prompt. Similarly, Eshell's "ls" implementation doesn't check for the connection-aware UID/username for ownership. And likewise for the "U" and "G" Eshell predicate operators. Attached is a patch to fix this, which also adds a new utility function 'file-group-gid'. Similar to 'file-user-uid' (added in bug#60722), it's just a connection-aware version of 'group-gid'.