Changeset 328 for trunk


Ignore:
Timestamp:
Apr 6, 2011, 8:37:39 PM (14 years ago)
Author:
katerina
Message:

Fix for ticket #247: The port range for the open port check should be configurable

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/Changelog

    r326 r328  
    44        * Add support for X-Forwarded-For in apache logfile parser, add
    55          option 'RE{regex}' to insert arbitrary regex
     6        * New options PortcheckMinPort, PortcheckMaxPort for the open ports
     7          check
    68
    792.8.3a:
     
    1416        * sh_entropy.c: move pthread usage out of child
    1517        * sh_hash.c, sh_pthread.c, sh_pthread.h: sh_hash_hashdelete()
    16           needs deadlock detection, may be called from within sh_hash_init() 
     18          needs deadlock detection, may be called from within sh_hash_init()
    1719          via atexit handler on error condition
    1820        * sh_suidchk.c, sh_calls.c, sh_calls.h: need a nosub version of lstat()
     
    2426        * fix spurious warnings about unsupported address family (reported
    2527          by N Silverman)
    26         * option to run lstat/stat in subprocess to avoid hanging on NFS mounts 
     28        * option to run lstat/stat in subprocess to avoid hanging on NFS mounts
    2729          (off by default)
    2830        * fix Windows/Cygwin compile error (reported by A. Schmidt)
  • trunk/src/sh_portcheck.c

    r300 r328  
    129129static int sh_portchk_interval  = SH_PORTCHK_INTERVAL;
    130130
     131static int sh_portchk_minport = -1;
     132static int sh_portchk_maxport = -1;
     133
    131134struct sh_port {
    132135  int                  port;
     
    195198}
    196199
     200static int sh_portchk_set_port_minmax (const char * c, int * setthis)
     201{
     202  int retval = 0;
     203  long val;
     204
     205  SL_ENTER(_("sh_portchk_set_port_minmax"));
     206  val = strtol (c, (char **)NULL, 10);
     207  if (val < 0 || val > 65535)
     208    {
     209      SH_MUTEX_LOCK(mutex_thread_nolog);
     210      sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALS,
     211                       _("port check port minmax"), c);
     212      SH_MUTEX_UNLOCK(mutex_thread_nolog);
     213      retval = -1;
     214    }
     215
     216  *setthis = (int) val;
     217  SL_RETURN(0, _("sh_portchk_set_port_minmax"));
     218}
     219
     220
     221static int sh_portchk_set_minport   (const char * str)
     222{
     223  return sh_portchk_set_port_minmax (str, &sh_portchk_minport);
     224}
     225
     226static int sh_portchk_set_maxport   (const char * str)
     227{
     228  return sh_portchk_set_port_minmax (str, &sh_portchk_maxport);
     229}
    197230
    198231static int sh_portchk_set_active   (const char * str)
     
    246279        N_("portcheckinterval"),
    247280        sh_portchk_set_interval,
     281    },
     282    {
     283        N_("portcheckminport"),
     284        sh_portchk_set_minport,
     285    },
     286    {
     287        N_("portcheckmaxport"),
     288        sh_portchk_set_maxport,
    248289    },
    249290    {
     
    11661207  sh_portchk_interval  = SH_PORTCHK_INTERVAL;
    11671208
     1209  sh_portchk_minport = -1;
     1210  sh_portchk_maxport = -1;
     1211
    11681212  portlist_udp = sh_portchk_kill_list (portlist_udp);
    11691213  portlist_tcp = sh_portchk_kill_list (portlist_tcp);
     
    17241768  SH_MUTEX_LOCK(mutex_port_check);
    17251769
    1726   min_port = 0;
     1770  min_port = (sh_portchk_minport == -1) ? 0 : sh_portchk_minport;
    17271771
    17281772  if (sh_portchk_active != S_FALSE)
     
    17331777
    17341778      sh_portchk_reset_lists();
    1735       if (0 != geteuid())
     1779      if ((0 != geteuid()) && (min_port < 1024))
    17361780        {
    17371781          min_port = 1024;
     
    17491793      sh_port2proc_prepare();
    17501794
     1795      min_port = (sh_portchk_minport == -1) ? min_port : sh_portchk_minport;
     1796
    17511797      if (sh_portchk_check_udp == 1)
    1752         sh_portchk_scan_ports_udp(min_port, -1);
    1753       sh_portchk_scan_ports_tcp(min_port, -1);
     1798        sh_portchk_scan_ports_udp(min_port, sh_portchk_maxport);
     1799      sh_portchk_scan_ports_tcp(min_port, sh_portchk_maxport);
    17541800
    17551801
Note: See TracChangeset for help on using the changeset viewer.