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

Subversion リポジトリの参照

Diff of /trunk/1.7.x/ccs-patch/security/ccsecurity/util.c

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

revision 712 by kumaneko, Mon Nov 19 12:08:17 2007 UTC revision 853 by kumaneko, Wed Jan 2 07:32:11 2008 UTC
# Line 3  Line 3 
3   *   *
4   * Common functions for SAKURA and TOMOYO.   * Common functions for SAKURA and TOMOYO.
5   *   *
6   * Copyright (C) 2005-2007  NTT DATA CORPORATION   * Copyright (C) 2005-2008  NTT DATA CORPORATION
7   *   *
8   * Version: 1.5.2-pre   2007/11/19   * Version: 1.5.3-pre   2008/01/02
9   *   *
10   * This file is applicable to both 2.4.30 and 2.6.11 and later.   * This file is applicable to both 2.4.30 and 2.6.11 and later.
11   * See README.ccs for ChangeLog.   * See README.ccs for ChangeLog.
# Line 52  static const int lookup_flags = LOOKUP_F Line 52  static const int lookup_flags = LOOKUP_F
52  /*************************  VARIABLES  *************************/  /*************************  VARIABLES  *************************/
53    
54  /* /sbin/init started? */  /* /sbin/init started? */
55  int sbin_init_started = 0;  bool sbin_init_started = 0;
56    
57  const char *ccs_log_level = KERN_DEBUG;  const char *ccs_log_level = KERN_DEBUG;
58    
# Line 131  static void NormalizeLine(unsigned char Line 131  static void NormalizeLine(unsigned char
131   *  Check whether the given filename follows the naming rules.   *  Check whether the given filename follows the naming rules.
132   *  Returns nonzero if follows, zero otherwise.   *  Returns nonzero if follows, zero otherwise.
133   */   */
134  bool IsCorrectPath(const char *filename, const int start_type, const int pattern_type, const int end_type, const char *function)  bool IsCorrectPath(const char *filename, const s8 start_type, const s8 pattern_type, const s8 end_type, const char *function)
135  {  {
136          int contains_pattern = 0;          int contains_pattern = 0;
137          char c, d, e;          char c, d, e;
# Line 249  struct domain_info *FindDomain(const cha Line 249  struct domain_info *FindDomain(const cha
249          struct path_info domainname;          struct path_info domainname;
250          domainname.name = domainname0;          domainname.name = domainname0;
251          fill_path_info(&domainname);          fill_path_info(&domainname);
252          list_for_each_entry(domain, &domain_list, list) {          list1_for_each_entry(domain, &domain_list, list) {
253                  if (!domain->is_deleted && !pathcmp(&domainname, domain->domainname)) return domain;                  if (!domain->is_deleted && !pathcmp(&domainname, domain->domainname)) return domain;
254          }          }
255          return NULL;          return NULL;
# Line 473  int io_printf(struct io_buffer *head, co Line 473  int io_printf(struct io_buffer *head, co
473   */   */
474  const char *GetEXE(void)  const char *GetEXE(void)
475  {  {
476          if (current->mm) {          struct mm_struct *mm = current->mm;
477                  struct vm_area_struct *vma;          struct vm_area_struct *vma;
478                  for (vma = current->mm->mmap; vma; vma = vma->vm_next) {          const char *cp = NULL;
479                          if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file) {          if (!mm) return NULL;
480                                  return realpath_from_dentry(vma->vm_file->f_dentry, vma->vm_file->f_vfsmnt);          down_read(&mm->mmap_sem);
481                          }          for (vma = mm->mmap; vma; vma = vma->vm_next) {
482                    if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file) {
483                            cp = realpath_from_dentry(vma->vm_file->f_dentry, vma->vm_file->f_vfsmnt);
484                            break;
485                  }                  }
486          }          }
487          return NULL;          up_read(&mm->mmap_sem);
488            return cp;
489  }  }
490    
491  const char *GetMSG(const bool is_enforce)  const char *GetMSG(const bool is_enforce)
# Line 499  const char *GetAltExec(void) Line 503  const char *GetAltExec(void)
503  /*************************  DOMAIN POLICY HANDLER  *************************/  /*************************  DOMAIN POLICY HANDLER  *************************/
504    
505  /* Check whether the given access control is enabled. */  /* Check whether the given access control is enabled. */
506  unsigned int CheckCCSFlags(const unsigned int index)  unsigned int CheckCCSFlags(const u8 index)
507  {  {
508          const u8 profile = current->domain_info->profile;          const u8 profile = current->domain_info->profile;
509          return sbin_init_started && index < CCS_MAX_CONTROL_INDEX          return sbin_init_started && index < CCS_MAX_CONTROL_INDEX
# Line 508  unsigned int CheckCCSFlags(const unsigne Line 512  unsigned int CheckCCSFlags(const unsigne
512  #endif  #endif
513                  && profile_ptr[profile] ? profile_ptr[profile]->value[index] : 0;                  && profile_ptr[profile] ? profile_ptr[profile]->value[index] : 0;
514  }  }
 EXPORT_SYMBOL(CheckCCSFlags);  
515    
516  bool TomoyoVerboseMode(void)  bool TomoyoVerboseMode(void)
517  {  {
518          return CheckCCSFlags(CCS_TOMOYO_VERBOSE) != 0;          return CheckCCSFlags(CCS_TOMOYO_VERBOSE) != 0;
519  }  }
520    
 /* Check whether the given access control is enforce mode. */  
 bool CheckCCSEnforce(const unsigned int index)  
 {  
         return CheckCCSFlags(index) == 3;  
 }  
 EXPORT_SYMBOL(CheckCCSEnforce);  
   
521  bool CheckDomainQuota(struct domain_info * const domain)  bool CheckDomainQuota(struct domain_info * const domain)
522  {  {
523          unsigned int count = 0;          unsigned int count = 0;
524          struct acl_info *ptr;          struct acl_info *ptr;
525          if (!domain) return 1;          if (!domain) return 1;
526          list_for_each_entry(ptr, &domain->acl_info_list, list) {          list1_for_each_entry(ptr, &domain->acl_info_list, list) {
527                  if (!ptr->is_deleted) count++;                  if (!ptr->is_deleted) count++;
528          }          }
529          if (count < CheckCCSFlags(CCS_TOMOYO_MAX_ACCEPT_ENTRY)) return 1;          if (count < CheckCCSFlags(CCS_TOMOYO_MAX_ACCEPT_ENTRY)) return 1;
# Line 538  bool CheckDomainQuota(struct domain_info Line 534  bool CheckDomainQuota(struct domain_info
534          return 0;          return 0;
535  }  }
536    
 /* Check whether the given access control is learning mode. */  
 bool CheckCCSAccept(const unsigned int index, struct domain_info * const domain)  
 {  
         if (CheckCCSFlags(index) != 1) return 0;  
         return CheckDomainQuota(domain);  
 }  
 EXPORT_SYMBOL(CheckCCSAccept);  
   
537  static struct profile *FindOrAssignNewProfile(const unsigned int profile)  static struct profile *FindOrAssignNewProfile(const unsigned int profile)
538  {  {
539          static DEFINE_MUTEX(profile_lock);          static DEFINE_MUTEX(profile_lock);
# Line 563  static struct profile *FindOrAssignNewPr Line 551  static struct profile *FindOrAssignNewPr
551          return ptr;          return ptr;
552  }  }
553    
554    /* #define ALT_EXEC */
555    
556  static int SetProfile(struct io_buffer *head)  static int SetProfile(struct io_buffer *head)
557  {  {
558          char *data = head->write_buf;          char *data = head->write_buf;
# Line 585  static int SetProfile(struct io_buffer * Line 575  static int SetProfile(struct io_buffer *
575                  profile->comment = SaveName(cp + 1);                  profile->comment = SaveName(cp + 1);
576                  return 0;                  return 0;
577          }          }
578  #if 0  #ifdef ALT_EXEC
579  #ifdef CONFIG_TOMOYO  #ifdef CONFIG_TOMOYO
580          if (strcmp(data, ccs_control_array[CCS_TOMOYO_ALT_EXEC].keyword) == 0) {          if (strcmp(data, ccs_control_array[CCS_TOMOYO_ALT_EXEC].keyword) == 0) {
581                  cp++;                  cp++;
# Line 642  static int ReadProfile(struct io_buffer Line 632  static int ReadProfile(struct io_buffer
632                                  case CCS_TOMOYO_MAX_REJECT_LOG:                                  case CCS_TOMOYO_MAX_REJECT_LOG:
633                                  case CCS_TOMOYO_VERBOSE:                                  case CCS_TOMOYO_VERBOSE:
634  #endif  #endif
635    #ifndef ALT_EXEC
636                                  case CCS_TOMOYO_ALT_EXEC:                                  case CCS_TOMOYO_ALT_EXEC:
637                                  case CCS_SLEEP_PERIOD:                                  case CCS_SLEEP_PERIOD:
638    #endif
639                                          continue;                                          continue;
640                                  }                                  }
641                                  if (j == CCS_PROFILE_COMMENT) {                                  if (j == CCS_PROFILE_COMMENT) {
# Line 673  static int ReadProfile(struct io_buffer Line 665  static int ReadProfile(struct io_buffer
665  /*************************  POLICY MANAGER HANDLER  *************************/  /*************************  POLICY MANAGER HANDLER  *************************/
666    
667  struct policy_manager_entry {  struct policy_manager_entry {
668          struct list_head list;          struct list1_head list;
669          const struct path_info *manager;          const struct path_info *manager;
670          bool is_domain;          bool is_domain;
671          bool is_deleted;          bool is_deleted;
672  };  };
673    
674  static LIST_HEAD(policy_manager_list);  static LIST1_HEAD(policy_manager_list);
675    
676  static int AddManagerEntry(const char *manager, const bool is_delete)  static int AddManagerEntry(const char *manager, const bool is_delete)
677  {  {
# Line 697  static int AddManagerEntry(const char *m Line 689  static int AddManagerEntry(const char *m
689          }          }
690          if ((saved_manager = SaveName(manager)) == NULL) return -ENOMEM;          if ((saved_manager = SaveName(manager)) == NULL) return -ENOMEM;
691          mutex_lock(&lock);          mutex_lock(&lock);
692          list_for_each_entry(ptr, &policy_manager_list, list) {          list1_for_each_entry(ptr, &policy_manager_list, list) {
693                  if (ptr->manager == saved_manager) {                  if (ptr->manager == saved_manager) {
694                          ptr->is_deleted = is_delete;                          ptr->is_deleted = is_delete;
695                          error = 0;                          error = 0;
# Line 711  static int AddManagerEntry(const char *m Line 703  static int AddManagerEntry(const char *m
703          if ((new_entry = alloc_element(sizeof(*new_entry))) == NULL) goto out;          if ((new_entry = alloc_element(sizeof(*new_entry))) == NULL) goto out;
704          new_entry->manager = saved_manager;          new_entry->manager = saved_manager;
705          new_entry->is_domain = is_domain;          new_entry->is_domain = is_domain;
706          list_add_tail_mb(&new_entry->list, &policy_manager_list);          list1_add_tail_mb(&new_entry->list, &policy_manager_list);
707          error = 0;          error = 0;
708   out:   out:
709          mutex_unlock(&lock);          mutex_unlock(&lock);
# Line 733  static int AddManagerPolicy(struct io_bu Line 725  static int AddManagerPolicy(struct io_bu
725    
726  static int ReadManagerPolicy(struct io_buffer *head)  static int ReadManagerPolicy(struct io_buffer *head)
727  {  {
728          struct list_head *pos;          struct list1_head *pos;
729          if (head->read_eof) return 0;          if (head->read_eof) return 0;
730          if (!isRoot()) return -EPERM;          if (!isRoot()) return -EPERM;
731          list_for_each_cookie(pos, head->read_var2, &policy_manager_list) {          list1_for_each_cookie(pos, head->read_var2, &policy_manager_list) {
732                  struct policy_manager_entry *ptr;                  struct policy_manager_entry *ptr;
733                  ptr = list_entry(pos, struct policy_manager_entry, list);                  ptr = list1_entry(pos, struct policy_manager_entry, list);
734                  if (ptr->is_deleted) continue;                  if (ptr->is_deleted) continue;
735                  if (io_printf(head, "%s\n", ptr->manager->name)) return 0;                  if (io_printf(head, "%s\n", ptr->manager->name)) return 0;
736          }          }
# Line 754  static int IsPolicyManager(void) Line 746  static int IsPolicyManager(void)
746          const struct path_info *domainname = current->domain_info->domainname;          const struct path_info *domainname = current->domain_info->domainname;
747          bool found = 0;          bool found = 0;
748          if (!sbin_init_started) return 1;          if (!sbin_init_started) return 1;
749          list_for_each_entry(ptr, &policy_manager_list, list) {          list1_for_each_entry(ptr, &policy_manager_list, list) {
750                  if (!ptr->is_deleted && ptr->is_domain && !pathcmp(domainname, ptr->manager)) return 1;                  if (!ptr->is_deleted && ptr->is_domain && !pathcmp(domainname, ptr->manager)) return 1;
751          }          }
752          if ((exe = GetEXE()) == NULL) return 0;          if ((exe = GetEXE()) == NULL) return 0;
753          list_for_each_entry(ptr, &policy_manager_list, list) {          list1_for_each_entry(ptr, &policy_manager_list, list) {
754                  if (!ptr->is_deleted && !ptr->is_domain && !strcmp(exe, ptr->manager->name)) {                  if (!ptr->is_deleted && !ptr->is_domain && !strcmp(exe, ptr->manager->name)) {
755                          found = 1;                          found = 1;
756                          break;                          break;
# Line 850  static int AddDomainPolicy(struct io_buf Line 842  static int AddDomainPolicy(struct io_buf
842    
843  static int ReadDomainPolicy(struct io_buffer *head)  static int ReadDomainPolicy(struct io_buffer *head)
844  {  {
845          struct list_head *dpos;          struct list1_head *dpos;
846          struct list_head *apos;          struct list1_head *apos;
847          if (head->read_eof) return 0;          if (head->read_eof) return 0;
848          if (head->read_step == 0) {          if (head->read_step == 0) {
849                  if (!isRoot()) return -EPERM;                  if (!isRoot()) return -EPERM;
850                  head->read_step = 1;                  head->read_step = 1;
851          }          }
852          list_for_each_cookie(dpos, head->read_var1, &domain_list) {          list1_for_each_cookie(dpos, head->read_var1, &domain_list) {
853                  struct domain_info *domain;                  struct domain_info *domain;
854                  domain = list_entry(dpos, struct domain_info, list);                  domain = list1_entry(dpos, struct domain_info, list);
855                  if (head->read_step != 1) goto acl_loop;                  if (head->read_step != 1) goto acl_loop;
856                  if (domain->is_deleted) continue;                  if (domain->is_deleted) continue;
857                  if (io_printf(head, "%s\n" KEYWORD_USE_PROFILE "%u\n%s\n", domain->domainname->name, domain->profile, domain->quota_warned ? "quota_exceeded\n" : "")) return 0;                  if (io_printf(head, "%s\n" KEYWORD_USE_PROFILE "%u\n%s\n", domain->domainname->name, domain->profile, domain->quota_warned ? "quota_exceeded\n" : "")) return 0;
858                  head->read_step = 2;                  head->read_step = 2;
859          acl_loop: ;          acl_loop: ;
860                  if (head->read_step == 3) goto tail_mark;                  if (head->read_step == 3) goto tail_mark;
861                  list_for_each_cookie(apos, head->read_var2, &domain->acl_info_list) {                  list1_for_each_cookie(apos, head->read_var2, &domain->acl_info_list) {
862                          struct acl_info *ptr;                          struct acl_info *ptr;
863                          int pos;                          int pos;
864                          u8 acl_type;                          u8 acl_type;
865                          ptr = list_entry(apos, struct acl_info, list);                          ptr = list1_entry(apos, struct acl_info, list);
866                          if (ptr->is_deleted) continue;                          if (ptr->is_deleted) continue;
867                          pos = head->read_avail;                          pos = head->read_avail;
868                          acl_type = ptr->type;                          acl_type = ptr->type;
869                          if (acl_type == TYPE_FILE_ACL) {                          if (acl_type == TYPE_SINGLE_PATH_ACL) {
870                                  struct file_acl_record *ptr2 = container_of(ptr, struct file_acl_record, head);                                  struct single_acl_record *ptr2 = container_of(ptr, struct single_acl_record, head);
871                                  const unsigned char b = ptr2->u_is_group;                                  const bool b = ptr2->u_is_group;
872                                  if (io_printf(head, "%d %s%s", ptr2->perm,                                  const u16 perm = ptr2->perm;
873                                                b ? "@" : "",                                  u8 bit = head->read_bit;
874                                                b ? ptr2->u.group->group_name->name : ptr2->u.filename->name)) goto print_acl_rollback;                                  while (bit < MAX_SINGLE_PATH_OPERATION) {
875                                            if (perm & (1 << bit)) {
876                                                    pos = head->read_avail;
877                                                    if (io_printf(head, "allow_%s %s%s ", sp_operation2keyword(bit),
878                                                                  b ? "@" : "", b ? ptr2->u.group->group_name->name : ptr2->u.filename->name)
879                                                        || DumpCondition(head, ptr->cond)) {
880                                                            head->read_bit = bit;
881                                                            head->read_avail = pos;
882                                                            return 0;
883                                                    }
884                                            }
885                                            bit++;
886                                    }
887                                    head->read_bit = 0;
888                            } else if (acl_type == TYPE_DOUBLE_PATH_ACL) {
889                                    struct double_acl_record *ptr2 = container_of(ptr, struct double_acl_record, head);
890                                    const bool b0 = ptr2->u1_is_group, b1 = ptr2->u2_is_group;
891                                    const u8 perm = ptr2->perm;
892                                    u8 bit = head->read_bit;
893                                    while (bit < MAX_DOUBLE_PATH_OPERATION) {
894                                            if (perm & (1 << bit)) {
895                                                    pos = head->read_avail;
896                                                    if (io_printf(head, "allow_%s %s%s %s%s", dp_operation2keyword(bit),
897                                                                  b0 ? "@" : "", b0 ? ptr2->u1.group1->group_name->name : ptr2->u1.filename1->name,
898                                                                  b1 ? "@" : "", b1 ? ptr2->u2.group2->group_name->name : ptr2->u2.filename2->name)
899                                                        || DumpCondition(head, ptr->cond)) {
900                                                            head->read_bit = bit;
901                                                            head->read_avail = pos;
902                                                            return 0;
903                                                    }
904                                            }
905                                            bit++;
906                                    }
907                                    head->read_bit = 0;
908                          } else if (acl_type == TYPE_ARGV0_ACL) {                          } else if (acl_type == TYPE_ARGV0_ACL) {
909                                  struct argv0_acl_record *ptr2 = container_of(ptr, struct argv0_acl_record, head);                                  struct argv0_acl_record *ptr2 = container_of(ptr, struct argv0_acl_record, head);
910                                  if (io_printf(head, KEYWORD_ALLOW_ARGV0 "%s %s",                                  if (io_printf(head, KEYWORD_ALLOW_ARGV0 "%s %s",
# Line 889  static int ReadDomainPolicy(struct io_bu Line 914  static int ReadDomainPolicy(struct io_bu
914                                  if (io_printf(head, KEYWORD_ALLOW_ENV "%s", ptr2->env->name)) goto print_acl_rollback;                                  if (io_printf(head, KEYWORD_ALLOW_ENV "%s", ptr2->env->name)) goto print_acl_rollback;
915                          } else if (acl_type == TYPE_CAPABILITY_ACL) {                          } else if (acl_type == TYPE_CAPABILITY_ACL) {
916                                  struct capability_acl_record *ptr2 = container_of(ptr, struct capability_acl_record, head);                                  struct capability_acl_record *ptr2 = container_of(ptr, struct capability_acl_record, head);
917                                  if (io_printf(head, KEYWORD_ALLOW_CAPABILITY "%s", capability2keyword(ptr2->capability))) goto print_acl_rollback;                                  const u32 capability = ptr2->capability;
918                                    u8 bit = head->read_bit;
919                                    while (bit < TOMOYO_MAX_CAPABILITY_INDEX) {
920                                            if (capability & (1 << bit)) {
921                                                    pos = head->read_avail;
922                                                    if (io_printf(head, KEYWORD_ALLOW_CAPABILITY "%s", cap_operation2keyword(bit)) ||
923                                                        DumpCondition(head, ptr->cond)) {
924                                                            head->read_bit = bit;
925                                                            head->read_avail = pos;
926                                                            return 0;
927                                                    }
928                                            }
929                                            bit++;
930                                    }
931                                    head->read_bit = 0;
932                          } else if (acl_type == TYPE_IP_NETWORK_ACL) {                          } else if (acl_type == TYPE_IP_NETWORK_ACL) {
933                                  struct ip_network_acl_record *ptr2 = container_of(ptr, struct ip_network_acl_record, head);                                  struct ip_network_acl_record *ptr2 = container_of(ptr, struct ip_network_acl_record, head);
934                                  if (io_printf(head, KEYWORD_ALLOW_NETWORK "%s ", network2keyword(ptr2->operation_type))) goto print_acl_rollback;                                  if (io_printf(head, KEYWORD_ALLOW_NETWORK "%s ", net_operation2keyword(ptr2->operation_type))) goto print_acl_rollback;
935                                  switch (ptr2->record_type) {                                  switch (ptr2->record_type) {
936                                  case IP_RECORD_TYPE_ADDRESS_GROUP:                                  case IP_RECORD_TYPE_ADDRESS_GROUP:
937                                          if (io_printf(head, "@%s", ptr2->u.group->group_name->name)) goto print_acl_rollback;                                          if (io_printf(head, "@%s", ptr2->u.group->group_name->name)) goto print_acl_rollback;
# Line 907  static int ReadDomainPolicy(struct io_bu Line 946  static int ReadDomainPolicy(struct io_bu
946                                  case IP_RECORD_TYPE_IPv6:                                  case IP_RECORD_TYPE_IPv6:
947                                          {                                          {
948                                                  char buf[64];                                                  char buf[64];
949                                                  const u16 *min_address = ptr2->u.ipv6.min, *max_address = ptr2->u.ipv6.max;                                                  const struct in6_addr *min_address = ptr2->u.ipv6.min, *max_address = ptr2->u.ipv6.max;
950                                                  print_ipv6(buf, sizeof(buf), min_address);                                                  print_ipv6(buf, sizeof(buf), min_address);
951                                                  if (io_printf(head, "%s", buf)) goto print_acl_rollback;                                                  if (io_printf(head, "%s", buf)) goto print_acl_rollback;
952                                                  if (memcmp(min_address, max_address, 16)) {                                                  if (min_address != max_address) {
953                                                          print_ipv6(buf, sizeof(buf), max_address);                                                          print_ipv6(buf, sizeof(buf), max_address);
954                                                          if (io_printf(head, "-%s", buf)) goto print_acl_rollback;                                                          if (io_printf(head, "-%s", buf)) goto print_acl_rollback;
955                                                  }                                                  }
# Line 926  static int ReadDomainPolicy(struct io_bu Line 965  static int ReadDomainPolicy(struct io_bu
965                                  struct signal_acl_record *ptr2 = container_of(ptr, struct signal_acl_record, head);                                  struct signal_acl_record *ptr2 = container_of(ptr, struct signal_acl_record, head);
966                                  if (io_printf(head, KEYWORD_ALLOW_SIGNAL "%u %s", ptr2->sig, ptr2->domainname->name)) goto print_acl_rollback;                                  if (io_printf(head, KEYWORD_ALLOW_SIGNAL "%u %s", ptr2->sig, ptr2->domainname->name)) goto print_acl_rollback;
967                          } else {                          } else {
968                                  const char *keyword = acltype2keyword(acl_type);                                  BUG();
                                 if (!keyword) continue;  
                                 if (acltype2paths(acl_type) == 2) {  
                                         struct double_acl_record *ptr2 = container_of(ptr, struct double_acl_record, head);  
                                         const bool b0 = ptr2->u1_is_group, b1 = ptr2->u2_is_group;  
                                         if (io_printf(head, "allow_%s %s%s %s%s", keyword,  
                                                       b0 ? "@" : "", b0 ? ptr2->u1.group1->group_name->name : ptr2->u1.filename1->name,  
                                                       b1 ? "@" : "", b1 ? ptr2->u2.group2->group_name->name : ptr2->u2.filename2->name)) goto print_acl_rollback;  
                                 } else {  
                                         struct single_acl_record *ptr2 = container_of(ptr, struct single_acl_record, head);  
                                         const bool b = ptr2->u_is_group;  
                                         if (io_printf(head, "allow_%s %s%s", keyword,  
                                                       b ? "@" : "", b ? ptr2->u.group->group_name->name : ptr2->u.filename->name)) goto print_acl_rollback;  
                                 }  
969                          }                          }
970                          if (DumpCondition(head, ptr->cond)) {                          if (acl_type != TYPE_SINGLE_PATH_ACL && acl_type != TYPE_DOUBLE_PATH_ACL && acl_type != TYPE_CAPABILITY_ACL && DumpCondition(head, ptr->cond)) {
971                          print_acl_rollback: ;                          print_acl_rollback: ;
972                          head->read_avail = pos;                          head->read_avail = pos;
973                          return 0;                          return 0;
# Line 976  static int UpdateDomainProfile(struct io Line 1002  static int UpdateDomainProfile(struct io
1002    
1003  static int ReadDomainProfile(struct io_buffer *head)  static int ReadDomainProfile(struct io_buffer *head)
1004  {  {
1005          struct list_head *pos;          struct list1_head *pos;
1006          if (head->read_eof) return 0;          if (head->read_eof) return 0;
1007          if (!isRoot()) return -EPERM;          if (!isRoot()) return -EPERM;
1008          list_for_each_cookie(pos, head->read_var1, &domain_list) {          list1_for_each_cookie(pos, head->read_var1, &domain_list) {
1009                  struct domain_info *domain;                  struct domain_info *domain;
1010                  domain = list_entry(pos, struct domain_info, list);                  domain = list1_entry(pos, struct domain_info, list);
1011                  if (domain->is_deleted) continue;                  if (domain->is_deleted) continue;
1012                  if (io_printf(head, "%u %s\n", domain->profile, domain->domainname->name)) return 0;                  if (io_printf(head, "%u %s\n", domain->profile, domain->domainname->name)) return 0;
1013          }          }
# Line 1045  static int AddExceptionPolicy(struct io_ Line 1071  static int AddExceptionPolicy(struct io_
1071          } else if (strncmp(data, KEYWORD_ALLOW_ENV, KEYWORD_ALLOW_ENV_LEN) == 0) {          } else if (strncmp(data, KEYWORD_ALLOW_ENV, KEYWORD_ALLOW_ENV_LEN) == 0) {
1072                  return AddGloballyUsableEnvPolicy(data + KEYWORD_ALLOW_ENV_LEN, is_delete);                  return AddGloballyUsableEnvPolicy(data + KEYWORD_ALLOW_ENV_LEN, is_delete);
1073          } else if (strncmp(data, KEYWORD_FILE_PATTERN, KEYWORD_FILE_PATTERN_LEN) == 0) {          } else if (strncmp(data, KEYWORD_FILE_PATTERN, KEYWORD_FILE_PATTERN_LEN) == 0) {
1074                  return AddPatternPolicy(data + KEYWORD_FILE_PATTERN_LEN, is_delete);                  return AddFilePatternPolicy(data + KEYWORD_FILE_PATTERN_LEN, is_delete);
1075          } else if (strncmp(data, KEYWORD_PATH_GROUP, KEYWORD_PATH_GROUP_LEN) == 0) {          } else if (strncmp(data, KEYWORD_PATH_GROUP, KEYWORD_PATH_GROUP_LEN) == 0) {
1076                  return AddPathGroupPolicy(data + KEYWORD_PATH_GROUP_LEN, is_delete);                  return AddPathGroupPolicy(data + KEYWORD_PATH_GROUP_LEN, is_delete);
1077          } else if (strncmp(data, KEYWORD_DENY_REWRITE, KEYWORD_DENY_REWRITE_LEN) == 0) {          } else if (strncmp(data, KEYWORD_DENY_REWRITE, KEYWORD_DENY_REWRITE_LEN) == 0) {
# Line 1082  static int ReadExceptionPolicy(struct io Line 1108  static int ReadExceptionPolicy(struct io
1108                          if (ReadAggregatorPolicy(head)) break;                          if (ReadAggregatorPolicy(head)) break;
1109                          head->read_var2 = NULL; head->read_step = 7;                          head->read_var2 = NULL; head->read_step = 7;
1110                  case 7:                  case 7:
1111                          if (ReadPatternPolicy(head)) break;                          if (ReadFilePatternPolicy(head)) break;
1112                          head->read_var2 = NULL; head->read_step = 8;                          head->read_var2 = NULL; head->read_step = 8;
1113                  case 8:                  case 8:
1114                          if (ReadNoRewritePolicy(head)) break;                          if (ReadNoRewritePolicy(head)) break;
# Line 1220  void CCS_LoadPolicy(const char *filename Line 1246  void CCS_LoadPolicy(const char *filename
1246                  }                  }
1247          }          }
1248  #ifdef CONFIG_SAKURA  #ifdef CONFIG_SAKURA
1249          printk("SAKURA: 1.5.2-pre   2007/11/19\n");          printk("SAKURA: 1.5.3-pre   2008/01/02\n");
1250  #endif  #endif
1251  #ifdef CONFIG_TOMOYO  #ifdef CONFIG_TOMOYO
1252          printk("TOMOYO: 1.5.2-pre   2007/11/19\n");          printk("TOMOYO: 1.5.3-pre   2008/01/02\n");
1253  #endif  #endif
1254          //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");
1255          printk("Mandatory Access Control activated.\n");          printk("Mandatory Access Control activated.\n");
# Line 1231  void CCS_LoadPolicy(const char *filename Line 1257  void CCS_LoadPolicy(const char *filename
1257          ccs_log_level = KERN_WARNING;          ccs_log_level = KERN_WARNING;
1258          { /* Check all profiles currently assigned to domains are defined. */          { /* Check all profiles currently assigned to domains are defined. */
1259                  struct domain_info *domain;                  struct domain_info *domain;
1260                  list_for_each_entry(domain, &domain_list, list) {                  list1_for_each_entry(domain, &domain_list, list) {
1261                          const u8 profile = domain->profile;                          const u8 profile = domain->profile;
1262                          if (!profile_ptr[profile]) panic("Profile %u (used by '%s') not defined.\n", profile, domain->domainname->name);                          if (!profile_ptr[profile]) panic("Profile %u (used by '%s') not defined.\n", profile, domain->domainname->name);
1263                  }                  }
# Line 1265  int CheckSupervisor(const char *fmt, ... Line 1291  int CheckSupervisor(const char *fmt, ...
1291          static unsigned int serial = 0;          static unsigned int serial = 0;
1292          struct query_entry *query_entry;          struct query_entry *query_entry;
1293          if (!CheckCCSFlags(CCS_ALLOW_ENFORCE_GRACE) || !atomic_read(&queryd_watcher)) {          if (!CheckCCSFlags(CCS_ALLOW_ENFORCE_GRACE) || !atomic_read(&queryd_watcher)) {
1294  #if 0  #ifdef ALT_EXEC
1295                  if ((current->tomoyo_flags & CCS_DONT_SLEEP_ON_ENFORCE_ERROR) == 0) {                  if ((current->tomoyo_flags & CCS_DONT_SLEEP_ON_ENFORCE_ERROR) == 0) {
1296                          int i;                          int i;
1297                          for (i = 0; i < CheckCCSFlags(CCS_SLEEP_PERIOD); i++) {                          for (i = 0; i < CheckCCSFlags(CCS_SLEEP_PERIOD); i++) {
# Line 1475  static int ReadUpdatesCounter(struct io_ Line 1501  static int ReadUpdatesCounter(struct io_
1501  static int ReadVersion(struct io_buffer *head)  static int ReadVersion(struct io_buffer *head)
1502  {  {
1503          if (!head->read_eof) {          if (!head->read_eof) {
1504                  if (io_printf(head, "1.5.2-pre") == 0) head->read_eof = 1;                  if (io_printf(head, "1.5.3-pre") == 0) head->read_eof = 1;
1505          }          }
1506          return 0;          return 0;
1507  }  }
# Line 1498  static int ReadSelfDomain(struct io_buff Line 1524  static int ReadSelfDomain(struct io_buff
1524          return 0;          return 0;
1525  }  }
1526    
1527  int CCS_OpenControl(const int type, struct file *file)  int CCS_OpenControl(const u8 type, struct file *file)
1528  {  {
1529          struct io_buffer *head = ccs_alloc(sizeof(*head));          struct io_buffer *head = ccs_alloc(sizeof(*head));
1530          if (!head) return -ENOMEM;          if (!head) return -ENOMEM;

Legend:
Removed from v.712  
changed lines
  Added in v.853

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