~mathiaz/apparmor/ubuntu-mathiaz

« back to all changes in this revision

Viewing changes to parser/parser_policy.c

  • Committer: Mathias Gug
  • Date: 2008-02-04 18:57:00 UTC
  • mfrom: (885.1.5 apparmor)
  • Revision ID: mathiaz@ubuntu.com-20080204185700-wwlyq0ksssxclv8w
Merge  ubuntu branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: parser_policy.c 756 2007-06-26 22:09:46Z jrjohansen $ */
 
1
/* $Id: parser_policy.c 1030 2007-11-16 09:34:01Z jrjohansen $ */
2
2
 
3
3
/*
4
4
 *   Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
41
41
 
42
42
static int codomain_compare(const void *a, const void *b)
43
43
{
44
 
        return strcmp(((struct codomain *) a)->name,
45
 
                      ((struct codomain *) b)->name);
 
44
        struct codomain *A = (struct codomain *) a;
 
45
        struct codomain *B = (struct codoamin *) b;
 
46
 
 
47
        int res = 0;
 
48
        if (A->namespace) {
 
49
                if (B->namespace)
 
50
                        res = strcmp(A->namespace, B->namespace);
 
51
                else
 
52
                        res = -1;
 
53
        } else if (B->namespace)
 
54
                res = 1;
 
55
        if (res)
 
56
                return res;
 
57
        return strcmp(A->name, B->name);
46
58
}
47
59
 
48
60
void add_to_list(struct codomain *codomain)
87
99
        cod->entries = entry;
88
100
}
89
101
 
90
 
void add_netrule_to_policy(struct codomain *cod, struct cod_net_entry *net_entry)
91
 
{
92
 
        net_entry->next = cod->net_entries;
93
 
        cod->net_entries = net_entry;
94
 
}
95
 
 
96
102
static void __merge_rules(const void *nodep, const VISIT value,
97
103
                          const int __unused depth)
98
104
{
380
386
{
381
387
        struct codomain *ret = a;
382
388
        struct cod_entry *last;
383
 
        struct cod_net_entry *lastnet;
384
389
        if (!a) {
385
390
                ret = b;
386
391
                goto out;
403
408
        }
404
409
        b->entries = NULL;
405
410
 
406
 
        if (a->net_entries) {
407
 
                list_last_entry(a->net_entries, lastnet);
408
 
                lastnet->next = b->net_entries;
409
 
        } else {
410
 
                a->net_entries = b->net_entries;
411
 
        }
412
 
        b->net_entries = NULL;
413
 
 
414
411
        a->flags.complain = a->flags.complain || b->flags.complain;
415
412
        a->flags.audit = a->flags.audit || b->flags.audit;
416
413
 
470
467
                return;
471
468
        free_hat_table(cod->hat_table);
472
469
        free_cod_entries(cod->entries);
473
 
        free_net_entries(cod->net_entries);
474
470
        if (cod->dfarules)
475
471
                aare_delete_ruleset(cod->dfarules);
476
472
        if (cod->dfa)