#!/usr/bin/env perl
#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-

# Functions for getting service descriptions.
#
# Copyright (C) 2002 Ximian, Inc.
#
# Authors: Carlos Garnacho Parro <garnacho@tuxerver.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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 Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

# This function extracts known names and descriptions from the description hash
sub gst_service_list_get_info
{
	my ($service) = @_;
	my (%service_description_list);
	my $desc;

	# This is the hash that describes all the known services
	%service_description_list = 
	(
    # please, keep this list sorted
		# service => [long_name, description]
    "acpid"             =>  [ _("ACPI event handler"), _("Notifies user-space programs of ACPI events: executes arbitrary commands in response to ACPI events such as power buttons.") ],
    "alsa"              =>  [ _("Advanced Linux Sound Architecture"), _("Advanced Linux Sound Architecture") ],
    "apache"            =>	[ _("web server"),  _("Apache is a World Wide Web server.  It is used to serve HTML files and CGI.") ],
    "anacron"           =>      [ _("Run missed scheduled jobs at startup"), _("Run cron jobs that were left out due to downtime") ],
    "apmd"              =>      [ _("Automatic power management daemon"), _("apmd is used for monitoring battery status and logging it via syslog(8). It can also be used for shutting down the machine when the battery is low.") ],
    "atd"               =>      [ _("Runs a command at a given time"), _("Runs commands scheduled by the at command at the time specified when at was run, and runs batch commands when the load average is low enough.") ],
    "aumix"             =>  [ _("Audio mixer"), _("This program adjusts the settings of an audio mixing device") ],
    "binfmt-support"    =>      [ _("BinFormat Support"), _("Support for running non ELF binaries on Linux") ],
    "bootlogd"          =>  [ _("Boot messages recorder"), _("Runs in the background and copies all strings sent to the /dev/console device to a logfile") ],
    "chargen"           =>      [ "", _("An xinetd internal service which generate characters. The xinetd internal service which continuously generates characters until the connection is dropped.  This is the tcp version. You must enable xinetd to use this service.") ],
    "chargen-udp"       =>      [ "", _("An xinetd internal service which generate characters. The xinetd internal service which continuously generates characters until the connection is dropped.  This is the udp version. You must enable xinetd to use this service.") ],
    "cpufreqd"          =>  [ _("CPU frequency monitor"), _("cpufreqd is used to monitor the status of the battery and adjust the frequency of the CPU accordingly in order to preserve battery power while providing optimal performance") ],
		"cron"              =>	[ _("daemon to execute scheduled commands"), "" ],
    "crond"             =>      [ _("Run scheduled jobs"), _("cron is a standard UNIX program that runs user-specified programs at periodic scheduled times. vixie cron adds a number of features to the basic UNIX cron, including better security and more powerful configuration options.") ],
    "cupsd"             =>  [ _("Common Unix Printing System"), _("Printing system based upon the Internet Printing Protocol, version  1.1") ],
		"cupsys"            =>	[ _("Common Unix Printing System"), _("Printing system based upon the Internet Printing Protocol, version  1.1") ],
    "daytime"           =>      [ "", _("An internal xinetd service which gets the current system time then prints it out in a format like this: 'Wed Nov 13 22:30:27 EST 2002'.  This is the tcp version. You must enable xinetd to use this service.") ],
    "daytime-udp"   =>      [ "", _("An internal xinetd service which gets the current system time then prints it out in a format like this: 'Wed Nov 13 22:30:27 EST 2002'.  This is the udp version. You must enable xinetd to use this service.") ],
    "ddclient"      =>      [ _("Dynamic DNS Client"), _("A Dynamic DNS Name service from www.dyndns.org") ],
    "dhis-client"   =>      [ _("Dynamic DNS Client"), _("A Dynamic DNS Name service from www.dhis.org") ],
    "dictd"         =>      [ _("Dict Dictionary Server"), _("Dict Dictionary Server") ],
    "echo"              =>      [ "", _("An xinetd internal service which echo's characters back to clients.  This is the tcp version. You must enable xinetd to use this service.") ],
    "echo-udp"          =>      [ "", _("An xinetd internal service which echo's characters back to clients.  This is the udp version. You must enable xinetd to use this service.") ],
    "esound"            =>  [ _("Sound mixing server"), _("The Enlightened Sound Daemon") ],
    "exim"              =>      [ _("Exim SMTP Server"), _("Exim SMTP Server") ],
    "fam"               =>  [ _("file alteration monitor"), "" ],
    "firstboot"         =>      [ "", _("Firstboot is a druid style program that runs on the first time") ],
    "festival"          =>  [ _("Text-to-speech system"), _("Festival is a general purpose text-to-speech system") ],
    "fetchmail"         =>  [ _("Mail Fetcher") , _("A Mail Fetcher from external Servers") ],
    "freenet6"          =>  [ _("IPv6 Tunnel Broker"), _("A IPv6 Dynamic Tunnel Broker") ],
    "gdm"               =>	[ _("GNOME Display Manager"), _("gdm provides the GNOME equivalent of a \"login:\" prompt.") ],
    "gpm"                   =>      [ _("console mouse support"), _("GPM adds mouse support to text-based Linux applications such the Midnight Commander. It also allows mouse-based console cut-and-paste operations, and includes support for pop-up menus on the console.") ],
    "hdparm"            =>  [ _("Set hard disk parameters"), _("Provides a interface to various hard disk ioctls supported by the stock Linux ATA/IDE device driver subsystem.") ],
    "hotplug"           =>  [ _("Linux hotplugging support"), _("hotplug is a program which is used by the kernel to notify user mode software when some significant (usually hardware-related) events take place. An example is when a USB or Cardbus device has just been plugged in.") ],
    "httpd"             =>      [ _("web server"), _("Apache is a World Wide Web server.  It is used to serve HTML files and CGI.") ],
		"inetd"             =>	[ _("internet superserver"), _("inetd allows running one daemon to invoke several others, reducing load on the system.") ],
		"iptables"          =>	[ _("administration tool for IPv4 packet filtering and NAT"), _("Iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel.") ],
    "irda"              =>      [ "", _("IrDA stack for Linux") ],
    "isakmpd"           =>  [ _("The Internet Key Exchange protocol"), _("The Internet Key Exchange protocol openbsd implementation") ],
    "isdn"              =>      [ "", _("start and stop ISDN services") ],
    "joystick"          =>  [ _("Check and fix joystick device nodes"), _("Runs joystick-device-check.  joystick-device-check is a program which ensures that the /dev/js* device nodes are correct for the kernel version in use.") ],
    "keytable"          =>      [ "", _("This package loads the selected keyboard map as set in /etc/sysconfig/keyboard.  This can be selected using the kbdconfig utility.  You should leave this enabled for most machines.") ],
		"klogd"             =>	[ _("Kernel Log Daemon"), _("klogd is a system daemon which intercepts and logs Linux kernel messages.") ],
    "kudzu"             =>      [ "", _("This runs the hardware probe, and optionally configures changed hardware.") ],
    "lircd"             =>      [ "", _("LIRC is a package that allows you to decode and send infra-red signals of many commonly used remote controls") ],
    "lircmd"            =>      [ "", _("LIRC is a package that allows you to decode and send infra-red signals of many commonly used remote controls") ],
    "local"             =>  [ _("Starts misc programs that should be started"), "" ],
    "lpd"               =>      [ "", _("lpd is the print daemon required for lpr to work properly. It is basically a server that arbitrates print jobs to printer(s).") ],
    "makedev"           =>      [ _("Create devices"), _("Script that will create the devices in /dev used to interface with drivers in the kernel") ],
    "metalog"           =>      [ _("Syslog Replacement"), _("Modern logging daemon") ],
    "modules"           =>      [ _("Load kernel modules"), "" ],
    "module-init-tools" =>      [ _("tools for managing Linux kernel modules"), _("tools for managing Linux kernel modules") ],
    "mysql"             =>      [ _("database server"), _("MySQL, a SQL-based relational database daemon") ],
    "named"             =>      [ _("dns server"), _("named (BIND) is a Domain Name Server (DNS) that is used to resolve host names to IP addresses.") ],
    "netfs"             =>      [ "", _("Mounts and unmounts all Network File System (NFS), SMB (Lan Manager/Windows), and NCP (NetWare) mount points.") ],
    "network"           =>      [ "", _("Activates/Deactivates all network interfaces configured to start at boot time.") ],
    "nfs"               =>      [ "", _("NFS is a popular protocol for file sharing across TCP/IP networks. This service provides NFS server functionality, which is configured via the /etc/exports file.") ],
    "nfslock"           =>      [ "", _("NFS is a popular protocol for file sharing across TCP/IP networks. This service provides NFS file locking functionality.") ],
    "nscd"              =>  [ _("Name service cache daemon"), _("Daemon that provides a cache for the most common name service requests.") ],
    "ntpd"              =>      [ _("Network Time Protocol daemon"), _("ntpd is the NTPv4 daemon.") ],
    "ntpdate"           =>      [ _("Update the system time over the network"), _("Checks the time from a Network Time Protocol (ntp) server and adjusts the system time accordingly.") ],
    "ntp-client"        =>  [ _("Update the system time over the network"), _("Checks the time from a Network Time Protocol (ntp) server and adjusts the system time accordingly.") ],
    "ntp-simple"        =>  [ _("Network Time Protocol (NTP) server"), _("Daemon which sets and maintains the system time-of-day in synchronism with Internet standard time servers") ],
    "oops"              =>      [ _("HTTP caching proxy"), _("HTTP caching proxy") ],
    "pcmcia"            =>      [ _("PCMCIA Services"), _("PCMCIA Services") ],
    "pdnsd"             =>      [ _("Caching-Only DNS Server"), _("Caching-Only DNS Server") ],
    "pipsecd"           =>      [ _("IPsec tunnel implementation"), _("IPsec tunnel implementation") ],
    "portmap"           =>      [ _("DARPA port to RPC program number mapper"), _("The portmapper manages RPC connections, which are used by protocols such as NFS and NIS. The portmap server must be running on machines which act as servers for protocols which make use of the RPC mechanism.") ],
    "postfix"           =>  [ _("Mail Transport Agent"), "" ],
		"postgresql"        =>	[ _("database server"), "" ],
    "ppp"               =>  [ _("Point to Point Protocol daemon"), _("The  Point-to-Point Protocol (PPP) provides a method for transmitting datagrams over serial point-to-point links.") ],
    "privoxy"           =>  [ _("Privacy enhancing HTTP Proxy"), _("Privacy enhancing HTTP Proxy") ],
    "random"            =>      [ "", _("Saves and restores system entropy pool for higher quality random number generation.") ],
    "rawdevices"        =>      [ "", _("This scripts assignes raw devices to block devices (such as hard drive partitions). This is for the use of applications such as Oracle. You can set up the raw device to block device mapping by editing the file /etc/sysconfig/rawdevices.") ],
    "rhnsd"             =>      [ "", _("This is a daemon which handles the task of connecting periodically to the Red Hat Network servers to check for updates, notifications and perform system monitoring tasks according to the service level that this server is subscribed for.") ],
    "rsync"             =>      [ "", _("The rsync server is a good addition to am ftp server, as it allows crc checksumming etc. You must enable xinetd to use this service.") ],
    "rsyncd"            =>  [ _("Faster, flexible replacement for rcp"), _("The rsync server is a good addition to am ftp server, as it allows crc checksumming etc. You must enable xinetd to use this service.") ],
    "samba"             =>  [ _("A Windows SMB/CIFS fileserver for UNIX"), _("The Samba software suite is a collection of programs that implements the Server Message Block protocol for UNIX systems.") ],
    "saslauthd"         =>      [ "", _("saslauthd is a server process which handles plaintext authentication requests on behalf of the cyrus-sasl library.") ],
    "sendmail"          =>      [ "", _("Sendmail is a Mail Transport Agent, which is the program that moves mail from one machine to another.") ],
    "servers"           =>      [ "", _("An internal xinetd service, listing active servers. You must enable xinetd to use this service.") ],
    "services"          =>      [ "", _("An internal xinetd service, listing active services. You must enable xinetd to use this service.") ],
    "setserial"         =>  [ _("get/set serial port information"), _("setserial is a program designed to set and/or report the configuration information associated with a serial port.") ],
    "sgi_fam"           =>      [ "", _("FAM is a file monitoring daemon. It can be used to get reports when files change. You must enable xinetd to use this service.") ],
    "smartmontools"     =>      [ _("control and monitor storage systems using S.M.A.R.T."), _("control and monitor storage systems using S.M.A.R.T.") ],
    "spamassassin"      =>      [ _("Perl-based spam filter using text analysis"), _("Perl-based spam filter using text analysis") ],
    "snmpd"             =>      [ "", _("Simple Network Management Protocol (SNMP) Daemon") ],
		"ssh"               =>	[ _("OpenSSH SSH server"), _("ssh is a program for logging into a remote machine and for executing commands on a remote machine.") ],
    "sshd"              =>      [ _("OpenSSH SSH server"), _("OpenSSH server daemon") ],
		"sysklogd"          =>	[ _("Linux system logging utilities"), _("Sysklogd provides two system utilities which provide support for system  logging  and  kernel  message  trapping.") ],
    "syslog"            =>      [ "", _("Syslog is the facility by which many daemons use to log messages to various system log files.  It is a good idea to always run syslog.") ],
    "time"              =>      [ "", _("An RFC 868 time server. This protocol provides a site-independent, machine readable date and time. The Time service sends back to the originating source the time in seconds since midnight on January first 1900.  This is the tcp version. You must enable xinetd to use this service.") ],
    "time-udp"          =>      [ "", _("An RFC 868 time server. This protocol provides a site-independent, machine readable date and time. The Time service sends back to the originating source the time in seconds since midnight on January first 1900.  This is the udp version. You must enable xinetd to use this service.") ],
		"urandom"           =>	[ _("kernel random number source devices"), _("The  random  number  generator  gathers environmental noise from device drivers and other sources into an entropy pool. From this entropy pool random numbers are created.") ],
		"vcron"             =>	[ _("daemon to execute scheduled commands"), "" ],
    "vmware"            =>  [ _("Intel(TM) x86(TM)-based virtual machine"), _("The vmware command starts an Intel X86-based virtual machine. This script manages the services needed to run VMware software.") ],
    "webmin"            =>  [ _("Web-based administration toolkit"), _("Web-based administration toolkit") ],
    "winbind"           =>      [ _("Name Service Switch daemon for resolving names from NT servers"), _("Starts and stops the Samba winbind daemon") ],
    "wine"              =>      [ "", _("Allow users to run Windows(tm) applications by just clicking on them (or typing ./file.exe)") ],
    "xdm"               =>  [ _("X Display Manager"), _("Provides the X equivalent of a \"login:\" prompt.") ],
    "xfs"               =>	[ _("X font server"), _("Xfs is the X Window System font server. It supplies fonts to X Window System display servers.") ],
    "xinetd"            =>      [ "", _("xinetd is a powerful replacement for inetd. xinetd has access control machanisms, extensive logging capabilities, the ability to make services available based on time, and can place limits on the number of servers that can be started, among other things.") ]
	);

	$desc = $service_description_list{$service};
	return @$desc;	
}


# This function determines if a service is "forbidden" or not (if runlevel-admin must show it or not)
sub gst_service_list_service_is_forbidden
{
	my ($service) = @_;
	my ($ret);

  my ($service_forbidden_list) =
    [
     # These are the forbidden services I found in Red Hat
     "halt",
     "functions",
     "killall",
     # These are the forbidden services I found in Debian Woody	
     "single",
     "sendsigs",
     "reboot",
     "rcS",
     "modutils",
     "hostname\.sh",
     "devpts\.sh",
     "console-screen\.sh",
     "checkroot\.sh",
     "checkfs\.sh",
     "bootmisc\.sh",
     "bootclean\.sh",
     "checkfs\.sh",
     "keymap\.sh",
     "hwclockfirst\.sh",
     "etc-setserial",
     "procps\.sh",
     "mountall\.sh",
     "dns-clean",
     "ifupdown",
     "networking",
     "mountnfs\.sh",
     "mountkernfs",
     "mountvirtfs",
     "setserial",
     "hwclock\.sh",
     "urandom",
     "nviboot",
     "pppd-dns",
     "skeleton",
     "xfree86-common",
     "rc",
     ".*\.dpkg-old",
     ".*~",
     # this shouldn't be shown in slackware
     "inet2",
     # those were found in gentoo
     "bootmisc",
     "checkfs",
     "checkroot",
     "clock",
     "consolefont",
     "crypto-loop",
     "domainname",
     "hostname",
     "keymaps",
     "localmount",
     "net\..*",
     "numlock",
     "depscan\.sh",
     "functions\.sh",
     "halt\.sh",
     "reboot\.sh",
     "rmnologin",
     "runscript\.sh",
     "serial",
     "shutdown\.sh",
     "switch",
     # those were found in FreeBSD
     "DAEMON",
     "LOGIN",
     "NETWORKING",
     "SERVERS",
     "addswap",
     "adjkerntz",
     "archdep",
     "atm2\.sh",
     "atm3\.sh",
     "ccd",
     "cleanvar",
     "cleartmp",
     "devdb",
     "devfs",
     "dhclient",
     "diskless",
     "dumpon",
     "fsck",
     "hostname",
     "initdiskless",
     "initrandom",
     "ldconfig",
     "local",
     "localdaemons",
     "mountcritlocal",
     "mountcritremote",
     "msgs",
     "netif",
     "network1",
     "network2",
     "network3",
     "nisdomain",
     "othermta",
     "pccard",
     "pcvt",
     "pwcheck",
     "random",
     "rcconf\.sh",
     "root",
     "savecore",
     "securelevel",
     "serial",
     "sppp",
     "swap1",
     "syscons",
     "sysctl",
     "ttys",
     "virecover",
     # These are the services found in SuSE
     "rc[sS0-9]\.d",
     "boot",
     "boot\..*",
    ];

  foreach $i (@$service_forbidden_list)
  {
    return 1 if ($service =~ "^$i\$");
  }
	
  return undef;
}

1;
