オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Diff of /trunk/1.5.x/ccs-patch/fs/ccs_common.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 183 by kumaneko, Wed Apr 18 05:36:07 2007 UTC revision 206 by kumaneko, Tue May 8 11:18:36 2007 UTC
# Line 160  int IsCorrectPath(const char *filename, Line 160  int IsCorrectPath(const char *filename,
160                          case 'X':   /* "\X" */                          case 'X':   /* "\X" */
161                          case 'a':   /* "\a" */                          case 'a':   /* "\a" */
162                          case 'A':   /* "\A" */                          case 'A':   /* "\A" */
163                            case '-':   /* "\-" */
164                                  if (pattern_type == -1) break; /* Must not contain pattern */                                  if (pattern_type == -1) break; /* Must not contain pattern */
165                                  contains_pattern = 1;                                  contains_pattern = 1;
166                                  continue;                                  continue;
# Line 280  void fill_path_info(struct path_info *pt Line 281  void fill_path_info(struct path_info *pt
281          ptr->depth = PathDepth(name);          ptr->depth = PathDepth(name);
282  }  }
283    
284  static int FileMatchesToPattern(const char *filename, const char *filename_end, const char *pattern, const char *pattern_end)  static int FileMatchesToPattern2(const char *filename, const char *filename_end, const char *pattern, const char *pattern_end)
285  {  {
286          while (filename < filename_end && pattern < pattern_end) {          while (filename < filename_end && pattern < pattern_end) {
287                  if (*pattern != '\\') {                  if (*pattern != '\\') {
# Line 332  static int FileMatchesToPattern(const ch Line 333  static int FileMatchesToPattern(const ch
333                                  {                                  {
334                                          int i;                                          int i;
335                                          for (i = 0; i <= filename_end - filename; i++) {                                          for (i = 0; i <= filename_end - filename; i++) {
336                                                  if (FileMatchesToPattern(filename + i, filename_end, pattern + 1, pattern_end)) return 1;                                                  if (FileMatchesToPattern2(filename + i, filename_end, pattern + 1, pattern_end)) return 1;
337                                                  if ((c = filename[i]) == '.' && *pattern == '@') break;                                                  if ((c = filename[i]) == '.' && *pattern == '@') break;
338                                                  if (c == '\\') {                                                  if (c == '\\') {
339                                                          if ((c = filename[i + 1]) == '\\') {                                                          if ((c = filename[i + 1]) == '\\') {
# Line 357  static int FileMatchesToPattern(const ch Line 358  static int FileMatchesToPattern(const ch
358                                                  while (((c = filename[j]) >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) j++;                                                  while (((c = filename[j]) >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) j++;
359                                          }                                          }
360                                          for (i = 1; i <= j; i++) {                                          for (i = 1; i <= j; i++) {
361                                                  if (FileMatchesToPattern(filename + i, filename_end, pattern + 1, pattern_end)) return 1;                                                  if (FileMatchesToPattern2(filename + i, filename_end, pattern + 1, pattern_end)) return 1;
362                                          }                                          }
363                                  }                                  }
364                                  return 0; /* Not matched or bad pattern. */                                  return 0; /* Not matched or bad pattern. */
# Line 370  static int FileMatchesToPattern(const ch Line 371  static int FileMatchesToPattern(const ch
371          return (filename == filename_end && pattern == pattern_end);          return (filename == filename_end && pattern == pattern_end);
372  }  }
373    
374    static int FileMatchesToPattern(const char *filename, const char *filename_end, const char *pattern, const char *pattern_end)
375    {
376            const char *pattern_start = pattern;
377            int first = 1;
378            int result;
379            while (pattern < pattern_end - 1) {
380                    if (*pattern++ != '\\' || *pattern++ != '-') continue;
381                    result = FileMatchesToPattern2(filename, filename_end, pattern_start, pattern - 2);
382                    if (first) result = !result;
383                    if (result) return 0;
384                    first = 0;
385                    pattern_start = pattern;
386            }
387            result = FileMatchesToPattern2(filename, filename_end, pattern_start, pattern_end);
388            return first ? result : !result;
389    }
390    
391  /*  /*
392   *  Check whether the given pathname matches to the given pattern.   *  Check whether the given pathname matches to the given pattern.
393   *  Returns nonzero if matches, zero otherwise.   *  Returns nonzero if matches, zero otherwise.
# Line 386  static int FileMatchesToPattern(const ch Line 404  static int FileMatchesToPattern(const ch
404   *    \x     1 hexadecimal digit.   *    \x     1 hexadecimal digit.
405   *    \A     More than or equals to 1 alphabet character.   *    \A     More than or equals to 1 alphabet character.
406   *    \a     1 alphabet character.   *    \a     1 alphabet character.
407     *    \-     Subtraction operator.
408   */   */
409    
410  int PathMatchesToPattern(const struct path_info *pathname0, const struct path_info *pattern0)  int PathMatchesToPattern(const struct path_info *pathname0, const struct path_info *pattern0)
# Line 1187  void CCS_LoadPolicy(const char *filename Line 1206  void CCS_LoadPolicy(const char *filename
1206          }          }
1207    
1208  #ifdef CONFIG_SAKURA  #ifdef CONFIG_SAKURA
1209          printk("SAKURA: 1.4   2007/04/01\n");          printk("SAKURA: 1.4+   2007/05/07\n");
1210  #endif  #endif
1211  #ifdef CONFIG_TOMOYO  #ifdef CONFIG_TOMOYO
1212          printk("TOMOYO: 1.4+   2007/04/18\n");          printk("TOMOYO: 1.4+   2007/05/07\n");
1213  #endif  #endif
1214          if (!profile_loaded) panic("No profiles loaded. Run policy loader using 'init=' option.\n");          if (!profile_loaded) panic("No profiles loaded. Run policy loader using 'init=' option.\n");
1215          printk("Mandatory Access Control activated.\n");          printk("Mandatory Access Control activated.\n");

Legend:
Removed from v.183  
changed lines
  Added in v.206

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26