#!/usr/bin/env bash{l_pkgoutput=""ifcommand-vdpkg-query>/dev/null2>&1;thenl_pq="dpkg-query -W"elifcommand-vrpm>/dev/null2>&1;thenl_pq="rpm -q"fil_pcl="gdm gdm3"# Space seporated list of packages to checkforl_pnin$l_pcl;do$l_pq"$l_pn">/dev/null2>&1&&l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n - checking configuration"doneif[-n"$l_pkgoutput"];thenoutput=""output2=""l_gdmfile="$(grep-Pril'^\h*disable-user-list\h*=\h*true\b'/etc/dconf/db)"if[-n"$l_gdmfile"];thenoutput="$output\n - The \"disable-user-list\" option is enabled in \"$l_gdmfile\""l_gdmprofile="$(awk-F\/'{split($(NF-1),a,".");print a[1]}'<<<"$l_gdmfile")"ifgrep-Pq"^\h*system-db:$l_gdmprofile"/etc/dconf/profile/"$l_gdmprofile";thenoutput="$output\n - The \"$l_gdmprofile\" exists"elseoutput2="$output2\n - The \"$l_gdmprofile\" doesn't exist"fiif[-f"/etc/dconf/db/$l_gdmprofile"];thenoutput="$output\n - The \"$l_gdmprofile\" profile exists in the dconf database"elseoutput2="$output2\n - The \"$l_gdmprofile\" profile doesn't exist in the dconf database"fielseoutput2="$output2\n - The \"disable-user-list\" option is not enabled"fiif[-z"$output2"];thenecho-e"$l_pkgoutput\n- Audit result:\n *** PASS: ***\n$output\n"elseecho-e"$l_pkgoutput\n- Audit Result:\n *** FAIL: ***\n$output2\n"[-n"$output"]&&echo-e"$output\n"fielseecho-e"\n\n - GNOME Desktop Manager isn't installed\n - Recommendation is Not Applicable\n- Audit result:\n *** PASS ***\n"fi}
#!/usr/bin/env bash{l_gdmprofile="gdm"if[!-f"/etc/dconf/profile/$l_gdmprofile"];thenecho"Creating profile \"$l_gdmprofile\""echo-e"user-db:user\nsystem-db:$l_gdmprofile\nfiledb:/usr/share/$l_gdmprofile/greeter-dconf-defaults">/etc/dconf/profile/$l_gdmprofilefiif[!-d"/etc/dconf/db/$l_gdmprofile.d/"];thenecho"Creating dconf database directory \"/etc/dconf/db/$l_gdmprofile.d/\""mkdir/etc/dconf/db/$l_gdmprofile.d/
fiif!grep-Piq'^\h*disable-user-list\h*=\h*true\b'/etc/dconf/db/$l_gdmprofile.d/*;thenecho"creating gdm keyfile for machine-wide settings"if!grep-Piq--'^\h*\[org\/gnome\/login-screen\]'/etc/dconf/db/$l_gdmprofile.d/*;thenecho-e"\n[org/gnome/login-screen]\n# Do not show the user list\ndisable-user-list=true">>/etc/dconf/db/$l_gdmprofile.d/00-loginscreen
elsesed-ri'/^\s*\[org\/gnome\/login-screen\]/ a\# Do not show the user list\ndisable-user-list=true'$(grep-Pil--'^\h*\[org\/gnome\/loginscreen\]'/etc/dconf/db/$l_gdmprofile.d/*)fifidconfupdate
}
Note: When the user profile is created or changed, the user will need to log out and log in again before the changes will be applied.
OR
Run the following command to remove the GNOME package: