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

Subversion リポジトリの参照

Diff of /trunk/1.8.x/ccs-patch/security/ccsecurity/network.c

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

revision 325 by kumaneko, Mon Aug 6 12:55:41 2007 UTC revision 328 by kumaneko, Wed Aug 8 11:12:12 2007 UTC
# Line 266  static int AddNetworkEntry(const u8 oper Line 266  static int AddNetworkEntry(const u8 oper
266          if (is_add) {          if (is_add) {
267                  if ((ptr = domain->first_acl_ptr) == NULL) goto first_entry;                  if ((ptr = domain->first_acl_ptr) == NULL) goto first_entry;
268                  while (1) {                  while (1) {
269                          struct ip_network_acl_record *new_ptr;                          struct ip_network_acl_record *new_ptr = (struct ip_network_acl_record *) ptr;
270                          if (ptr->type == TYPE_IP_NETWORK_ACL && ptr->u.b[0] == operation && ptr->u.b[1] == record_type && ptr->cond == condition && ((struct ip_network_acl_record *) ptr)->min_port == min_port && max_port == ((struct ip_network_acl_record *) ptr)->max_port) {                          if (ptr->type == TYPE_IP_NETWORK_ACL && new_ptr->operation_type == operation && new_ptr->record_type == record_type && ptr->cond == condition && new_ptr->min_port == min_port && max_port == new_ptr->max_port) {
271                                  if (record_type == IP_RECORD_TYPE_ADDRESS_GROUP) {                                  if (record_type == IP_RECORD_TYPE_ADDRESS_GROUP) {
272                                          if (((struct ip_network_acl_record *) ptr)->u.group == group) {                                          if (new_ptr->u.group == group) {
273                                                  ptr->is_deleted = 0;                                                  ptr->is_deleted = 0;
274                                                  /* Found. Nothing to do. */                                                  /* Found. Nothing to do. */
275                                                  error = 0;                                                  error = 0;
276                                                  break;                                                  break;
277                                          }                                          }
278                                  } else if (record_type == IP_RECORD_TYPE_IPv4) {                                  } else if (record_type == IP_RECORD_TYPE_IPv4) {
279                                          if (((struct ip_network_acl_record *) ptr)->u.ipv4.min == min_ip && max_ip == ((struct ip_network_acl_record *) ptr)->u.ipv4.max) {                                          if (new_ptr->u.ipv4.min == min_ip && max_ip == new_ptr->u.ipv4.max) {
280                                                  ptr->is_deleted = 0;                                                  ptr->is_deleted = 0;
281                                                  /* Found. Nothing to do. */                                                  /* Found. Nothing to do. */
282                                                  error = 0;                                                  error = 0;
283                                                  break;                                                  break;
284                                          }                                          }
285                                  } else if (record_type == IP_RECORD_TYPE_IPv6) {                                  } else if (record_type == IP_RECORD_TYPE_IPv6) {
286                                          if (memcmp(((struct ip_network_acl_record *) ptr)->u.ipv6.min, min_address, 16) == 0 && memcmp(max_address, ((struct ip_network_acl_record *) ptr)->u.ipv6.max, 16) == 0) {                                          if (memcmp(new_ptr->u.ipv6.min, min_address, 16) == 0 && memcmp(max_address, new_ptr->u.ipv6.max, 16) == 0) {
287                                                  ptr->is_deleted = 0;                                                  ptr->is_deleted = 0;
288                                                  /* Found. Nothing to do. */                                                  /* Found. Nothing to do. */
289                                                  error = 0;                                                  error = 0;
# Line 300  static int AddNetworkEntry(const u8 oper Line 300  static int AddNetworkEntry(const u8 oper
300                          /* Not found. Append it to the tail. */                          /* Not found. Append it to the tail. */
301                          if ((new_ptr = alloc_element(sizeof(*new_ptr))) == NULL) break;                          if ((new_ptr = alloc_element(sizeof(*new_ptr))) == NULL) break;
302                          new_ptr->head.type = TYPE_IP_NETWORK_ACL;                          new_ptr->head.type = TYPE_IP_NETWORK_ACL;
303                          new_ptr->head.u.b[0] = operation;                          new_ptr->operation_type = operation;
304                          new_ptr->head.u.b[1] = record_type;                          new_ptr->record_type = record_type;
305                          new_ptr->head.cond = condition;                          new_ptr->head.cond = condition;
306                          if (record_type == IP_RECORD_TYPE_ADDRESS_GROUP) {                          if (record_type == IP_RECORD_TYPE_ADDRESS_GROUP) {
307                                  new_ptr->u.group = group;                                  new_ptr->u.group = group;
# Line 320  static int AddNetworkEntry(const u8 oper Line 320  static int AddNetworkEntry(const u8 oper
320          } else {          } else {
321                  error = -ENOENT;                  error = -ENOENT;
322                  for (ptr = domain->first_acl_ptr; ptr; ptr = ptr->next) {                  for (ptr = domain->first_acl_ptr; ptr; ptr = ptr->next) {
323                          if (ptr->type != TYPE_IP_NETWORK_ACL || ptr->is_deleted || ptr->u.b[0] != operation || ptr->u.b[1] != record_type || ptr->cond != condition || ((struct ip_network_acl_record *) ptr)->min_port != min_port || ((struct ip_network_acl_record *) ptr)->max_port != max_port) continue;                          struct ip_network_acl_record *ptr2 = (struct ip_network_acl_record *) ptr;
324                            if (ptr->type != TYPE_IP_NETWORK_ACL || ptr->is_deleted || ptr2->operation_type != operation || ptr2->record_type != record_type || ptr->cond != condition || ptr2->min_port != min_port || ptr2->max_port != max_port) continue;
325                          if (record_type == IP_RECORD_TYPE_ADDRESS_GROUP) {                          if (record_type == IP_RECORD_TYPE_ADDRESS_GROUP) {
326                                  if (((struct ip_network_acl_record *) ptr)->u.group != group) continue;                                  if (ptr2->u.group != group) continue;
327                          } else if (record_type == IP_RECORD_TYPE_IPv4) {                          } else if (record_type == IP_RECORD_TYPE_IPv4) {
328                                  if (((struct ip_network_acl_record *) ptr)->u.ipv4.min != min_ip || max_ip != ((struct ip_network_acl_record *) ptr)->u.ipv4.max) continue;                                  if (ptr2->u.ipv4.min != min_ip || max_ip != ptr2->u.ipv4.max) continue;
329                          } else if (record_type == IP_RECORD_TYPE_IPv6) {                          } else if (record_type == IP_RECORD_TYPE_IPv6) {
330                                  if (memcmp(((struct ip_network_acl_record *) ptr)->u.ipv6.min, min_address, 16) || memcmp(max_address, ((struct ip_network_acl_record *) ptr)->u.ipv6.max, 16)) continue;                                  if (memcmp(ptr2->u.ipv6.min, min_address, 16) || memcmp(max_address, ptr2->u.ipv6.max, 16)) continue;
331                          }                          }
332                          error = DelDomainACL(ptr);                          error = DelDomainACL(ptr);
333                          break;                          break;
# Line 345  static int CheckNetworkEntry(const int i Line 346  static int CheckNetworkEntry(const int i
346          const u32 ip = ntohl(*address); /* using host byte order to allow u32 comparison than memcmp().*/          const u32 ip = ntohl(*address); /* using host byte order to allow u32 comparison than memcmp().*/
347          if (!CheckCCSFlags(CCS_TOMOYO_MAC_FOR_NETWORK)) return 0;          if (!CheckCCSFlags(CCS_TOMOYO_MAC_FOR_NETWORK)) return 0;
348          for (ptr = domain->first_acl_ptr; ptr; ptr = ptr->next) {          for (ptr = domain->first_acl_ptr; ptr; ptr = ptr->next) {
349                  if (ptr->type != TYPE_IP_NETWORK_ACL || ptr->is_deleted || ptr->u.b[0] != operation || port < ((struct ip_network_acl_record *) ptr)->min_port || ((struct ip_network_acl_record *) ptr)->max_port < port || CheckCondition(ptr->cond, NULL)) continue;                  struct ip_network_acl_record *ptr2 = (struct ip_network_acl_record *) ptr;
350                  if (ptr->u.b[1] == IP_RECORD_TYPE_ADDRESS_GROUP) {                  if (ptr->type != TYPE_IP_NETWORK_ACL || ptr->is_deleted || ptr2->operation_type != operation || port < ptr2->min_port || ptr2->max_port < port || CheckCondition(ptr->cond, NULL)) continue;
351                          if (AddressMatchesToGroup(is_ipv6, address, ((struct ip_network_acl_record *) ptr)->u.group)) break;                  if (ptr2->record_type == IP_RECORD_TYPE_ADDRESS_GROUP) {
352                  } else if (ptr->u.b[1] == IP_RECORD_TYPE_IPv4) {                          if (AddressMatchesToGroup(is_ipv6, address, ptr2->u.group)) break;
353                          if (!is_ipv6 && ((struct ip_network_acl_record *) ptr)->u.ipv4.min <= ip && ip <= ((struct ip_network_acl_record *) ptr)->u.ipv4.max) break;                  } else if (ptr2->record_type == IP_RECORD_TYPE_IPv4) {
354                            if (!is_ipv6 && ptr2->u.ipv4.min <= ip && ip <= ptr2->u.ipv4.max) break;
355                  } else {                  } else {
356                          if (is_ipv6 && memcmp(((struct ip_network_acl_record *) ptr)->u.ipv6.min, address, 16) <= 0 && memcmp(address, ((struct ip_network_acl_record *) ptr)->u.ipv6.max, 16) <= 0) break;                          if (is_ipv6 && memcmp(ptr2->u.ipv6.min, address, 16) <= 0 && memcmp(address, ptr2->u.ipv6.max, 16) <= 0) break;
357                  }                  }
358          }          }
359          if (ptr) {          if (ptr) {

Legend:
Removed from v.325  
changed lines
  Added in v.328

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