#-----------------------------------------------------------------------------
#
# Check /var/X11/xdm/Xsession and /var/X11/xdm/Xsession.dt if we're running 5.2
# Check /usr/lib/X11/xdm/Xsession if we're running 4.0.5
# we're looking for a "xhost +" line that isn't commented out (this is the default)
#

$file  = '/var/X11/xdm/Xsession';
$file2 = '/var/X11/xdm/Xsession.dt';
&pcheck('System Xsession files');
open(TMP, $file);
while ($_ = <TMP>) {
  chop;
  if (/\s*#/) { next; };
  if ((/\s*\/usr\/bin\/X11\/xhost \+$/) || (/\s*xhost \+$/)) {
    $xhost = 1;
    &report("DANGER: $file vulnerability\n",
      "  To fix: Edit line $. of $file and\n",
      "          change \"$&\" to something else (or comment it out)\n\n");
    }
  }
close(TMP);
open(TMP, $file2);
while ($_ = <TMP>) {
  if (/\s*#/) { next; };
  if ((/\s*\/usr\/bin\/X11\/xhost \+$/) || (/\s*xhost \+$/)) {
    $xhost = 1;
    &report("DANGER: $file2 vulnerability\n",
      "  To fix: Edit line $. of $file2 and\n",
      "          change \"$&\" to something else (or comment it out)\n\n");
    }
  }
close(TMP);
if ($xhost) { &failed; }
else {
  &report("INFO:  You do not have an 'xhost +' line in your\n",
          "       system's Xsession files\n");
  &passed;
  }

exit 0;

