###############################################################################
# OpenVAS Vulnerability Test
# $Id: secpod_ibm_lotus_notes_detect_lin.nasl 4611 2009-09-11 10:10:29Z sep $
#
# IBM Lotus Notes Version Detection (Linux)
#
# Authors:
# Antu Sanadi <santu@secpod.com>
#
# Copyright:
# Copyright (c) 2009 SecPod, http://www.secpod.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# (or any later version), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
###############################################################################

if(description)
{
  script_id(901016);
  script_version("$Revision: 1.0 $");
  script_tag(name:"risk_factor", value:"None");
  script_name("IBM Lotus Notes Version Detection (Linux)");
  desc = "
  Overview: This script detects the installed version of IBM Lotus Notes and
  sets the result in KB item.

  Risk factor: None";

  script_description(desc);
  script_summary("Set Version of IBM Lotus Notes in KB");
  script_category(ACT_GATHER_INFO);
  script_copyright("Copyright (C) 2009 SecPod");
  script_family("Service detection");
  exit(0);
}


include("ssh_func.inc");
include("version_func.inc");

# Get the Socket Connection
sock = ssh_login_or_reuse_connection();
if(!sock)
{
  exit(0);
}

# Find the 'nsd.sh' Paths
paths = find_file(file_name:"nsd.sh",file_path:"/notes/", useregex:TRUE,
                  regexpar:"$", sock:sock);

foreach binName (paths)
{
  lotusVer = get_bin_version(full_prog_name:"cat", version_argv:chomp(binName),
                             ver_pattern:'SCR_VERSION="([0-9.]+)', sock:sock);

  # Set KB for Lotus Notes
  if(lotusVer[1] != NULL){
    set_kb_item(name:"IBM/LotusNotes/Linux/Ver", value:lotusVer[1]);
    security_note(data:"IBM Lotus Notes version " + lotusVer[1] +
             " running at location " + binName + " was detected on the host");
  }
}
ssh_close_connection();
