Ignore:
Timestamp:
Jul 18, 2015, 5:06:52 PM (6 years ago)
Author:
katerina
Message:

Enhancements and fixes for tickets #374, #375, #376, #377, #378, and #379.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_readconf.c

    r432 r481  
    3333#include "sh_unix.h"
    3434#include "sh_files.h"
    35 #include "sh_forward.h"
     35#include "sh_xfer.h"
    3636#include "sh_gpg.h"
    3737#include "sh_hash.h"
     38#include "sh_dbIO.h"
    3839#include "sh_ignore.h"
    3940#include "sh_database.h"
     
    4950#include "sh_utils.h"
    5051#include "sh_restrict.h"
    51 
     52#include "sh_socket.h"
    5253
    5354extern int set_reverse_lookup (const char * c);
     
    137138{
    138139#ifdef SH_EVAL_SHELL
    139   char * tmp = (char*)str;
     140  char * tmp = sh_util_strdup(str);
    140141  char * out;
     142  char * tmp_orig = tmp;
    141143
    142144  while (tmp && isspace((int)*tmp)) ++tmp;
     
    150152          tmp[len-1] = '\0';
    151153          out = sh_ext_popen_str(&tmp[2]);
     154          SH_FREE(tmp_orig);
    152155          return out;
    153156        }
    154157    }
     158  SH_FREE(tmp_orig);
    155159#endif
    156160  return sh_util_strdup(str);
     
    384388      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_D_START);
    385389
    386       fd = sh_forward_req_file(_("CONF"));
     390      fd = sh_xfer_request_file(_("CONF"));
    387391
    388392      if (!SL_ISERROR(fd))
     
    392396      else if (sh.flag.checkSum != SH_CHECK_INIT)
    393397        {
     398          sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FBAD);
    394399          aud_exit (FIL__, __LINE__, EXIT_FAILURE);
    395400        }
    396401      else
    397402        {
     403          sh_error_handle(SH_ERR_WARN, FIL__, __LINE__, 0, MSG_TCP_FBAD);
    398404          sh_error_handle ((-1), FIL__, __LINE__, fd, MSG_D_FAIL);
    399405          local_file = 1;
     
    490496  /* Validate signature of open file.
    491497   */
    492   if (0 != sh_gpg_check_sign (fd, 0, 1))
     498  if (0 != sh_gpg_check_sign (fd, SIG_CONF))
    493499    {
    494500      SH_FREE(line_in);
     501      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORT1, sh.prg_name);
    495502      aud_exit (FIL__, __LINE__, EXIT_FAILURE);
    496503    }
     
    830837}
    831838
     839
     840#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
     841static int sh_readconf_set_delay (const char * c)
     842{
     843  unsigned long i = atol (c);
     844
     845  if (i  > INT_MAX)
     846    return -i;
     847  sh.delayload = (int) i;
     848  return 0;
     849}
     850#endif
     851
    832852#ifdef FANCY_LIBCAP
    833853int sh_readconf_setCaps(const char * c)
     
    965985    sh_files_pushfile_prelink },
    966986
    967   { N_("ignoreadded"),   SH_SECTION_MISC,   SH_SECTION_NONE,
     987  { N_("ignoreadded"),          SH_SECTION_MISC,   SH_SECTION_NONE,
    968988    sh_ignore_add_new },
    969   { N_("ignoremissing"), SH_SECTION_MISC,   SH_SECTION_NONE,
     989  { N_("ignoremissing"),        SH_SECTION_MISC,   SH_SECTION_NONE,
    970990    sh_ignore_add_del },
    971   { N_("ignoremodified"), SH_SECTION_MISC,   SH_SECTION_NONE,
     991  { N_("ignoremodified"),       SH_SECTION_MISC,   SH_SECTION_NONE,
    972992    sh_ignore_add_mod },
    973993
    974   { N_("skipchecksum"),  SH_SECTION_MISC,   SH_SECTION_NONE,
     994  { N_("skipchecksum"),         SH_SECTION_MISC,   SH_SECTION_NONE,
    975995    sh_restrict_define },
    976   { N_("filetype"),      SH_SECTION_MISC,   SH_SECTION_NONE,
     996  { N_("filetype"),             SH_SECTION_MISC,   SH_SECTION_NONE,
    977997    sh_restrict_add_ftype },
    978998
     
    9831003    sh_set_schedule_two },
    9841004
    985   { N_("usehardlinkcheck"),   SH_SECTION_MISC,   SH_SECTION_NONE,
     1005  { N_("usehardlinkcheck"),     SH_SECTION_MISC,   SH_SECTION_NONE,
    9861006    sh_files_check_hardlinks },
    987   { N_("usersrccheck"),       SH_SECTION_MISC,   SH_SECTION_NONE,
     1007  { N_("usersrccheck"),         SH_SECTION_MISC,   SH_SECTION_NONE,
    9881008    sh_files_use_rsrc },
    989   { N_("hardlinkoffset"),     SH_SECTION_MISC,   SH_SECTION_NONE,
     1009  { N_("hardlinkoffset"),       SH_SECTION_MISC,   SH_SECTION_NONE,
    9901010    sh_files_hle_reg },
    9911011#if defined(USE_XATTR)
    992   { N_("useselinuxcheck"),    SH_SECTION_MISC,   SH_SECTION_NONE,
     1012  { N_("useselinuxcheck"),      SH_SECTION_MISC,   SH_SECTION_NONE,
    9931013    sh_unix_setcheckselinux },
    9941014#endif
    9951015#if defined(USE_ACL)
    996   { N_("useaclcheck"),        SH_SECTION_MISC,   SH_SECTION_NONE,
     1016  { N_("useaclcheck"),          SH_SECTION_MISC,   SH_SECTION_NONE,
    9971017    sh_unix_setcheckacl },
    9981018#endif
    999   { N_("loosedircheck"),      SH_SECTION_MISC,   SH_SECTION_NONE,
     1019  { N_("loosedircheck"),        SH_SECTION_MISC,   SH_SECTION_NONE,
    10001020    sh_hash_loosedircheck },
    1001   { N_("addokchars"),         SH_SECTION_MISC,   SH_SECTION_NONE,
     1021  { N_("addokchars"),           SH_SECTION_MISC,   SH_SECTION_NONE,
    10021022    sh_util_obscure_ok },
    1003   { N_("filenamesareutf8"),   SH_SECTION_MISC,   SH_SECTION_NONE,
     1023  { N_("filenamesareutf8"),     SH_SECTION_MISC,   SH_SECTION_NONE,
    10041024    sh_util_obscure_utf8 },
    1005   { N_("setrecursionlevel"),  SH_SECTION_MISC,   SH_SECTION_NONE,
     1025  { N_("setrecursionlevel"),    SH_SECTION_MISC,   SH_SECTION_NONE,
    10061026    sh_files_setrecursion },
    1007   { N_("checksumtest"),       SH_SECTION_MISC,   SH_SECTION_NONE,
     1027  { N_("checksumtest"),         SH_SECTION_MISC,   SH_SECTION_NONE,
    10081028    sh_util_setchecksum },
    1009   { N_("reportonlyonce"),     SH_SECTION_MISC,   SH_SECTION_NONE,
     1029  { N_("reportonlyonce"),       SH_SECTION_MISC,   SH_SECTION_NONE,
    10101030    sh_files_reportonce },
    1011   { N_("reportfulldetail"),   SH_SECTION_MISC,   SH_SECTION_NONE,
     1031  { N_("reportfulldetail"),     SH_SECTION_MISC,   SH_SECTION_NONE,
    10121032    sh_files_fulldetail },
    1013   { N_("uselocaltime"),       SH_SECTION_MISC,   SH_SECTION_NONE,
     1033  { N_("uselocaltime"),         SH_SECTION_MISC,   SH_SECTION_NONE,
    10141034    sh_unix_uselocaltime },
    10151035
    1016   { N_("setnicelevel"),   SH_SECTION_MISC,   SH_SECTION_NONE,
     1036  { N_("setnicelevel"),         SH_SECTION_MISC,   SH_SECTION_NONE,
    10171037    sh_readconf_set_nice },
    10181038
     1039  { N_("startuploaddelay"),     SH_SECTION_MISC,   SH_SECTION_NONE,
     1040    sh_readconf_set_delay },
     1041
    10191042#if defined(FANCY_LIBCAP)
    1020   { N_("usecaps"),        SH_SECTION_MISC,   SH_SECTION_NONE,
     1043  { N_("usecaps"),              SH_SECTION_MISC,   SH_SECTION_NONE,
    10211044    sh_readconf_setCaps },
    10221045#endif
    10231046
    1024   { N_("setdropcache"),   SH_SECTION_MISC,   SH_SECTION_NONE,
     1047  { N_("reportcheckflags"),     SH_SECTION_MISC,   SH_SECTION_NONE,
     1048    set_report_checkflags },
     1049
     1050  { N_("setdropcache"),         SH_SECTION_MISC,   SH_SECTION_NONE,
    10251051    sl_set_drop_cache },
    10261052
    1027   { N_("setiolimit"),   SH_SECTION_MISC,   SH_SECTION_NONE,
     1053  { N_("setiolimit"),           SH_SECTION_MISC,   SH_SECTION_NONE,
    10281054    sh_unix_set_io_limit },
    10291055
    10301056  { N_("versionstring"),        SH_SECTION_MISC,   SH_SECTION_NONE,
    1031     sh_hash_version_string },
     1057    sh_dbIO_version_string },
    10321058
    10331059  { N_("digestalgo"),           SH_SECTION_MISC,   SH_SECTION_NONE,
     
    10921118    sh_socket_password },
    10931119  { N_("setstripdomain"),      SH_SECTION_SRV,  SH_SECTION_MISC,
    1094     sh_forward_set_strip },
     1120    sh_xfer_set_strip },
    10951121  { N_("useseparatelogs"),     SH_SECTION_SRV,  SH_SECTION_MISC,
    10961122    set_flag_sep_log },
     
    10981124    sh_unix_set_chroot },
    10991125  { N_("setclienttimelimit"),  SH_SECTION_SRV,  SH_SECTION_MISC,
    1100     sh_forward_set_time_limit },
     1126    sh_xfer_set_time_limit },
    11011127  { N_("setconnectiontimeout"),SH_SECTION_SRV,  SH_SECTION_MISC,
    1102     sh_forward_set_timeout },
     1128    sh_xfer_set_timeout },
    11031129  { N_("useclientseverity"),   SH_SECTION_SRV,  SH_SECTION_MISC,
    1104   sh_forward_use_clt_sev },
     1130  sh_xfer_use_clt_sev },
    11051131  { N_("useclientclass"),      SH_SECTION_SRV,  SH_SECTION_MISC,
    1106   sh_forward_use_clt_class },
     1132  sh_xfer_use_clt_class },
    11071133  { N_("severitylookup"),      SH_SECTION_SRV,  SH_SECTION_MISC,
    1108   sh_forward_lookup_level },
     1134  sh_xfer_lookup_level },
    11091135  { N_("setclientfromaccept"), SH_SECTION_SRV,  SH_SECTION_MISC,
    11101136    set_socket_peer },
    11111137  { N_("setserverport"),       SH_SECTION_SRV,  SH_SECTION_MISC,
    1112     sh_forward_set_port },
     1138    sh_xfer_set_port },
    11131139  { N_("setserverinterface"),  SH_SECTION_SRV,  SH_SECTION_MISC,
    1114     sh_forward_set_interface },
     1140    sh_xfer_set_interface },
    11151141  { N_("client"),              SH_SECTION_CLIENTS,           SH_SECTION_NONE,
    1116     sh_forward_register_client },
     1142    sh_xfer_register_client },
    11171143#endif
    11181144
     
    11241150#if defined(SH_WITH_SERVER)
    11251151  { N_("setlogserver"),        SH_SECTION_SRV,  SH_SECTION_MISC,
    1126     sh_forward_setlogserver },
     1152    sh_xfer_set_logserver },
    11271153#else
    11281154  { N_("setlogserver"),        SH_SECTION_CLT,  SH_SECTION_MISC,
    1129     sh_forward_setlogserver },
     1155    sh_xfer_set_logserver },
    11301156  { N_("setthrottle"),         SH_SECTION_CLT,  SH_SECTION_MISC,
    1131     sh_forward_set_throttle_delay},
     1157    sh_xfer_set_throttle_delay},
     1158  { N_("setdeltaretrycount"),   SH_SECTION_CLT,  SH_SECTION_MISC,
     1159    set_delta_retry_count},
     1160  { N_("setdeltaretryinterval"),SH_SECTION_CLT,  SH_SECTION_MISC,
     1161    set_delta_retry_interval},
    11321162#endif
    11331163#endif
     
    12741304  char * key;
    12751305  const char * value;
     1306  char * value_dup;
    12761307  char * tmp;
    12771308  int    i;
     
    13941425   * If !defined(SH_EVAL_SHELL), this will reduce to a strdup.
    13951426   */
    1396   value = sh_readconf_expand_value(value);
    1397 
    1398   if (!value || (*value) == '\0')
    1399     {
    1400       TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: empty after shell expansion: %s>\n"),
     1427  value_dup = sh_readconf_expand_value(value);
     1428
     1429  if (!value_dup || (*value_dup) == '\0')
     1430    {
     1431      TPT(( 0, FIL__, __LINE__,
     1432            _("msg=<ConfigFile: empty after shell expansion: %s>\n"),
    14011433            line));
    14021434      SL_RETURN(good_opt, _("sh_readconf_line"));
    14031435    }
     1436
     1437  value = value_dup;
    14041438
    14051439#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
     
    14671501    }
    14681502
    1469   SH_FREE((char*)value);
     1503  SH_FREE(value_dup);
    14701504
    14711505  SL_RETURN(good_opt, _("sh_readconf_line"));
    14721506}
    1473  
     1507
    14741508   
Note: See TracChangeset for help on using the changeset viewer.