| 1055 | } |
| 1056 | |
| 1057 | static void |
| 1058 | biba_ifnet_create(struct ifnet *ifp, struct label *ifplabel) |
| 1059 | { |
| 1060 | char tifname[IFNAMSIZ], *p, *q; |
| 1061 | char tiflist[sizeof(trusted_interfaces)]; |
| 1062 | struct mac_biba *dest; |
| 1063 | int len, type; |
| 1064 | |
| 1065 | dest = SLOT(ifplabel); |
| 1066 | |
| 1067 | if (ifp->if_type == IFT_LOOP || interfaces_equal != 0) { |
| 1068 | type = MAC_BIBA_TYPE_EQUAL; |
| 1069 | goto set; |
| 1070 | } |
| 1071 | |
| 1072 | if (trust_all_interfaces) { |
| 1073 | type = MAC_BIBA_TYPE_HIGH; |
| 1074 | goto set; |
| 1075 | } |
| 1076 | |
| 1077 | type = MAC_BIBA_TYPE_LOW; |
| 1078 | |
| 1079 | if (trusted_interfaces[0] == '\0' || |
| 1080 | !strvalid(trusted_interfaces, sizeof(trusted_interfaces))) |
| 1081 | goto set; |
| 1082 | |
| 1083 | bzero(tiflist, sizeof(tiflist)); |
| 1084 | for (p = trusted_interfaces, q = tiflist; *p != '\0'; p++, q++) |
| 1085 | if(*p != ' ' && *p != '\t') |
| 1086 | *q = *p; |
| 1087 | |
| 1088 | for (p = q = tiflist;; p++) { |
| 1089 | if (*p == ',' || *p == '\0') { |
| 1090 | len = p - q; |
| 1091 | if (len < IFNAMSIZ) { |
| 1092 | bzero(tifname, sizeof(tifname)); |
| 1093 | bcopy(q, tifname, len); |
| 1094 | if (strcmp(tifname, ifp->if_xname) == 0) { |
| 1095 | type = MAC_BIBA_TYPE_HIGH; |
| 1096 | break; |
| 1097 | } |
| 1098 | } else { |
| 1099 | *p = '\0'; |
| 1100 | printf("mac_biba warning: interface name " |
| 1101 | "\"%s\" is too long (must be < %d)\n", |
| 1102 | q, IFNAMSIZ); |
| 1103 | } |
| 1104 | if (*p == '\0') |
| 1105 | break; |
| 1106 | q = p + 1; |
| 1107 | } |
| 1108 | } |
| 1109 | set: |
| 1110 | biba_set_effective(dest, type, 0, NULL); |
| 1111 | biba_set_range(dest, type, 0, NULL, type, 0, NULL); |
| 1112 | } |
| 1113 | |
| 1114 | static void |
nothing calls this directly
no test coverage detected