Changeset 115 for trunk/src/sh_suidchk.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_suidchk.c

    r114 r115  
    831831  struct stat     buf;
    832832  int             status;
     833  int             fflags;
    833834  char          * fs;
    834835  long            sl_status = SL_ENONE;
     
    910911      ++FileLimTotal;
    911912
     913      /* Rate limit (Fps == Files per second)
     914       */
    912915      if ((ShSuidchkFps > 0 && FileLimNum > ShSuidchkFps && FileLimTotal > 0)&&
    913916          (ShSuidchkYield == S_FALSE))
     
    995998              else
    996999                {
    997                   if (sh.flag.update == S_TRUE &&
     1000
     1001                  if ( sh.flag.update   == S_TRUE &&
    9981002                      (sh.flag.checkSum == SH_CHECK_INIT  ||
    9991003                       sh.flag.checkSum == SH_CHECK_CHECK))
    10001004                    {
     1005                      /* Updating database. Report new files that
     1006                       * are not in database already. Then compare
     1007                       * to database and report changes.
     1008                       */
    10011009                      if (-1 == sh_hash_have_it (tmpcat))
    10021010                        {
     
    10171025                          sh_hash_pushdata_memory (&theFile, fileHash);
    10181026                        }
     1027                     
     1028                      sh_hash_addflag(tmpcat, SH_FFLAG_SUIDCHK);
     1029                     
    10191030                    }
     1031
    10201032                  else if (sh.flag.checkSum == SH_CHECK_INIT  &&
    10211033                           sh.flag.update == S_FALSE )
    10221034                    {
     1035                      /* Running init. Report on files detected.
     1036                       */
    10231037                      sh_hash_pushdata (&theFile, fileHash);
    10241038                      sh_error_handle ((-1), FIL__, __LINE__,
    10251039                                       0, MSG_SUID_FOUND, tmp );
    10261040                    }
     1041
    10271042                  else if (sh.flag.checkSum == SH_CHECK_CHECK )
    10281043                    {
     1044                      /* Running file check. Report on new files
     1045                       * detected, and quarantine them.
     1046                       */
    10291047                      sh_error_handle (SH_ERR_ALL, FIL__, __LINE__,
    10301048                                       0, MSG_SUID_FOUND, tmp );
    1031                       if (-1 == sh_hash_have_it (tmpcat))
     1049
     1050                      fflags = sh_hash_getflags(tmpcat);
     1051
     1052                      if ( (-1 == fflags) || (!SH_FFLAG_SUIDCHK_SET(fflags)))
    10321053                        {
    1033                           report_file(tmpcat, &theFile, timestrc, timestra, timestrm);
     1054                          if (-1 == fflags)
     1055                            report_file(tmpcat, &theFile, timestrc, timestra, timestrm);
    10341056
    10351057                          /* Quarantine file according to configured method
     
    10631085                                                       _("[SuidCheck]"),
    10641086                                                       ShSuidchkSeverity);
     1087
     1088                              sh_hash_addflag(tmpcat, SH_FFLAG_SUIDCHK);
     1089
    10651090                            }
    10661091                        }
    10671092                      else
    10681093                        {
     1094                          /* File exists. Check for modifications.
     1095                           */
    10691096                          (void) sh_hash_compdata (SH_LEVEL_READONLY,
    10701097                                                   &theFile, fileHash,
    10711098                                                   _("[SuidCheck]"),
    10721099                                                   ShSuidchkSeverity);
     1100                         
     1101                          sh_hash_addflag(tmpcat, SH_FFLAG_SUIDCHK);
     1102
    10731103                        }
    10741104                    }
Note: See TracChangeset for help on using the changeset viewer.