MCPcopy Create free account
hub / github.com/F-Stack/f-stack / biba_ifnet_create

Function biba_ifnet_create

freebsd/security/mac_biba/mac_biba.c:1057–1112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1055}
1056
1057static void
1058biba_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 }
1109set:
1110 biba_set_effective(dest, type, 0, NULL);
1111 biba_set_range(dest, type, 0, NULL, type, 0, NULL);
1112}
1113
1114static void

Callers

nothing calls this directly

Calls 6

strvalidFunction · 0.85
bzeroFunction · 0.85
strcmpFunction · 0.85
biba_set_effectiveFunction · 0.85
biba_set_rangeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected