~apparmor-dev/apparmor/master

« back to all changes in this revision

Viewing changes to parser/af_rule.h

  • Committer: Steve Beattie
  • Date: 2019-02-19 09:38:13 UTC
  • Revision ID: sbeattie@ubuntu.com-20190219093813-ud526ee6hwn8nljz
The AppArmor project has been converted to git and is now hosted on
gitlab.

To get the converted repository, please do
  git clone https://gitlab.com/apparmor/apparmor

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *   Copyright (c) 2014
3
 
 *   Canonical Ltd. (All rights reserved)
4
 
 *
5
 
 *   This program is free software; you can redistribute it and/or
6
 
 *   modify it under the terms of version 2 of the GNU General Public
7
 
 *   License published by the Free Software Foundation.
8
 
 *
9
 
 *   This program is distributed in the hope that it will be useful,
10
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 *   GNU General Public License for more details.
13
 
 *
14
 
 *   You should have received a copy of the GNU General Public License
15
 
 *   along with this program; if not, contact Novell, Inc. or Canonical
16
 
 *   Ltd.
17
 
 */
18
 
#ifndef __AA_AF_RULE_H
19
 
#define __AA_AF_RULE_H
20
 
 
21
 
#include "immunix.h"
22
 
#include "network.h"
23
 
#include "parser.h"
24
 
#include "profile.h"
25
 
 
26
 
#include "rule.h"
27
 
 
28
 
enum cond_side { local_cond, peer_cond, either_cond };
29
 
 
30
 
struct supported_cond {
31
 
        const char *name;
32
 
        bool supported;
33
 
        bool in;
34
 
        bool multivalue;
35
 
        enum cond_side side ;
36
 
};
37
 
 
38
 
class af_rule: public rule_t {
39
 
public:
40
 
        std::string af_name;
41
 
        char *sock_type;
42
 
        int sock_type_n;
43
 
        char *proto;
44
 
        int proto_n;
45
 
        char *label;
46
 
        char *peer_label;
47
 
        int mode;
48
 
        int audit;
49
 
        bool deny;
50
 
 
51
 
        af_rule(const char *name): af_name(name), sock_type(NULL),
52
 
                sock_type_n(-1), proto(NULL), proto_n(0), label(NULL),
53
 
                peer_label(NULL), mode(0), audit(0), deny(0)
54
 
        {}
55
 
 
56
 
        virtual ~af_rule()
57
 
        {
58
 
                free(sock_type);
59
 
                free(proto);
60
 
                free(label);
61
 
                free(peer_label);
62
 
        };
63
 
 
64
 
        bool cond_check(struct supported_cond *cond, struct cond_entry *ent,
65
 
                        bool peer, const char *rname);
66
 
        int move_base_cond(struct cond_entry *conds, bool peer);
67
 
 
68
 
        virtual bool has_peer_conds(void) { return peer_label ? true : false; }
69
 
        virtual ostream &dump_prefix(ostream &os);
70
 
        virtual ostream &dump_local(ostream &os);
71
 
        virtual ostream &dump_peer(ostream &os);
72
 
        virtual ostream &dump(ostream &os);
73
 
        virtual int expand_variables(void);
74
 
        virtual int gen_policy_re(Profile &prof) = 0;
75
 
        virtual void post_process(Profile &prof unused) { };
76
 
};
77
 
 
78
 
#endif /* __AA_AF_RULE_H */