Changeset 381 for trunk/src


Ignore:
Timestamp:
Dec 2, 2011, 11:18:23 PM (13 years ago)
Author:
katerina
Message:

Fix for ticket #279 (checksum flip with --enable-suidcheck).

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_files.c

    r378 r381  
    697697  SL_ENTER(_("sh_files_parse_mask"));
    698698
     699  myword[0] = '\0';
     700
    699701  if (str == NULL)
    700702    {
     
    705707
    706708  while (i < l) {
     709
    707710    if (str[i] == '\0')
    708711      break;
     712
    709713    if (str[i] == ' ' || str[i] == '\t' || str[i] == ',')
    710714      {
     
    716720      {
    717721        act = +1; ++i;
    718         continue;
     722        myword[0] = '\0';
     723        goto getword;
    719724      }
    720725    else if (str[i] == '-')
    721726      {
    722727        act = -1; ++i;
    723         continue;
     728        myword[0] = '\0';
     729        goto getword;
    724730      }
    725731    else /* a word */
    726732      {
     733      getword:
    727734        k = 0;
    728735        while (k < 63 && str[i] != ' ' && str[i] != '\t' && str[i] != ','
     
    733740        myword[k] = '\0';
    734741
     742        if (sl_strlen(myword) == 0)
     743          {
     744            SL_RETURN ( (-1), _("sh_files_parse_mask"));
     745          }
     746
    735747/* checksum     */
    736         if (0 == strncmp(myword, _("CHK"), 3))
     748        if      (0 == strcmp(myword, _("CHK")))
    737749          sh_files_set_mask (mask, MODI_CHK, act);
    738750/* link         */
    739         if (0 == strncmp(myword, _("LNK"), 3))
     751        else if (0 == strcmp(myword, _("LNK")))
    740752          sh_files_set_mask (mask, MODI_LNK, act);
    741753/* inode        */
    742         if (0 == strncmp(myword, _("RDEV"), 3))
     754        else if (0 == strcmp(myword, _("RDEV")))
    743755          sh_files_set_mask (mask, MODI_RDEV, act);
    744756/* inode        */
    745         if (0 == strncmp(myword, _("INO"), 3))
     757        else if (0 == strcmp(myword, _("INO")))
    746758          sh_files_set_mask (mask, MODI_INO, act);
    747759/* user         */
    748         if (0 == strncmp(myword, _("USR"), 3))
     760        else if (0 == strcmp(myword, _("USR")))
    749761          sh_files_set_mask (mask, MODI_USR, act);
    750762/* group        */
    751         if (0 == strncmp(myword, _("GRP"), 3))
     763        else if (0 == strcmp(myword, _("GRP")))
    752764          sh_files_set_mask (mask, MODI_GRP, act);
    753765/* mtime        */
    754         if (0 == strncmp(myword, _("MTM"), 3))
     766        else if (0 == strcmp(myword, _("MTM")))
    755767          sh_files_set_mask (mask, MODI_MTM, act);
    756768/* ctime        */
    757         if (0 == strncmp(myword, _("CTM"), 3))
     769        else if (0 == strcmp(myword, _("CTM")))
    758770          sh_files_set_mask (mask, MODI_CTM, act);
    759771/* atime        */
    760         if (0 == strncmp(myword, _("ATM"), 3))
     772        else if (0 == strcmp(myword, _("ATM")))
    761773          sh_files_set_mask (mask, MODI_ATM, act);
    762774/* size         */
    763         if (0 == strncmp(myword, _("SIZ"), 3))
     775        else if (0 == strcmp(myword, _("SIZ")))
    764776          sh_files_set_mask (mask, MODI_SIZ, act);
    765777/* file mode    */
    766         if (0 == strncmp(myword, _("MOD"), 3))
     778        else if (0 == strcmp(myword, _("MOD")))
    767779          sh_files_set_mask (mask, MODI_MOD, act);
    768780/* hardlinks    */
    769         if (0 == strncmp(myword, _("HLN"), 3))
     781        else if (0 == strcmp(myword, _("HLN")))
    770782          sh_files_set_mask (mask, MODI_HLN, act);
    771783/* size may grow */
    772         if (0 == strncmp(myword, _("GROW"), 3))
     784        else if (0 == strcmp(myword, _("SGROW")))
    773785          sh_files_set_mask (mask, MODI_SGROW, act);
    774786/* use prelink */
    775         if (0 == strncmp(myword, _("PRE"), 3))
     787        else if (0 == strcmp(myword, _("PRE")))
    776788          sh_files_set_mask (mask, MODI_PREL, act);
    777789/* get content */
    778         if (0 == strncmp(myword, _("TXT"), 3))
     790        else if (0 == strcmp(myword, _("TXT")))
    779791          sh_files_set_mask (mask, MODI_TXT, act);
    780792/* get content */
    781         if (0 == strncmp(myword, _("AUDIT"), 3))
     793        else if (0 == strcmp(myword, _("AUDIT")))
    782794          sh_files_set_mask (mask, MODI_AUDIT, act);
     795        else
     796          {
     797            SL_RETURN ( (-1), _("sh_files_parse_mask"));
     798          }
     799        act       = 0;
     800        myword[0] = '\0';
    783801      }
    784802  }
     
    840858    {
    841859    case SH_LEVEL_READONLY:
    842       return (unsigned long) mask_READONLY;
     860      return (unsigned long) (mask_READONLY | MODI_INIT);
    843861    case SH_LEVEL_ATTRIBUTES:
    844       return (unsigned long) mask_ATTRIBUTES;
     862      return (unsigned long) (mask_ATTRIBUTES | MODI_INIT);
    845863    case SH_LEVEL_LOGFILES:
    846       return (unsigned long) mask_LOGFILES;
     864      return (unsigned long) (mask_LOGFILES | MODI_INIT);
    847865    case SH_LEVEL_LOGGROW:
    848       return (unsigned long) mask_LOGGROW;
     866      return (unsigned long) (mask_LOGGROW | MODI_INIT);
    849867    case SH_LEVEL_ALLIGNORE:
    850       return (unsigned long) mask_ALLIGNORE;
     868      return (unsigned long) (mask_ALLIGNORE | MODI_INIT);
    851869    case SH_LEVEL_NOIGNORE:
    852       return (unsigned long) mask_NOIGNORE;
     870      return (unsigned long) (mask_NOIGNORE | MODI_INIT);
    853871    case SH_LEVEL_USER0:
    854       return (unsigned long) mask_USER0;
     872      return (unsigned long) (mask_USER0 | MODI_INIT);
    855873    case SH_LEVEL_USER1:
    856       return (unsigned long) mask_USER1;
     874      return (unsigned long) (mask_USER1 | MODI_INIT);
    857875    case SH_LEVEL_USER2:
    858       return (unsigned long) mask_USER2;
     876      return (unsigned long) (mask_USER2 | MODI_INIT);
    859877    case SH_LEVEL_USER3:
    860       return (unsigned long) mask_USER3;
     878      return (unsigned long) (mask_USER3 | MODI_INIT);
    861879    case SH_LEVEL_USER4:
    862       return (unsigned long) mask_USER4;
     880      return (unsigned long) (mask_USER4 | MODI_INIT);
    863881    case SH_LEVEL_PRELINK:
    864       return (unsigned long) mask_PRELINK;
     882      return (unsigned long) (mask_PRELINK | MODI_INIT);
    865883    default:
    866884      return (unsigned long) 0;
     
    907925#endif
    908926
    909 int sh_files_push_file_int (int class, const char * str_s, size_t len)
     927int sh_files_push_file_int (int class, const char * str_s, size_t len, unsigned long check_mask)
    910928{
    911929  dirstack_t * new_item_ptr;
     
    923941  new_item_ptr->name           = fileName;
    924942  new_item_ptr->class          = class;
    925   new_item_ptr->check_mask     = sh_files_maskof(class);
     943  new_item_ptr->check_mask     = check_mask;
    926944  new_item_ptr->rdepth         = 0;
    927945  new_item_ptr->checked        = S_FALSE;
     
    9821000}
    9831001
    984 int sh_files_push_dir_int (int class, char * tail, size_t len, int rdepth);
     1002int sh_files_push_dir_int (int class, char * tail, size_t len, int rdepth, unsigned long check_mask);
    9851003
    9861004#ifdef HAVE_GLOB_H
     
    10051023
    10061024  int     count = 0;
    1007   volatile unsigned long check_mask = check_mask_in;
     1025  volatile unsigned long check_mask = (flag == 0) ? sh_files_maskof(class) : check_mask_in;
    10081026 
    10091027  SL_ENTER(_("sh_files_pushglob"));
     
    10281046          new_item_ptr->name           = fileName;
    10291047          new_item_ptr->class          = class;
    1030           new_item_ptr->check_mask     = (flag == 0) ? sh_files_maskof(class) : check_mask;
     1048          new_item_ptr->check_mask     = check_mask;
    10311049          new_item_ptr->rdepth         = rdepth;
    10321050          new_item_ptr->type           = type;
     
    10571075            {
    10581076              count += sh_files_push_file_int (class, pglob.gl_pathv[gloop],
    1059                                                sl_strlen(pglob.gl_pathv[gloop]));
     1077                                               sl_strlen(pglob.gl_pathv[gloop]), check_mask);
    10601078            }
    10611079          else
     
    10641082
    10651083              count += sh_files_push_dir_int  (class, pglob.gl_pathv[gloop],
    1066                                                sl_strlen(pglob.gl_pathv[gloop]), rdepth);
     1084                                               sl_strlen(pglob.gl_pathv[gloop]), rdepth, check_mask);
    10671085            }
    10681086        }
     
    12751293  if (0 == sh_files_has_metachar(p))
    12761294    {
    1277       sh_files_push_file_int (class, p, len);
     1295      sh_files_push_file_int (class, p, len, sh_files_maskof(class));
    12781296    }
    12791297  else
     
    12831301
    12841302#else
    1285   sh_files_push_file_int (class, p, len);
     1303  sh_files_push_file_int (class, p, len, sh_files_maskof(class));
    12861304#endif
    12871305
     
    15341552}
    15351553
    1536 int sh_files_push_dir_int (int class, char * tail, size_t len, int rdepth)
     1554int sh_files_push_dir_int (int class, char * tail, size_t len, int rdepth, unsigned long check_mask)
    15371555{
    15381556  zAVLTree   * tree;
     
    15501568  new_item_ptr->name           = dirName;
    15511569  new_item_ptr->class          = class;
    1552   new_item_ptr->check_mask     = sh_files_maskof(class);
     1570  new_item_ptr->check_mask     = check_mask;
    15531571  new_item_ptr->rdepth         = rdepth;
    15541572  new_item_ptr->checked        = S_FALSE;
     
    16001618  else
    16011619    {
    1602       unsigned long mask = sh_files_maskof(class);
    1603       if (MODI_AUDIT_ENABLED(mask))
     1620      if (MODI_AUDIT_ENABLED(check_mask))
    16041621        {
    16051622          sh_audit_mark(tail);
     
    17131730  if (0 == sh_files_has_metachar(tail))
    17141731    {
    1715       sh_files_push_dir_int (class, tail, len, rdepth);
     1732      sh_files_push_dir_int (class, tail, len, rdepth, sh_files_maskof(class));
    17161733    }
    17171734  else
     
    17201737    }
    17211738#else 
    1722   sh_files_push_dir_int (class, tail, len, rdepth);
     1739  sh_files_push_dir_int (class, tail, len, rdepth, sh_files_maskof(class));
    17231740#endif
    17241741
  • trunk/src/sh_suidchk.c

    r370 r381  
    11881188            int dummy;
    11891189            int class;
    1190             unsigned long check_mask;
     1190            unsigned long check_mask = 0;
    11911191
    11921192            theFile = SH_ALLOC(sizeof(file_type));
  • trunk/src/sh_unix.c

    r379 r381  
    36433643  SL_ENTER(_("sh_unix_getinfo"));
    36443644
     3645  if (!MODI_INITIALIZED(theFile->check_mask))
     3646    {
     3647      tmp2 = sh_util_safe_name (theFile->fullpath);
     3648      SH_MUTEX_LOCK(mutex_thread_nolog);
     3649      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_SUBGPATH,
     3650                       _("Uninitialized check mask"), _("sh_unix_getinfo"),
     3651                       tmp2);
     3652      SH_MUTEX_UNLOCK(mutex_thread_nolog);
     3653      SH_FREE(tmp2);
     3654    }
     3655
    36453656  /* Take the address to keep gcc from putting it into a register.
    36463657   * Avoids the 'clobbered by longjmp' warning.
     
    38083819              sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1);
    38093820            }
    3810           else if ((theFile->check_mask & MODI_PREL) != 0 && 
     3821          else if ((theFile->check_mask & MODI_PREL) != 0 &&
    38113822                   S_TRUE == sh_prelink_iself(rval_open, fbuf.st_size,
    38123823                                              alert_timeout, theFile->fullpath))
Note: See TracChangeset for help on using the changeset viewer.