~ubuntu-branches/debian/lenny/libsepol/lenny

« back to all changes in this revision

Viewing changes to src/assertion.c

  • Committer: Bazaar Package Importer
  • Author(s): Russell Coker
  • Date: 2008-07-13 00:26:51 UTC
  • mfrom: (1.2.1 upstream) (3.1.3 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080713002651-ww7wa3wm1x30dyk3
Tags: 2.0.30-2
Added exec_prefix to libselinux.pc.
Closes: #489724

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        return 0;
60
60
 
61
61
      err:
62
 
        ERR(handle, "assertion on line %lu violated by allow %s %s:%s {%s };",
63
 
            line, p->p_type_val_to_name[stype], p->p_type_val_to_name[ttype],
64
 
            p->p_class_val_to_name[curperm->class - 1],
65
 
            sepol_av_to_string(p, curperm->class,
66
 
                               node->datum.data & curperm->data));
 
62
        if (line) {
 
63
                ERR(handle, "neverallow on line %lu violated by allow %s %s:%s {%s };",
 
64
                    line, p->p_type_val_to_name[stype], 
 
65
                    p->p_type_val_to_name[ttype],
 
66
                    p->p_class_val_to_name[curperm->class - 1],
 
67
                    sepol_av_to_string(p, curperm->class,
 
68
                                       node->datum.data & curperm->data));
 
69
        } else {
 
70
                ERR(handle, "neverallow violated by allow %s %s:%s {%s };",
 
71
                    p->p_type_val_to_name[stype], 
 
72
                    p->p_type_val_to_name[ttype],
 
73
                    p->p_class_val_to_name[curperm->class - 1],
 
74
                    sepol_av_to_string(p, curperm->class,
 
75
                                       node->datum.data & curperm->data));
 
76
        }
67
77
        return -1;
68
78
}
69
79
 
74
84
        avtab_t te_avtab, te_cond_avtab;
75
85
        ebitmap_node_t *snode, *tnode;
76
86
        unsigned int i, j;
77
 
        int errors = 0;
 
87
        int rc;
78
88
 
79
89
        if (!avrules) {
80
90
                /* Since assertions are stored in avrules, if it is NULL
111
121
                        if (a->flags & RULE_SELF) {
112
122
                                if (check_assertion_helper
113
123
                                    (handle, p, &te_avtab, &te_cond_avtab, i, i,
114
 
                                     a->perms, a->line))
115
 
                                        errors++;
 
124
                                     a->perms, a->line)) {
 
125
                                        rc = -1;
 
126
                                        goto out;
 
127
                                }
116
128
                        }
117
129
                        ebitmap_for_each_bit(ttypes, tnode, j) {
118
130
                                if (!ebitmap_node_get_bit(tnode, j))
119
131
                                        continue;
120
132
                                if (check_assertion_helper
121
133
                                    (handle, p, &te_avtab, &te_cond_avtab, i, j,
122
 
                                     a->perms, a->line))
123
 
                                        errors++;
 
134
                                     a->perms, a->line)) {
 
135
                                        rc = -1;
 
136
                                        goto out;
 
137
                                }
124
138
                        }
125
139
                }
126
140
        }
127
141
 
128
 
        if (errors) {
129
 
                ERR(handle, "%d assertion violations occured", errors);
130
 
                avtab_destroy(&te_avtab);
131
 
                avtab_destroy(&te_cond_avtab);
132
 
                return -1;
133
 
        }
134
 
 
 
142
        rc = 0;
 
143
out:
135
144
        avtab_destroy(&te_avtab);
136
145
        avtab_destroy(&te_cond_avtab);
137
 
        return 0;
 
146
        return rc;
138
147
 
139
148
      oom:
140
 
        ERR(handle, "Out of memory - unable to check assertions");
 
149
        ERR(handle, "Out of memory - unable to check neverallows");
141
150
        return -1;
142
151
}