mviereck / x11docker

Run GUI applications and desktops in docker and podman containers. Focus on security.
MIT License
5.5k stars 370 forks source link

Consider checking for and using system getent before using custom getent #496

Closed BuildingAtom closed 1 year ago

BuildingAtom commented 1 year ago

Hi, I was testing this script in a shared server setting where we use freeipa for logins and encountered the error:

x11docker ERROR: Could not find user '...' in /etc/passwd.

Since we use freeipa, our users aren't stored in the /etc/passwd file. The system getent command is capable of working with this, but the custom getent command used isn't. I realize this was implemented to address #477 where getent wasn't implemented for some systems/shells.

I think some way of testing for and using the system getent first would suffice. I haven't tested thoroughly, but I made the following quick change below to get it working for me.

mygetent() {
  command -v getent >/dev/null 2>&1 && getent $1 $2 || \
  grep "^${2:-NOENTRY}:" < "/etc/${1:-NOFILESPECIFIED}"
}
mviereck commented 1 year ago

Thank you very much! You suggested code is implemented in the latest master version.