2013-07-31 09:05:51 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013
|
|
|
|
* Canonical, Ltd. (All rights reserved)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of version 2 of the GNU General Public
|
|
|
|
* License published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, contact Novell, Inc. or Canonical
|
|
|
|
* Ltd.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __AA_DBUS_H
|
|
|
|
#define __AA_DBUS_H
|
|
|
|
|
|
|
|
#include "parser.h"
|
2014-04-07 03:16:50 -07:00
|
|
|
#include "rule.h"
|
|
|
|
#include "profile.h"
|
2013-07-31 09:05:51 -07:00
|
|
|
|
2023-08-02 02:07:36 -07:00
|
|
|
extern int parse_dbus_perms(const char *str_mode, perm32_t *mode, int fail);
|
2014-04-07 03:16:50 -07:00
|
|
|
|
2021-09-04 03:28:18 -07:00
|
|
|
class dbus_rule: public perms_rule_t {
|
2014-04-07 03:16:50 -07:00
|
|
|
void move_conditionals(struct cond_entry *conds);
|
|
|
|
public:
|
2013-07-31 09:05:51 -07:00
|
|
|
char *bus;
|
|
|
|
/**
|
|
|
|
* Be careful! ->name can be the subject or the peer name, depending on
|
|
|
|
* whether the rule is a bind rule or a send/receive rule. See the
|
|
|
|
* comments in new_dbus_entry() for details.
|
|
|
|
*/
|
|
|
|
char *name;
|
|
|
|
char *peer_label;
|
|
|
|
char *path;
|
|
|
|
char *interface;
|
|
|
|
char *member;
|
|
|
|
|
2023-08-02 02:07:36 -07:00
|
|
|
dbus_rule(perm32_t perms_p, struct cond_entry *conds,
|
2014-04-07 03:16:50 -07:00
|
|
|
struct cond_entry *peer_conds);
|
|
|
|
virtual ~dbus_rule() {
|
|
|
|
free(bus);
|
|
|
|
free(name);
|
|
|
|
free(peer_label);
|
|
|
|
free(path);
|
|
|
|
free(interface);
|
|
|
|
free(member);
|
|
|
|
};
|
2022-09-01 09:56:45 -07:00
|
|
|
virtual bool valid_prefix(const prefixes &p, const char *&error) {
|
2023-08-03 23:21:05 -07:00
|
|
|
if (p.owner != OWNER_UNSPECIFIED) {
|
2021-09-04 03:28:18 -07:00
|
|
|
error = "owner prefix not allowed on dbus rules";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
2014-04-07 03:16:50 -07:00
|
|
|
|
|
|
|
virtual ostream &dump(ostream &os);
|
|
|
|
virtual int expand_variables(void);
|
|
|
|
virtual int gen_policy_re(Profile &prof);
|
2013-07-31 09:05:51 -07:00
|
|
|
|
2023-07-05 04:02:29 -07:00
|
|
|
virtual bool is_mergeable(void) { return true; }
|
|
|
|
virtual int cmp(rule_t const &rhs) const
|
|
|
|
{
|
2023-07-10 20:04:53 -07:00
|
|
|
int res = perms_rule_t::cmp(rhs);
|
2023-07-05 04:02:29 -07:00
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
dbus_rule const &trhs = (rule_cast<dbus_rule const &>(rhs));
|
|
|
|
res = null_strcmp(bus, trhs.bus);
|
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
res = null_strcmp(name, trhs.name);
|
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
res = null_strcmp(peer_label, trhs.peer_label);
|
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
res = null_strcmp(path, trhs.path);
|
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
res = null_strcmp(interface, trhs.interface);
|
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
return null_strcmp(member, trhs.member);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-08-09 14:51:55 -04:00
|
|
|
protected:
|
|
|
|
virtual void warn_once(const char *name) override;
|
2014-04-07 03:16:50 -07:00
|
|
|
};
|
2013-07-31 09:05:51 -07:00
|
|
|
|
|
|
|
#endif /* __AA_DBUS_H */
|