[apparmor] [patch 4/5] add generic lookup of af_name mappings
John Johansen
john.johansen at canonical.com
Fri Aug 8 06:53:28 UTC 2014
On 08/07/2014 04:17 PM, Seth Arnold wrote:
> On Wed, Aug 06, 2014 at 05:32:48AM -0700, john.johansen at canonical.com wrote:
>> Signed-off-by: John Johansen <john.johansen at canonical.com>
>
> Looks good in itself, but I noticed that the network_families array is
> missing values 0, 12, 27, and 28 when built on my trusty laptop. So, uh, is
> 'return i' and 'return network_families[af]' correct in face of holes?
>
It should but, it wouldn't hurt to double check. Hmmm I think I hear steve
yelling something about a unit test, but he is on vacation so I'll just ignore
him for now ;)
> Thanks
>
>> ---
>> parser/network.c | 19 +++++++++++++++++++
>> parser/network.h | 5 +++++
>> 2 files changed, 24 insertions(+)
>>
>> --- 2.9-test.orig/parser/network.c
>> +++ 2.9-test/parser/network.c
>> @@ -305,6 +305,25 @@
>> #include "af_names.h"
>> };
>>
>> +int net_find_af_val(const char *af)
>> +{
>> + int i;
>> + for (i = 0; network_families[i]; i++) {
>> + if (strcmp(network_families[i], af) == 0)
>> + return i;
>> + }
>> +
>> + return -1;
>> +}
>> +
>> +const char *net_find_af_name(unsigned int af)
>> +{
>> + if (af < 0 || af > get_af_max())
>> + return NULL;
>> +
>> + return network_families[af];
>> +}
>> +
>> void __debug_network(unsigned int *array, const char *name)
>> {
>> unsigned int count = sizeof(sock_types)/sizeof(sock_types[0]);
>> --- 2.9-test.orig/parser/network.h
>> +++ 2.9-test/parser/network.h
>> @@ -77,5 +77,10 @@
>>
>> int net_find_type_val(const char *type);
>> const char *net_find_type_name(int type);
>> +int net_find_af_val(const char *af);
>> +const char *net_find_af_name(unsigned int af);
>> +const struct network_tuple *net_find_mapping(const char *family,
>> + const char *type,
>> + const char *protocol);
>>
>> #endif /* __AA_NETWORK_H */
>>
>>
>> --
>> AppArmor mailing list
>> AppArmor at lists.ubuntu.com
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
>>
>>
>>
More information about the AppArmor
mailing list