Changeset 305


Ignore:
Timestamp:
Nov 13, 2010, 11:24:24 PM (14 years ago)
Author:
katerina
Message:

Fix for ticker #226 (incorrect handling of missing files when secondary schedule is active).

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/Changelog

    r304 r305  
    112.8.1:
     2        * Fix incorrect handling of missing files when secondary schedule
     3          is used (reported by Sergey)
    24        * Fix null pointer dereference in config parse handler for SetMailAlias
    35          (reported by Sergey)
  • trunk/include/sh_hash.h

    r294 r305  
    3535 */
    3636int hashreport_missing( char *fullpath, int level);
     37
     38/* remove internal db record for a file
     39 */
     40void sh_hash_remove (const char * path);
    3741
    3842/* write database to stdout
  • trunk/include/sh_utils.h

    r214 r305  
    9494/* ask if a file should be updated (returns S_TRUE/S_FALSE)
    9595 */
    96 int sh_util_ask_update(char * path);
     96int sh_util_ask_update(const char * path);
    9797int sh_util_set_interactive(const char * str);
    9898
  • trunk/src/samhain.c

    r294 r305  
    20242024          if (flag_check_2 == 1 || FileSchedTwo == NULL)
    20252025            {
     2026              fprintf(stderr, "FIXME check unvisited\n");
    20262027              TPT((0, FIL__, __LINE__, _("msg=<Check for missing files.>\n")))
    20272028              sh_hash_unvisited (ShDFLevel[SH_ERR_T_FILE]);
  • trunk/src/sh_files.c

    r294 r305  
    377377                  if (S_FALSE == sh_ignore_chk_del(ptr->name))
    378378                    {
     379                      fprintf(stderr, "FIXME 1 %s, %d\n", ptr->name, ptr->is_reported);
    379380                      if (0 != hashreport_missing(ptr->name,
    380381                                                  (ptr->class == SH_LEVEL_ALLIGNORE) ?
     
    430431                   * file has been added.
    431432                   */
    432                   if (sh_hash_have_it (ptr->name) >= 0)
     433                  if (sh_hash_have_it (ptr->name) >= 0 &&
     434                      !SH_FFLAG_REPORTED_SET(ptr->is_reported))
    433435                    {
    434436                      if (S_FALSE == sh_ignore_chk_del(ptr->name))
    435437                        {
     438                          fprintf(stderr, "FIXME 2 %s, %d\n", ptr->name, ptr->is_reported);
    436439                          if (0 != hashreport_missing(ptr->name,
    437440                                                      (ptr->class == SH_LEVEL_ALLIGNORE) ?
     
    12891292              if (S_FALSE == sh_ignore_chk_del(ptr->name))
    12901293                {
     1294                  fprintf(stderr, "FIXME 2 %s, %d\n", ptr->name, ptr->is_reported);
    12911295                  if (0 != hashreport_missing(ptr->name,
    12921296                                              (ptr->class == SH_LEVEL_ALLIGNORE) ?
  • trunk/src/sh_hash.c

    r294 r305  
    393393}
    394394
     395struct two_sh_file_t {
     396  sh_file_t * prev;
     397  sh_file_t * this;
     398};
     399
    395400static sh_file_t * hashsearch (const char * s);
     401static int hashsearch_prev (const char * s, struct two_sh_file_t * a, int * index);
    396402
    397403static sh_file_t * tab[TABSIZE];
     
    423429  char hashbuf[KEYBUF_SIZE];
    424430  int  retval;
     431  volatile int flag = 0;
    425432
    426433  /* --------  find the entry for the file ----------------       */
     
    449456  sh_error_handle (level, FIL__, __LINE__, 0,
    450457                   MSG_FI_MISS2, tmp, str);
     458  flag = 1;
    451459  SH_FREE(tmp);
    452460  SH_FREE(str);
     
    458466  ; /* 'label at end of compound statement */
    459467  SH_MUTEX_UNLOCK(mutex_hash);
     468
    460469  return retval;
    461470}
     
    625634
    626635
     636
    627637/*********************************************************************
    628638 *
     
    646656  SL_RET0(_("hash_unvisited"));
    647657}
     658
     659/*********************************************************************
     660 *
     661 * Remove a single file from the database.
     662 *
     663 *********************************************************************/
     664void sh_hash_remove (const char * path)
     665{
     666  struct two_sh_file_t entries;
     667  int index;
     668
     669  SL_ENTER(_("sh_hash_remove"));
     670
     671  SH_MUTEX_LOCK(mutex_hash);
     672
     673  if ((sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) ||
     674      (S_TRUE == sh.flag.update && S_TRUE == sh_util_ask_update(path)))
     675    {
     676      if (0 == hashsearch_prev (path, &entries, &index))
     677        {
     678          sh_file_t * p = entries.this;
     679#ifdef REPLACE_OLD
     680          /* Remove the old entry
     681           */
     682          if (entries.prev == p)
     683            tab[index] = p->next;
     684          else
     685            entries.prev->next = p->next;
     686         
     687          p = delete_db_entry(p);
     688         
     689          goto end;
     690          SL_RET0(_("sh_hash_remove"));
     691#else
     692          SET_SH_FFLAG_REPORTED(p->fflags);
     693#endif
     694        }
     695    }
     696
     697 end:
     698  ; /* 'label at end of compound statement' */
     699  SH_MUTEX_UNLOCK(mutex_hash);
     700
     701  SL_RET0(_("sh_hash_remove"));
     702}
     703
    648704
    649705/*********************************************************************
     
    772828    }
    773829  SL_RETURN( NULL, _("hashsearch"));
     830}
     831
     832static int hashsearch_prev (const char * s, struct two_sh_file_t * a, int * index)
     833{
     834  sh_file_t * this;
     835  sh_file_t * prev = NULL;
     836
     837  SL_ENTER(_("hashsearch_prev"));
     838
     839  if (s)
     840    {
     841      *index = hashfunc(s);
     842
     843      this = tab[*index];
     844
     845      prev  = this;
     846
     847      if (this)
     848        {
     849          do {
     850           
     851            if ((this->fullpath != NULL) && (0 == strcmp(s, this->fullpath)))
     852              {
     853                a->prev = prev;
     854                a->this = this;
     855               
     856                SL_RETURN( 0, _("hashsearch_prev"));
     857              }
     858           
     859            prev = this;
     860            this = this->next;
     861           
     862          } while(this);
     863        }
     864    }
     865  SL_RETURN( -1, _("hashsearch"));
    774866}
    775867
     
    22262318  int i;
    22272319  SL_ENTER(_("sh_hash_set_missing"));
     2320
    22282321  i = sh_hash_set_visited_int(newname, SH_FFLAG_CHECKED);
     2322
     2323  if (sh.flag.checkSum != SH_CHECK_INIT) {
     2324    sh_hash_remove(newname);
     2325  }
     2326
    22292327  SL_RETURN(i, _("sh_hash_set_missing"));
    22302328}
  • trunk/src/sh_utils.c

    r294 r305  
    120120#endif
    121121
    122 int sh_util_ask_update(char * path)
     122int sh_util_ask_update(const char * path)
    123123{
    124124  int    inchar, c;
Note: See TracChangeset for help on using the changeset viewer.