Changeset 115 for trunk/src/sh_hash.c


Ignore:
Timestamp:
Aug 21, 2007, 10:22:59 PM (17 years ago)
Author:
rainer
Message:

Fix the problem that new suid/sgid file found by the file system check already will not be quarantined in the suid check (ticket #71).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_hash.c

    r114 r115  
    10541054  memcpy( &(*p).theFile, &ft, sizeof(sh_filestore_t) );
    10551055
    1056   p->fflags = 0;
    1057 
     1056  /* init fflags, such that suid files in
     1057   * database are recognized as such
     1058   */
     1059  {
     1060    mode_t mode = (mode_t) ft.mode;
     1061
     1062    if (S_ISREG(mode) &&
     1063        (0 !=(S_ISUID & mode) ||
     1064#if defined(HOST_IS_LINUX)
     1065         (0 !=(S_ISGID & mode) &&
     1066          0 !=(S_IXGRP & mode))
     1067#else 
     1068         0 !=(S_ISGID & mode)
     1069#endif
     1070         )
     1071        )
     1072      p->fflags = SH_FFLAG_SUIDCHK;
     1073
     1074    else
     1075      p->fflags = 0;
     1076  }
     1077     
    10581078  p->modi_mask = 0L;
    10591079  p->fullpath  = fullpath;
     
    18121832  sh_file_t * p;
    18131833
    1814   SL_ENTER(_("sh_hash_have_it"));
     1834  SL_ENTER(_("sh_hash_have_it_int"));
    18151835
    18161836  if (newname == NULL)
    1817     SL_RETURN( (NULL), _("sh_hash_have_it"));
     1837    SL_RETURN( (NULL), _("sh_hash_have_it_int"));
    18181838
    18191839  if (IsInit != 1)
     
    18241844    p = hashsearch ( sh_tiger_hash(newname, TIGER_DATA, sl_strlen(newname)) );
    18251845  if (p == NULL)
    1826      SL_RETURN( (NULL), _("sh_hash_have_it"));
     1846     SL_RETURN( (NULL), _("sh_hash_have_it_int"));
    18271847  /*
    18281848  if (p->allignore == S_FALSE &&
     
    18311851    SL_RETURN( (1), _("sh_hash_have_it"));
    18321852  */
    1833   SL_RETURN( (p), _("sh_hash_have_it"));
     1853  SL_RETURN( (p), _("sh_hash_have_it_int"));
    18341854}
    18351855
     
    18601880  return 0;
    18611881}
    1862  
     1882
     1883int sh_hash_getflags (char * filename)
     1884{
     1885  sh_file_t * p = sh_hash_have_it_int (filename);
     1886  if (!p)
     1887    return (-1);
     1888  return (p->fflags);
     1889}
     1890
     1891int sh_hash_setflags (char * filename, int flags)
     1892{
     1893  sh_file_t * p = sh_hash_have_it_int (filename);
     1894  if (!p)
     1895    return (-1);
     1896  p->fflags = flags;
     1897  return 0;
     1898}
     1899
     1900/* needs lock to be threadsafe
     1901 */
     1902void sh_hash_addflag (char * filename, int flag_to_set)
     1903{
     1904  int fflags = sh_hash_getflags(filename);
     1905
     1906  if (fflags >= 0)
     1907    {
     1908      fflags |= flag_to_set;
     1909      sh_hash_setflags(filename, fflags);
     1910    }
     1911  return;
     1912}
    18631913
    18641914/*****************************************************************
     
    21062156
    21072157  memcpy( &(*fp).theFile, &p, sizeof(sh_filestore_t) );
    2108   fp->fflags    = 0;
     2158  fp->fflags    = 0;  /* init fflags */
    21092159  fp->modi_mask = 0L;
    21102160
Note: See TracChangeset for help on using the changeset viewer.