Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_files.c

    r20 r27  
    7272#define FIL__  _("sh_files.c")
    7373
    74 extern int safe_logger (int signal, int method, pid_t thepid);
    75 
    7674extern int flag_err_debug;
    7775extern int flag_err_info;
    7876
    79 int sh_files_reportonce(char * c)
     77int sh_files_reportonce(const char * c)
    8078{
    8179  int i;
     
    8684}
    8785   
    88 int sh_files_fulldetail(char * c)
     86int sh_files_fulldetail(const char * c)
    8987{
    9088  int i;
     
    156154static int        sh_files_fullpath  (char * testdir, char * d_name,
    157155                                      char * statpath);
    158 static int        sh_files_pushdir   (int class, char * str_s);
    159 static int        sh_files_pushfile  (int class, char * str_s);
     156static int        sh_files_pushdir   (int class, const char * str_s);
     157static int        sh_files_pushfile  (int class, const char * str_s);
    160158static int        sh_files_checkdir  (int class, int rdepth, char * dirName,
    161159                                      char * relativeName);
     
    446444
    447445
    448 int sh_files_pushfile_prelink (char * str_s)
     446int sh_files_pushfile_prelink (const char * str_s)
    449447{
    450448  return (sh_files_pushfile (SH_LEVEL_PRELINK, str_s));
    451449}
    452450
    453 int sh_files_pushfile_user0 (char * str_s)
     451int sh_files_pushfile_user0 (const char * str_s)
    454452{
    455453  return (sh_files_pushfile (SH_LEVEL_USER0, str_s));
    456454}
    457455
    458 
    459 int sh_files_pushfile_user1 (char * str_s)
     456int sh_files_pushfile_user1 (const char * str_s)
    460457{
    461458  return (sh_files_pushfile (SH_LEVEL_USER1, str_s));
    462459}
    463460
    464 
    465 int sh_files_pushfile_ro (char * str_s)
     461int sh_files_pushfile_user2 (const char * str_s)
     462{
     463  return (sh_files_pushfile (SH_LEVEL_USER2, str_s));
     464}
     465
     466int sh_files_pushfile_user3 (const char * str_s)
     467{
     468  return (sh_files_pushfile (SH_LEVEL_USER3, str_s));
     469}
     470
     471int sh_files_pushfile_user4 (const char * str_s)
     472{
     473  return (sh_files_pushfile (SH_LEVEL_USER4, str_s));
     474}
     475
     476
     477int sh_files_pushfile_ro (const char * str_s)
    466478{
    467479  return (sh_files_pushfile (SH_LEVEL_READONLY, str_s));
    468480}
    469481
    470 int sh_files_pushfile_attr (char * str_s)
     482int sh_files_pushfile_attr (const char * str_s)
    471483{
    472484  return (sh_files_pushfile (SH_LEVEL_ATTRIBUTES, str_s));
    473485}
    474486
    475 int sh_files_pushfile_log (char * str_s)
     487int sh_files_pushfile_log (const char * str_s)
    476488{
    477489  return (sh_files_pushfile (SH_LEVEL_LOGFILES, str_s));
    478490}
    479491
    480 int sh_files_pushfile_glog (char * str_s)
     492int sh_files_pushfile_glog (const char * str_s)
    481493{
    482494  return (sh_files_pushfile (SH_LEVEL_LOGGROW, str_s));
    483495}
    484496
    485 int sh_files_pushfile_noig (char * str_s)
     497int sh_files_pushfile_noig (const char * str_s)
    486498{
    487499  return (sh_files_pushfile (SH_LEVEL_NOIGNORE, str_s));
    488500}
    489501
    490 int sh_files_pushfile_allig (char * str_s)
     502int sh_files_pushfile_allig (const char * str_s)
    491503{
    492504  return (sh_files_pushfile (SH_LEVEL_ALLIGNORE, str_s));
     
    511523/* set mask(class)
    512524 */
    513 static int sh_files_parse_mask (unsigned long * mask, char * str)
     525static int sh_files_parse_mask (unsigned long * mask, const char * str)
    514526{
    515527  int l, i = 0, act = 0, k = 0;
     
    602614}
    603615
    604 int sh_files_redef_prelink(char * str)
     616int sh_files_redef_prelink(const char * str)
    605617{
    606618  return (sh_files_parse_mask(&mask_PRELINK, str));
    607619}
    608 int sh_files_redef_user0(char * str)
     620int sh_files_redef_user0(const char * str)
    609621{
    610622  return (sh_files_parse_mask(&mask_USER0, str));
    611623}
    612 int sh_files_redef_user1(char * str)
     624int sh_files_redef_user1(const char * str)
    613625{
    614626  return (sh_files_parse_mask(&mask_USER1, str));
    615627}
    616 int sh_files_redef_readonly(char * str)
     628int sh_files_redef_user2(const char * str)
     629{
     630  return (sh_files_parse_mask(&mask_USER2, str));
     631}
     632int sh_files_redef_user3(const char * str)
     633{
     634  return (sh_files_parse_mask(&mask_USER3, str));
     635}
     636int sh_files_redef_user4(const char * str)
     637{
     638  return (sh_files_parse_mask(&mask_USER4, str));
     639}
     640int sh_files_redef_readonly(const char * str)
    617641{
    618642  return (sh_files_parse_mask(&mask_READONLY, str));
    619643}
    620 int sh_files_redef_loggrow(char * str)
     644int sh_files_redef_loggrow(const char * str)
    621645{
    622646  return (sh_files_parse_mask(&mask_LOGGROW, str));
    623647}
    624 int sh_files_redef_logfiles(char * str)
     648int sh_files_redef_logfiles(const char * str)
    625649{
    626650  return (sh_files_parse_mask(&mask_LOGFILES, str));
    627651}
    628 int sh_files_redef_attributes(char * str)
     652int sh_files_redef_attributes(const char * str)
    629653{
    630654  return (sh_files_parse_mask(&mask_ATTRIBUTES, str));
    631655}
    632 int sh_files_redef_noignore(char * str)
     656int sh_files_redef_noignore(const char * str)
    633657{
    634658  return (sh_files_parse_mask(&mask_NOIGNORE, str));
    635659}
    636 int sh_files_redef_allignore(char * str)
     660int sh_files_redef_allignore(const char * str)
    637661{
    638662  return (sh_files_parse_mask(&mask_ALLIGNORE, str));
     
    659683    case SH_LEVEL_USER1:
    660684      return (unsigned long) mask_USER1;
     685    case SH_LEVEL_USER2:
     686      return (unsigned long) mask_USER2;
     687    case SH_LEVEL_USER3:
     688      return (unsigned long) mask_USER3;
     689    case SH_LEVEL_USER4:
     690      return (unsigned long) mask_USER4;
    661691    case SH_LEVEL_PRELINK:
    662692      return (unsigned long) mask_PRELINK;
     
    725755      if (zfileList == NULL)
    726756        {
    727           (void) safe_logger (0, 0, getpid());
     757          (void) safe_logger (0, 0, NULL);
    728758          aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    729759        }
     
    734764  if (-1 == ret)
    735765    {
    736       (void) safe_logger (0, 0, getpid());
     766      (void) safe_logger (0, 0, NULL);
    737767      aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    738768    }
     
    745775
    746776
    747 static int sh_files_pushfile (int class, char * str_s)
    748 {
     777static int sh_files_pushfile (int class, const char * str_s)
     778{
     779  int     len;
    749780  char  * tmp;
    750   int     len;
     781  char  * p;
    751782#ifdef HAVE_GLOB_H
    752   glob_t  pglob;
    753783  int     globstatus = -1;
    754784  unsigned int     gloop;
     785  glob_t  pglob;
    755786#endif
    756787
     
    808839       * special case of the root directory.
    809840       */
    810       if (str_s[len-1] == '/' && len > 1)
     841      p = sh_util_strdup (str_s);
     842      if (p[len-1] == '/' && len > 1)
    811843        {
    812           str_s[len-1] = '\0';
     844          p[len-1] = '\0';
    813845          --len;
    814846        }
     
    817849
    818850#ifdef HAVE_GLOB_H
    819   if (0 == sh_files_has_metachar(str_s))
    820     {
    821       sh_files_push_file_int (class, str_s, len);
     851  if (0 == sh_files_has_metachar(p))
     852    {
     853      sh_files_push_file_int (class, p, len);
    822854    }
    823855  else
    824856    {
    825857      pglob.gl_offs = 0;
    826       globstatus    = glob (str_s, 0, sh_files_globerr, &pglob);
     858      globstatus    = glob (p, 0, sh_files_globerr, &pglob);
    827859
    828860      if (globstatus == 0 && pglob.gl_pathc > 0)
     
    834866      else
    835867        {
    836           tmp = sh_util_safe_name (str_s);
     868          tmp = sh_util_safe_name (p);
    837869
    838870          if (pglob.gl_pathc == 0
     
    869901
    870902#else
    871   sh_files_push_file_int (class, str_s, len);
    872 #endif
    873 
     903  sh_files_push_file_int (class, p, len);
     904#endif
     905
     906  SH_FREE(p);
    874907  SL_RETURN((0),_("sh_files_pushfile"));
    875908}
     
    10281061}
    10291062
    1030 int sh_files_pushdir_prelink (char * str_s)
     1063int sh_files_pushdir_prelink (const char * str_s)
    10311064{
    10321065  return (sh_files_pushdir (SH_LEVEL_PRELINK, str_s));
    10331066}
    10341067
    1035 int sh_files_pushdir_user0 (char * str_s)
     1068int sh_files_pushdir_user0 (const char * str_s)
    10361069{
    10371070  return (sh_files_pushdir (SH_LEVEL_USER0, str_s));
    10381071}
    10391072
    1040 int sh_files_pushdir_user1 (char * str_s)
     1073int sh_files_pushdir_user1 (const char * str_s)
    10411074{
    10421075  return (sh_files_pushdir (SH_LEVEL_USER1, str_s));
    10431076}
    10441077
    1045 int sh_files_pushdir_attr (char * str_s)
     1078int sh_files_pushdir_user2 (const char * str_s)
     1079{
     1080  return (sh_files_pushdir (SH_LEVEL_USER2, str_s));
     1081}
     1082
     1083int sh_files_pushdir_user3 (const char * str_s)
     1084{
     1085  return (sh_files_pushdir (SH_LEVEL_USER3, str_s));
     1086}
     1087
     1088int sh_files_pushdir_user4 (const char * str_s)
     1089{
     1090  return (sh_files_pushdir (SH_LEVEL_USER4, str_s));
     1091}
     1092
     1093int sh_files_pushdir_attr (const char * str_s)
    10461094{
    10471095  return (sh_files_pushdir (SH_LEVEL_ATTRIBUTES, str_s));
    10481096}
    10491097
    1050 int sh_files_pushdir_ro (char * str_s)
     1098int sh_files_pushdir_ro (const char * str_s)
    10511099{
    10521100  return (sh_files_pushdir (SH_LEVEL_READONLY, str_s));
    10531101}
    10541102
    1055 int sh_files_pushdir_log (char * str_s)
     1103int sh_files_pushdir_log (const char * str_s)
    10561104{
    10571105  return (sh_files_pushdir (SH_LEVEL_LOGFILES, str_s));
    10581106}
    10591107
    1060 int sh_files_pushdir_glog (char * str_s)
     1108int sh_files_pushdir_glog (const char * str_s)
    10611109{
    10621110  return (sh_files_pushdir (SH_LEVEL_LOGGROW, str_s));
    10631111}
    10641112
    1065 int sh_files_pushdir_noig (char * str_s)
     1113int sh_files_pushdir_noig (const char * str_s)
    10661114{
    10671115  return (sh_files_pushdir (SH_LEVEL_NOIGNORE, str_s));
    10681116}
    10691117
    1070 int sh_files_pushdir_allig (char * str_s)
     1118int sh_files_pushdir_allig (const char * str_s)
    10711119{
    10721120  return (sh_files_pushdir (SH_LEVEL_ALLIGNORE, str_s));
     
    11201168      if (tree == NULL)
    11211169        {
    1122           (void) safe_logger (0, 0, getpid());
     1170          (void) safe_logger (0, 0, NULL);
    11231171          aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    11241172        }
     
    11331181  if (-1 == ret)
    11341182    {
    1135       (void) safe_logger (0, 0, getpid());
     1183      (void) safe_logger (0, 0, NULL);
    11361184      aud__exit(FIL__, __LINE__, EXIT_FAILURE);
    11371185    }
     
    11431191}
    11441192
    1145 static int sh_files_pushdir (int class, char * str_s)
     1193static int sh_files_pushdir (int class, const char * str_s)
    11461194{
    11471195  char  * tmp;
     
    11491197  int     rdepth = 0;
    11501198  char  * tail = NULL;
     1199  char  * p;
    11511200
    11521201#ifdef HAVE_GLOB_H
     
    11661215    SL_RETURN((-1), _("sh_files_pushdir"));
    11671216 
    1168 
    1169   if (str_s[0] != '/')
    1170     {
    1171       rdepth = strtol(str_s, &tail, 10);
    1172       if (tail == str_s)
    1173         SL_RETURN((-1), _("sh_files_pushdir"));
     1217  p = sh_util_strdup (str_s);
     1218
     1219  if (p[0] != '/')
     1220    {
     1221      rdepth = strtol(p, &tail, 10);
     1222      if (tail == p)
     1223        {
     1224          SH_FREE(p);
     1225          SL_RETURN((-1), _("sh_files_pushdir"));
     1226        }
    11741227    }
    11751228  else
    1176     tail   = str_s;
     1229    tail   = p;
    11771230 
    11781231
    1179   if (rdepth < (-1) || tail == str_s || rdepth > 99)
     1232  if (rdepth < (-1) || tail == p || rdepth > 99)
    11801233    rdepth = (-2);
    11811234
     
    11881241                       tmp);
    11891242      SH_FREE(tmp);
     1243      SH_FREE(p);
    11901244      SL_RETURN((-1), _("sh_files_pushdir"));
    11911245    }
    11921246  else if (len < 1)
    11931247    {
     1248      SH_FREE(p);
    11941249      SL_RETURN((-1), _("sh_files_pushdir"));
    11951250    }
     
    12001255                       tmp);
    12011256      SH_FREE(tmp);
     1257      SH_FREE(p);
    12021258      SL_RETURN((-1), _("sh_files_pushdir"));
    12031259    }
     
    12681324#endif
    12691325
     1326  SH_FREE(p);
    12701327  SL_RETURN((0), _("sh_files_pushdir"));
    12711328
     
    13221379/* Simply sets our boolean as to whether this check is active
    13231380 */
    1324 int sh_files_check_hardlinks (char * opt)
     1381int sh_files_check_hardlinks (const char * opt)
    13251382{
    13261383  int i;
     
    13381395static struct sh_hle_struct * sh_hl_exc = NULL;
    13391396
    1340 int sh_files_hle_reg (char * str)
     1397int sh_files_hle_reg (const char * str)
    13411398{
    13421399  long   offset;
Note: See TracChangeset for help on using the changeset viewer.