Changeset 317 for trunk/src


Ignore:
Timestamp:
Mar 15, 2011, 8:54:21 PM (14 years ago)
Author:
katerina
Message:

Further refinements for lstat in subprocess (ticket #236).

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/samhain.c

    r310 r317  
    983983  pid_t       * pidlist;
    984984  int         i;
    985 
     985#ifdef WCONTINUED
     986      int wflags = WNOHANG|WUNTRACED|WCONTINUED;
     987#else
     988      int wflags = WNOHANG|WUNTRACED;
     989#endif
    986990
    987991  fullpath = strdup (SH_INSTALL_PATH);
     
    10301034        times = 0;
    10311035        while (times < 300) {
    1032           respid = waitpid(pid, &status, WNOHANG|WUNTRACED);
     1036          respid = waitpid(pid, &status, wflags);
    10331037          if ((pid_t)-1 == respid)
    10341038            {
     
    14731477  BREAKEXIT(sh_readconf_read);
    14741478  (void) sh_readconf_read ();
     1479
     1480  sh_calls_enable_sub();
    14751481
    14761482#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
  • trunk/src/sh_calls.c

    r315 r317  
    242242}
    243243
     244static int sh_enable_use_sub = 0;
     245
     246#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
     247static int sh_use_sub = 1;
     248#else
    244249static int sh_use_sub = 0;
     250#endif
     251
     252void sh_calls_enable_sub()
     253{
     254  sh_enable_use_sub = 1;
     255  return;
     256}
    245257
    246258int sh_calls_set_sub (const char * str)
    247259{
    248   return sh_util_flagval(str, &sh_use_sub);
     260  int ret = sh_util_flagval(str, &sh_use_sub);
     261
     262  if ((ret == 0) && (!sh_use_sub))
     263    {
     264      sh_kill_sub();
     265    }
     266  return ret;
     267}
     268
     269long int retry_lstat_ns(const char * file, int line,
     270                        const char *file_name, struct stat *buf)
     271{
     272  int error;
     273  long int val_retry = -1;
     274  char errbuf[SH_ERRBUF_SIZE];
     275 
     276  SL_ENTER(_("retry_lstat_ns"));
     277
     278  do {
     279    val_retry = /*@-unrecog@*/lstat (file_name, buf)/*@+unrecog@*/;
     280  } while (val_retry < 0 && errno == EINTR);
     281
     282  error = errno;
     283  if (val_retry < 0) {
     284      (void) sh_error_message(error, aud_err_message, 64);
     285      sh_error_handle ((-1), file, line, error, MSG_ERR_LSTAT,
     286                       sh_error_message(error, errbuf, sizeof(errbuf)),
     287                       file_name );
     288  }
     289  errno = error;   
     290
     291  SL_RETURN(val_retry, _("retry_lstat_ns"));
    249292}
    250293
     
    258301  SL_ENTER(_("retry_lstat"));
    259302
    260   if (sh_use_sub)
     303  if (sh_use_sub && sh_enable_use_sub)
    261304    {
    262305      val_retry = sh_sub_lstat (file_name, buf);
     
    290333  SL_ENTER(_("retry_stat"));
    291334
    292   if (sh_use_sub)
     335  if (sh_use_sub && sh_enable_use_sub)
    293336    {
    294337      val_retry = sh_sub_stat (file_name, buf);
  • trunk/src/sh_suidchk.c

    r257 r317  
    193193/* Recursively descend into the directory to make sure that
    194194 * there is no symlink in the path.
     195 *
     196 * Use retry_lstat_ns() here because we cannot chdir the subprocess
     197 * that does the lstat().
    195198 */
    196199static int do_truncate_int (char * path, int depth)
     
    226229    {
    227230      *q = '\0';
    228       if (0 != retry_lstat(FIL__, __LINE__, path, &one))
     231      if (0 != retry_lstat_ns(FIL__, __LINE__, path, &one))
    229232        {
    230233          SH_MUTEX_LOCK(mutex_thread_nolog);
     
    260263        }
    261264      *q = '/';
    262       if (0 != retry_lstat(FIL__, __LINE__, ".", &two))
     265      if (0 != retry_lstat_ns(FIL__, __LINE__, ".", &two))
    263266        {
    264267          sh_error_handle ((-1), FIL__, __LINE__, errno,
     
    288291      if (*path == '\0')
    289292        return -1;
    290       if (0 != retry_lstat(FIL__, __LINE__, path, &one))
     293      if (0 != retry_lstat_ns(FIL__, __LINE__, path, &one))
    291294        {
    292295          SH_MUTEX_LOCK(mutex_thread_nolog);
Note: See TracChangeset for help on using the changeset viewer.