Ignore:
Timestamp:
Jun 7, 2011, 9:41:30 PM (13 years ago)
Author:
katerina
Message:

Fix for ticket #255 (improve protection against 'intruder on server' scenario).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_readconf.c

    r315 r347  
    136136static char * sh_readconf_expand_value (const char * str)
    137137{
     138#ifdef SH_EVAL_SHELL
    138139  char * tmp = (char*)str;
    139140  char * out;
     
    152153        }
    153154    }
     155#endif
    154156  return sh_util_strdup(str);
    155157}
     
    161163  SH_RC_FILE       = 3,
    162164  SH_RC_IFACE      = 4,
     165#ifdef SH_EVAL_SHELL
    163166  SH_RC_CMD        = 5
     167#endif
    164168};
    165169
     
    218222          p += 15; cond_type = SH_RC_SYSTEM;
    219223        }
     224#ifdef SH_EVAL_SHELL
    220225      else if (0 == strncasecmp(p, _("command_succeeds "), 17))
    221226        {
    222227          p += 17; cond_type = SH_RC_CMD;
    223228        }
     229#endif
    224230      else
    225231        {
     
    271277        match = negate;
    272278      break;
     279#ifdef SH_EVAL_SHELL
    273280    case SH_RC_CMD:
    274281      if (0 == sh_unix_run_command(p))
    275282        match = negate;
    276283      break;
     284#endif
    277285    default:
    278286      match = 0;
     
    337345#if defined(SH_STEALTH) && !defined(SH_STEALTH_MICRO)
    338346  SL_TICKET    fdTmp = -1;
    339   SL_TICKET open_tmp (void);
     347#endif
     348#if defined(WITH_GPG) || defined(WITH_PGP)
     349  SL_TICKET    fdGpg = -1;
    340350#endif
    341351  char * tmp;
     
    464474  sl_close(fd);
    465475  fd = fdTmp;
     476  sl_rewind (fd);
     477#endif
     478
     479#if defined(WITH_GPG) || defined(WITH_PGP)
     480
     481  /* extract the data and copy to temporary file
     482   */
     483  fdGpg = sh_gpg_extract_signed(fd);
     484
     485  sl_close(fd);
     486  fd = fdGpg;
     487
     488  /* Validate signature of open file.
     489   */
     490  if (0 != sh_gpg_check_sign (fd, 0, 1))
     491    {
     492      SH_FREE(line_in);
     493      aud_exit (FIL__, __LINE__, EXIT_FAILURE);
     494    }
    466495  sl_rewind (fd);
    467496#endif
     
    664693                     (long) conf_line);
    665694
    666 #if defined(WITH_GPG) || defined(WITH_PGP)
    667   /* Validate signature of open file.
    668    */
    669   sl_rewind (fd);
    670   if (0 != sh_gpg_check_sign (fd, 0, 1))
    671     {
    672       SH_FREE(line_in);
    673       aud_exit (FIL__, __LINE__, EXIT_FAILURE);
    674     }
    675 #endif
    676 
    677695  sl_close (fd);
    678696
     
    13581376
    13591377  /* Expand shell expressions. This return allocated memory which we must free.
     1378   * If !defined(SH_EVAL_SHELL), this will reduce to a strdup.
    13601379   */
    13611380  value = sh_readconf_expand_value(value);
Note: See TracChangeset for help on using the changeset viewer.