various cleanups and base symbol class
cover various cleanups and base symbol class
do various fixups/cleanups and add a base symbol class for all symbols. This lays much of the groundwork for upcoming patches.
Signature · 4 lines
-- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
PATCH 1/7 remove makefile targets that dont build
temporarilly remove targets that don't build with policyrep
--- policycoreutils/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
policycoreutils/Makefile +2 -1
@@ -1,4 +1,5 @@ -SUBDIRS=setfiles semanage load_policy newrole run_init restorecond secon audit2allow audit2why scripts sestatus semodule_package semodule semodule_link semodule_expand semodule_deps setsebool po +SUBDIRS=setfiles load_policy newrole run_init restorecond secon audit2allow audit2why scripts sestatus po +#setsebool semodule_package semanage semodule semodule_link semodule_expand semodule_deps all install relabel clean indent: @for subdir in $(SUBDIRS); do \
Signature · 4 lines
-- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
PATCH 2/7 remove policy_package
In reply to Joshua BrindleWe chose to go with a flat text file format rather than an archive so remove the xar package bits
--- libpolicyrep/include/policyrep/policy_package.hpp | 72 --- libpolicyrep/src/policy_package.cpp | 463 ---------------------- policycoreutils/semodule_package/Makefile | 2 3 files changed, 1 insertion(+), 536 deletions(-)
libpolicyrep/include/policyrep/policy_package.hpp deleted +0 -72
@@ -1,72 +0,0 @@ -/* Author: Joshua Brindle <[email protected]> */ - -#ifndef __policy_package_hpp__ -#define __policy_package_hpp__ - -#include <policyrep/policy.hpp> - -namespace policyrep { - -struct PolicyPackageImpl; - -class PolicyPackage { -public: - PolicyPackage(); - virtual ~ PolicyPackage(); - - virtual Module & get_policy_module() const; - virtual void set_policy_module(Module & module); - - virtual char *get_file_contexts() const; - virtual void set_file_contexts(char *fc); - virtual char *get_seusers() const; - virtual void set_seusers(char *su); - virtual char *get_user_extra() const; - virtual void set_user_extra(char *ue); - virtual char *get_netfilter_contexts() const; - virtual void set_netfilter_contexts(char *nf); - - virtual void read(char *filename); - // PolicyPackage.write does not currently work pending - // a bug fix in xar - virtual void write(char *filename); - -protected: - void init(); - PolicyPackageImpl *impl; - -}; - -// This is a simple archival class that allows a dumb packager -// e.g., semodule_package to simply set the pathnames for each -// file in the policy package and call create_archive. - -struct PolicyPackageArchiveImpl; - -class PolicyPackageArchive { -public: - PolicyPackageArchive(); - virtual ~ PolicyPackageArchive(); - - virtual void set_mod_file(char *mod); - virtual char *get_mod_file() const; - virtual void set_fc_file(char *fc); - virtual char *get_fc_file() const; - virtual void set_seusers_file(char *su); - virtual char *get_seusers_file() const; - virtual void set_user_extra_file(char *ue); - virtual char *get_user_extra_file() const; - virtual void set_nc_file(char *nf); - virtual char *get_nc_file() const; - - virtual void create_archive(char *filename); - -protected: - void init(); - PolicyPackageArchiveImpl *impl; - -}; - -} // namespace policyrep - -#endif
libpolicyrep/src/policy_package.cpp deleted +0 -463
463 lines not on this page · raw message
policycoreutils/semodule_package/Makefile +1 -1
@@ -7,7 +7,7 @@ MANDIR ?= $(PREFIX)/share/man CFLAGS ?= -Werror -Wall -W override CFLAGS += -I$(INCLUDEDIR) -LDLIBS = -lpolicyrep -lxar -lselinux -L$(LIBDIR) +LDLIBS = -lpolicyrep -lselinux -L$(LIBDIR) all: semodule_package
Signature · 4 lines
-- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
PATCH 3/7 remove duplicated optional.hpp data
In reply to Joshua BrindleSomehow optional.hpp ended up duplicated twice, remove the extra junk
--- libpolicyrep/include/policyrep/optional.hpp | 46 ---------------------------- 1 file changed, 46 deletions(-)
libpolicyrep/include/policyrep/optional.hpp +0 -46
@@ -44,49 +44,3 @@ namespace policyrep } // namespace policyrep #endif -/* Author: Karl MacMillan <[email protected]> */ - -#ifndef __optional_hpp__ -#define __optional_hpp__ - -#include <policyrep/policy_base.hpp> - -namespace policyrep -{ - class OptionalBranch; - typedef boost::shared_ptr<OptionalBranch> OptionalBranchPtr; - - struct OptionalBlockImpl; - class OptionalBlock : public PolicyBlock - { - public: - OptionalBlock(); - OptionalBlock(const OptionalBlock& other); - OptionalBlock(OptionalBranchPtr true_); - OptionalBlock(OptionalBranchPtr true_, OptionalBranchPtr false_); - virtual ~OptionalBlock(); - virtual void operator=(const OptionalBlock& other); - protected: - void copy(const OptionalBlock& other); - OptionalBlockImpl* impl; - }; - typedef boost::shared_ptr<OptionalBlock> OptionalBlockPtr; - - struct OptionalBranchImpl; - class OptionalBranch : public PolicyBranch - { - public: - OptionalBranch(); - OptionalBranch(const OptionalBranch& other); - virtual ~OptionalBranch(); - virtual void operator=(const OptionalBranch& other); - - protected: - virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void copy(const OptionalBranch& other); - OptionalBranchImpl* impl; - }; - -} // namespace policyrep - -#endif
Signature · 4 lines
-- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
PATCH 4/7 symbol base class
In reply to Joshua BrindleThis adds the symbol base class and makes all symbols (types, roles, etc) inherit from it.
--- libpolicyrep/include/policyrep/conditional.hpp | 5 - libpolicyrep/include/policyrep/mls.hpp | 16 +--- libpolicyrep/include/policyrep/object_class.hpp | 10 +-- libpolicyrep/include/policyrep/policy.hpp | 6 - libpolicyrep/include/policyrep/rbac.hpp | 6 - libpolicyrep/include/policyrep/symbol.hpp | 27 ++++++++ libpolicyrep/include/policyrep/te_decl.hpp | 10 --- libpolicyrep/include/policyrep/user.hpp | 6 - libpolicyrep/src/conditional.cpp | 21 +----- libpolicyrep/src/mls.cpp | 78 ++++++++---------------- libpolicyrep/src/object_class.cpp | 42 ++++-------- libpolicyrep/src/policy.cpp | 20 +----- libpolicyrep/src/rbac.cpp | 27 +++----- libpolicyrep/src/symbol.cpp | 71 +++++++++++++++++++++ libpolicyrep/src/te_decl.cpp | 52 +++++----------- libpolicyrep/src/user.cpp | 27 +++----- 16 files changed, 206 insertions(+), 218 deletions(-)
libpolicyrep/include/policyrep/conditional.hpp +2 -3
@@ -4,6 +4,7 @@ #define __conditional_hpp__ #include <policyrep/policy_base.hpp> +#include <policyrep/symbol.hpp> #include <list>
@@ -39,7 +40,7 @@ namespace policyrep */ struct CondBoolImpl; - class CondBool : public Node + class CondBool : public Symbol { public: CondBool();
@@ -48,8 +49,6 @@ namespace policyrep virtual ~CondBool(); virtual void operator=(const CondBool& other); - virtual void set_name(const std::string& name); - virtual const std::string& get_name() const; virtual void set_default_value(bool v); virtual bool get_default_value() const;
libpolicyrep/include/policyrep/mls.hpp +4 -12
@@ -4,6 +4,7 @@ #define __mls_hpp__ #include <policyrep/policy_base.hpp> +#include <policyrep/symbol.hpp> namespace policyrep {
@@ -13,7 +14,7 @@ namespace policyrep // struct SensitivityImpl; - class Sensitivity : public Node + class Sensitivity : public Symbol { public: Sensitivity();
@@ -30,9 +31,6 @@ namespace policyrep aliases().insert(begin, end); } - virtual const std::string& get_name() const; - virtual void set_name(const std::string& name); - virtual StringSet& aliases(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
@@ -74,7 +72,7 @@ namespace policyrep // struct CategoryImpl; - class Category : public Node + class Category : public Symbol { public: Category();
@@ -91,9 +89,6 @@ namespace policyrep aliases().insert(begin, end); } - virtual const std::string& get_name() const; - virtual void set_name(const std::string& name); - virtual StringSet& aliases(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
@@ -107,7 +102,7 @@ namespace policyrep // struct LevelImpl; - class Level : public Node + class Level : public Symbol { public: Level();
@@ -124,9 +119,6 @@ namespace policyrep categories().insert(begin, end); } - virtual const std::string& get_name() const; - virtual void set_name(const std::string& name); - virtual StringSet& categories(); virtual void do_output_brief(std::ostream& o, const OutputFormatter& op) const; protected:
libpolicyrep/include/policyrep/object_class.hpp +4 -6
@@ -4,6 +4,7 @@ #define __object_class_hpp__ #include <policyrep/policy_base.hpp> +#include <policyrep/symbol.hpp> namespace policyrep {
@@ -13,7 +14,7 @@ namespace policyrep // struct CommonPermsImpl; - class CommonPerms : public Node + class CommonPerms : public Symbol { public: CommonPerms();
@@ -29,8 +30,6 @@ namespace policyrep perms().insert(perms_begin, perms_end); } - virtual const std::string& get_name() const; - virtual void set_name(const std::string& name); virtual StringSet& perms(); protected:
@@ -46,10 +45,11 @@ namespace policyrep // struct ObjectClassImpl; - class ObjectClass : public Node + class ObjectClass : public Symbol { public: ObjectClass(); + ObjectClass(const std::string& name); ObjectClass(const std::string& name, const std::string& commons); ObjectClass(const ObjectClass& other); virtual ~ObjectClass();
@@ -65,8 +65,6 @@ namespace policyrep perms().insert(perms_begin, perms_end); } - virtual const std::string& get_name() const; - virtual void set_name(const std::string& name); virtual StringSet& perms(); virtual const std::string& get_common_perms() const; virtual void set_common_perms(const std::string& name);
libpolicyrep/include/policyrep/policy.hpp +2 -4
@@ -12,6 +12,7 @@ #include <policyrep/user.hpp> #include <policyrep/mls.hpp> #include <policyrep/optional.hpp> +#include <policyrep/symbol.hpp> namespace policyrep {
@@ -69,7 +70,7 @@ namespace policyrep // struct InitialSidImpl; - class InitialSid : public Node + class InitialSid : public Symbol { public: InitialSid();
@@ -78,9 +79,6 @@ namespace policyrep virtual ~InitialSid(); virtual void operator=(const InitialSid& other); - virtual const std::string& get_name() const; - virtual void set_name(const std::string& name); - protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; void copy(const InitialSid& other);
libpolicyrep/include/policyrep/rbac.hpp +2 -4
@@ -4,6 +4,7 @@ #define __role_hpp__ #include <policyrep/policy_base.hpp> +#include <policyrep/symbol.hpp> namespace policyrep {
@@ -13,7 +14,7 @@ namespace policyrep // struct RoleImpl; - class Role : public Node + class Role : public Symbol { public: Role();
@@ -30,9 +31,6 @@ namespace policyrep types().insert(types_begin, end); } - virtual const std::string& get_name() const; - virtual void set_name(const std::string& name); - virtual StringSet& types(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
libpolicyrep/include/policyrep/symbol.hpp new file +27 -0
@@ -0,0 +1,27 @@ +/* Author: Jeremy A. Mowery <[email protected]> */ + +#ifndef __symbol_hpp__ +#define __symbol_hpp__ + +#include <policyrep/policy_base.hpp> + +namespace policyrep +{ + struct SymbolImpl; + class Symbol : public Node + { + public: + typedef boost::shared_ptr<Symbol> Ptr; + Symbol(); + Symbol(const std::string & name); + Symbol(const Symbol & other); + virtual ~Symbol(); + const std::string & get_name() const; + std::string& set_name(const std::string & name); + virtual Symbol & operator=(const Symbol & other); + private: + SymbolImpl * _symbol_impl; + }; +} + +#endif /* __symbol_hpp__ */
libpolicyrep/include/policyrep/te_decl.hpp +3 -7
@@ -4,6 +4,7 @@ #define __te_decl_hpp__ #include <policyrep/policy_base.hpp> +#include <policyrep/symbol.hpp> namespace policyrep {
@@ -13,7 +14,7 @@ namespace policyrep // struct TypeImpl; - class Type : public Node + class Type : public Symbol { public: Type();
@@ -40,9 +41,6 @@ namespace policyrep aliases().insert(aliases_begin, aliases_end); } - virtual const std::string& get_name() const; - virtual void set_name(const std::string& name); - virtual StringSet& aliases(); virtual StringSet& attributes(); protected:
@@ -58,7 +56,7 @@ namespace policyrep // struct AttributeImpl; - class Attribute : public Node + class Attribute : public Symbol { public: Attribute();
@@ -67,8 +65,6 @@ namespace policyrep virtual ~Attribute(); virtual void operator=(const Attribute& other); - virtual const std::string& get_name() const; - virtual void set_name(const std::string& name); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; virtual void copy(const Attribute& other);
libpolicyrep/include/policyrep/user.hpp +2 -4
@@ -5,6 +5,7 @@ #include <policyrep/policy_base.hpp> #include <policyrep/mls.hpp> +#include <policyrep/symbol.hpp> namespace policyrep {
@@ -14,7 +15,7 @@ namespace policyrep // struct UserImpl; - class User : public Node + class User : public Symbol { public: User();
@@ -43,9 +44,6 @@ namespace policyrep set_range_high(high); } - - virtual const std::string& get_name() const; - virtual void set_name(const std::string& name); virtual void set_level(LevelPtr level); virtual void set_range_low(LevelPtr low); virtual void set_range_high(LevelPtr high);
libpolicyrep/src/conditional.cpp +5 -16
@@ -33,23 +33,21 @@ namespace policyrep struct CondBoolImpl { - std::string name; bool default_value; }; - CondBool::CondBool() : impl(new CondBoolImpl) + CondBool::CondBool() : Symbol(), impl(new CondBoolImpl) { } CondBool::CondBool(const std::string& name, bool v) - : impl(new CondBoolImpl) + :Symbol(name), impl(new CondBoolImpl) { - impl->name = name; impl->default_value = v; } - CondBool::CondBool(const CondBool& other) : Node(), impl(new CondBoolImpl) + CondBool::CondBool(const CondBool& other) : Symbol(other), impl(new CondBoolImpl) { copy(other); }
@@ -61,19 +59,10 @@ namespace policyrep void CondBool::operator=(const CondBool& other) { + Symbol::operator=(other); copy(other); } - void CondBool::set_name(const std::string& name) - { - impl->name = name; - } - - const std::string& CondBool::get_name() const - { - return impl->name; - } - void CondBool::set_default_value(bool v) { impl->default_value = v;
@@ -86,7 +75,7 @@ namespace policyrep void CondBool::do_output(std::ostream& o, const OutputFormatter& op) const { - o << "bool " << impl->name << " "; + o << "bool " << get_name() << " "; if (impl->default_value) o << "true;"; else
libpolicyrep/src/mls.cpp +29 -49
164 lines not on this page · raw message
libpolicyrep/src/symbol.cpp new file +71 -0
71 lines not on this page · raw message
libpolicyrep/src/object_class.cpp +13 -29
98 lines not on this page · raw message
libpolicyrep/src/policy.cpp +4 -16
@@ -148,20 +148,18 @@ namespace policyrep struct InitialSidImpl { - std::string name; }; InitialSid::InitialSid() - : impl(new InitialSidImpl) { } + :Symbol(), impl(new InitialSidImpl) { } InitialSid::InitialSid(const std::string& name) - : impl(new InitialSidImpl) + :Symbol(name), impl(new InitialSidImpl) { - impl->name = name; } InitialSid::InitialSid(const InitialSid& other) - : Node(), impl(new InitialSidImpl) + : Symbol(other), impl(new InitialSidImpl) { copy(other); }
@@ -173,19 +171,9 @@ namespace policyrep copy(other); } - const std::string& InitialSid::get_name() const - { - return impl->name; - } - - void InitialSid::set_name(const std::string& name) - { - impl->name = name; - } - void InitialSid::do_output(std::ostream& o, const OutputFormatter& op) const { - o << "sid " << impl->name; + o << "sid " << get_name(); } void InitialSid::copy(const InitialSid& other)
libpolicyrep/src/rbac.cpp +10 -17
@@ -29,7 +29,6 @@ namespace policyrep struct RoleImpl { - std::string name; StringSet types; };
@@ -38,18 +37,22 @@ namespace policyrep impl = new RoleImpl; } - Role::Role() { init(); } + Role::Role() + :Symbol() + { + impl = new RoleImpl; + } Role::Role(const std::string& name) + :Symbol(name) { - init(); - impl->name = name; + impl = new RoleImpl; } Role::Role(const Role& other) - : Node() + :Symbol(other) { - init(); + impl = new RoleImpl; *impl = *other.impl; }
@@ -60,16 +63,6 @@ namespace policyrep *impl = *other.impl; } - const std::string& Role::get_name() const - { - return impl->name; - } - - void Role::set_name(const std::string& name) - { - impl->name = name; - } - StringSet& Role::types() { return impl->types;
@@ -77,7 +70,7 @@ namespace policyrep void Role::do_output(std::ostream& o, const OutputFormatter& op) const { - o << "role " << impl->name; + o << "role " << get_name(); if (!impl->types.empty()) { o << " types "; output_set_comma(o, impl->types);
libpolicyrep/src/te_decl.cpp +18 -34
108 lines not on this page · raw message
libpolicyrep/src/user.cpp +10 -17
@@ -30,7 +30,6 @@ namespace policyrep struct UserImpl { - std::string name; LevelPtr level; RangePtr range; StringSet roles;
@@ -41,18 +40,22 @@ namespace policyrep impl = new UserImpl; } - User::User() { init(); } + User::User() + :Symbol() + { + impl = new UserImpl; + } User::User(const std::string& name) + :Symbol(name) { - init(); - impl->name = name; + impl = new UserImpl; } User::User(const User& other) - : Node() + :Symbol(other) { - init(); + impl = new UserImpl; *impl = *other.impl; }
@@ -65,16 +68,6 @@ namespace policyrep *impl = *other.impl; } - const std::string& User::get_name() const - { - return impl->name; - } - - void User::set_name(const std::string& name) - { - impl->name = name; - } - StringSet& User::roles() { return impl->roles;
@@ -99,7 +92,7 @@ namespace policyrep void User::do_output(std::ostream& o, const OutputFormatter& op) const { - o << "user " << impl->name; + o << "user " << get_name(); if (!impl->roles.empty()) { o << " roles "; output_set_comma(o, impl->roles);
Signature · 4 lines
-- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
PATCH 5/7 fix operator= calls to return pointer
In reply to Joshua Brindlefoo = bar is expected to return a pointer to the object being set, fix all classes to do this
--- libpolicyrep/include/policyrep/conditional.hpp | 8 +++--- libpolicyrep/include/policyrep/idset.hpp | 2 - libpolicyrep/include/policyrep/mls.hpp | 10 ++++---- libpolicyrep/include/policyrep/object_class.hpp | 4 +-- libpolicyrep/include/policyrep/optional.hpp | 4 +-- libpolicyrep/include/policyrep/parse.hpp | 2 - libpolicyrep/include/policyrep/policy.hpp | 6 ++-- libpolicyrep/include/policyrep/policy_base.hpp | 12 ++++----- libpolicyrep/include/policyrep/rbac.hpp | 2 - libpolicyrep/include/policyrep/rule.hpp | 4 +-- libpolicyrep/include/policyrep/te_decl.hpp | 8 +++--- libpolicyrep/include/policyrep/user.hpp | 2 - libpolicyrep/src/conditional.cpp | 20 ++++++++++------ libpolicyrep/src/idset.cpp | 3 +- libpolicyrep/src/mls.cpp | 12 ++++++--- libpolicyrep/src/object_class.cpp | 10 ++++---- libpolicyrep/src/optional.cpp | 12 ++++++--- libpolicyrep/src/parse.cpp | 3 +- libpolicyrep/src/policy.cpp | 18 +++++++++----- libpolicyrep/src/policy_base.cpp | 29 +++++++++++++++--------- libpolicyrep/src/rbac.cpp | 4 ++- libpolicyrep/src/rule.cpp | 12 ++++++--- libpolicyrep/src/te_decl.cpp | 17 +++++++++----- libpolicyrep/src/user.cpp | 3 +- 24 files changed, 126 insertions(+), 81 deletions(-)
libpolicyrep/include/policyrep/conditional.hpp +4 -4
@@ -47,7 +47,7 @@ namespace policyrep CondBool(const std::string& name, bool v); CondBool(const CondBool& other); virtual ~CondBool(); - virtual void operator=(const CondBool& other); + virtual CondBool& operator=(const CondBool& other); virtual void set_default_value(bool v);
@@ -75,7 +75,7 @@ namespace policyrep CondOp(Op op); CondOp(const CondOp& other); virtual ~CondOp(); - virtual void operator=(const CondOp& other); + virtual CondOp& operator=(const CondOp& other); virtual void set_op(Op op); virtual Op get_op() const;
@@ -113,7 +113,7 @@ namespace policyrep CondBlock(CondBranchPtr if_, CondBranchPtr else_); CondBlock(const CondBlock& other); virtual ~CondBlock(); - virtual void operator=(const CondBlock& other); + virtual CondBlock& operator=(const CondBlock& other); protected: void copy(const CondBlock& other); CondBlockImpl* impl;
@@ -130,7 +130,7 @@ namespace policyrep CondBranch(); CondBranch(const CondBranch& other); virtual ~CondBranch(); - virtual void operator=(const CondBranch& other); + virtual CondBranch& operator=(const CondBranch& other); virtual CondExpr& expr(); protected:
libpolicyrep/include/policyrep/idset.hpp +1 -1
@@ -16,7 +16,7 @@ namespace policyrep IdSet(); IdSet(const IdSet& other); ~IdSet(); - void operator=(const IdSet& other); + IdSet& operator=(const IdSet& other); void set_compl(bool val); bool get_compl() const;
libpolicyrep/include/policyrep/mls.hpp +5 -5
@@ -21,7 +21,7 @@ namespace policyrep Sensitivity(const std::string& name); Sensitivity(const Sensitivity& other); virtual ~Sensitivity(); - virtual void operator=(const Sensitivity& other); + virtual Sensitivity& operator=(const Sensitivity& other); template<class T> Sensitivity(const std::string& name, T begin, T end)
@@ -50,7 +50,7 @@ namespace policyrep Dominance(); Dominance(const Dominance& other); virtual ~Dominance(); - virtual void operator=(const Dominance& other); + virtual Dominance& operator=(const Dominance& other); template<class T> Dominance(T begin, T end)
@@ -79,7 +79,7 @@ namespace policyrep Category(const std::string& name); Category(const Category& other); virtual ~Category(); - virtual void operator=(const Category& other); + virtual Category& operator=(const Category& other); template<class T> Category(const std::string& name, T begin, T end)
@@ -109,7 +109,7 @@ namespace policyrep Level(const std::string& name); Level(const Level& other); virtual ~Level(); - virtual void operator=(const Level& other); + virtual Level& operator=(const Level& other); template<class T> Level(const std::string& name, T begin, T end)
@@ -145,7 +145,7 @@ namespace policyrep virtual const LevelPtr& get_high() const; virtual LevelPtr& get_low(); virtual LevelPtr& get_high(); - virtual void operator=(const Range& other); + virtual Range& operator=(const Range& other); virtual void do_output(std::ostream& o, const OutputFormatter& op) const; protected: void init();
libpolicyrep/include/policyrep/object_class.hpp +2 -2
@@ -20,7 +20,7 @@ namespace policyrep CommonPerms(); CommonPerms(const CommonPerms& other); virtual ~CommonPerms(); - virtual void operator=(const CommonPerms& other); + virtual CommonPerms& operator=(const CommonPerms& other); template<class T> CommonPerms(const std::string& name, T perms_begin, T perms_end)
@@ -53,7 +53,7 @@ namespace policyrep ObjectClass(const std::string& name, const std::string& commons); ObjectClass(const ObjectClass& other); virtual ~ObjectClass(); - virtual void operator=(const ObjectClass& other); + virtual ObjectClass& operator=(const ObjectClass& other); template<class T> ObjectClass(std::string name, std::string commons,
libpolicyrep/include/policyrep/optional.hpp +2 -2
@@ -19,7 +19,7 @@ namespace policyrep OptionalBlock(OptionalBranchPtr true_); OptionalBlock(OptionalBranchPtr true_, OptionalBranchPtr false_); virtual ~OptionalBlock(); - virtual void operator=(const OptionalBlock& other); + virtual OptionalBlock& operator=(const OptionalBlock& other); protected: void copy(const OptionalBlock& other); OptionalBlockImpl* impl;
@@ -33,7 +33,7 @@ namespace policyrep OptionalBranch(); OptionalBranch(const OptionalBranch& other); virtual ~OptionalBranch(); - virtual void operator=(const OptionalBranch& other); + virtual OptionalBranch& operator=(const OptionalBranch& other); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
libpolicyrep/include/policyrep/parse.hpp +1 -1
@@ -18,7 +18,7 @@ namespace policyrep { Parser(); Parser(const Parser& other); virtual ~Parser(); - virtual void operator=(const Parser& other); + virtual Parser& operator=(const Parser& other); // Parser virtual ModulePtr parse(const std::string& f);
libpolicyrep/include/policyrep/policy.hpp +3 -3
@@ -28,7 +28,7 @@ namespace policyrep Policy(bool mls=false); Policy(const Policy& other); virtual ~Policy(); - virtual void operator=(const Policy& other); + virtual Policy& operator=(const Policy& other); virtual bool get_mls() const; virtual void set_mls(bool val);
@@ -50,7 +50,7 @@ namespace policyrep Module(const std::string& name, const std::string& version); Module(const Module& other); virtual ~Module(); - virtual void operator=(const Module& other); + virtual Module& operator=(const Module& other); virtual const std::string& get_name() const; virtual void set_name(const std::string& name);
@@ -77,7 +77,7 @@ namespace policyrep InitialSid(const std::string& name); InitialSid(const InitialSid& other); virtual ~InitialSid(); - virtual void operator=(const InitialSid& other); + virtual InitialSid& operator=(const InitialSid& other); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
libpolicyrep/include/policyrep/policy_base.hpp +6 -6
@@ -82,7 +82,7 @@ namespace policyrep { OutputFormatter(); OutputFormatter(const OutputFormatter& other); ~OutputFormatter(); - void operator=(const OutputFormatter& other); + OutputFormatter& operator=(const OutputFormatter& other); OutputFormatter& operator()(const Node& n, bool end=false); OutputFormatter& operator()(NodePtr n, bool end=false);
@@ -117,7 +117,7 @@ namespace policyrep { Node(); Node(const Node& other); virtual ~Node(); - virtual void operator=(const Node& other); + virtual Node& operator=(const Node& other); virtual void set_parent(Parent* p); virtual Parent* get_parent() const;
@@ -153,7 +153,7 @@ namespace policyrep { explicit TreeIterator(Parent* n, enum Strategy strategy=POSTORDER); TreeIterator(const TreeIterator& other); virtual ~TreeIterator(); - void operator=(const TreeIterator& other); + TreeIterator& operator=(const TreeIterator& other); bool get_visited() const; private: friend class boost::iterator_core_access;
@@ -177,7 +177,7 @@ namespace policyrep { Parent(); Parent(const Parent& other); virtual ~Parent(); - virtual void operator=(const Parent& other); + virtual Parent& operator=(const Parent& other); typedef TreeIterator iterator; virtual void append_child(NodePtr Node);
@@ -223,7 +223,7 @@ namespace policyrep { PolicyBlock(PolicyBranchPtr true_, PolicyBranchPtr false_); PolicyBlock(const PolicyBlock& other); virtual ~PolicyBlock(); - virtual void operator=(const PolicyBlock& other); + virtual PolicyBlock& operator=(const PolicyBlock& other); virtual void append_child(PolicyBranchPtr node);
@@ -250,7 +250,7 @@ namespace policyrep { PolicyBranch(); PolicyBranch(const PolicyBranch& other); virtual ~PolicyBranch(); - virtual void operator=(const PolicyBranch& other); + virtual PolicyBranch& operator=(const PolicyBranch& other); virtual void set_isfalse(bool v); virtual bool get_isfalse() const;
libpolicyrep/include/policyrep/rbac.hpp +1 -1
@@ -21,7 +21,7 @@ namespace policyrep Role(const std::string& name); Role(const Role& other); virtual ~Role(); - virtual void operator=(const Role& other); + virtual Role& operator=(const Role& other); template<class T> Role(const std::string& name, T types_begin, T end)
libpolicyrep/include/policyrep/rule.hpp +2 -2
@@ -21,7 +21,7 @@ namespace policyrep AVRule(Type type=ALLOW); AVRule(const AVRule& other); virtual ~AVRule(); - virtual void operator=(const AVRule& other); + virtual AVRule& operator=(const AVRule& other); virtual void set_type(Type type); virtual Type get_type() const;
@@ -50,7 +50,7 @@ namespace policyrep TypeRule(Type type=TRANSITION); TypeRule(const TypeRule& other); virtual ~TypeRule(); - virtual void operator=(const TypeRule& other); + virtual TypeRule& operator=(const TypeRule& other); virtual void set_type(Type type); virtual Type get_type() const;
libpolicyrep/include/policyrep/te_decl.hpp +4 -4
@@ -21,7 +21,7 @@ namespace policyrep Type(const std::string& name); Type(const Type& other); virtual ~Type(); - virtual void operator=(const Type& other); + virtual Type& operator=(const Type& other); template<class T> Type(const std::string& name, T attrs_begin, T end)
@@ -63,7 +63,7 @@ namespace policyrep Attribute(const std::string& name); Attribute(const Attribute& other); virtual ~Attribute(); - virtual void operator=(const Attribute& other); + virtual Attribute& operator=(const Attribute& other); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
@@ -83,7 +83,7 @@ namespace policyrep TypeAttribute(); TypeAttribute(const TypeAttribute& other); virtual ~TypeAttribute(); - virtual void operator=(const TypeAttribute& other); + virtual TypeAttribute& operator=(const TypeAttribute& other); template<class T> TypeAttribute(const std::string& name, T attrs_begin,
@@ -116,7 +116,7 @@ namespace policyrep TypeAlias(); TypeAlias(const TypeAlias& other); virtual ~TypeAlias(); - virtual void operator=(const TypeAlias& other); + virtual TypeAlias& operator=(const TypeAlias& other); template<class T> TypeAlias(const std::string& name, T attrs_begin,
libpolicyrep/include/policyrep/user.hpp +1 -1
@@ -22,7 +22,7 @@ namespace policyrep User(const std::string& name); User(const User& other); virtual ~User(); - virtual void operator=(const User& other); + virtual User& operator=(const User& other); template<class T> User(const std::string& name, T roles_begin, T end)
libpolicyrep/src/idset.cpp +2 -1
@@ -45,9 +45,10 @@ namespace policyrep IdSet::~IdSet() { delete impl; } - void IdSet::operator=(const IdSet& other) + IdSet& IdSet::operator=(const IdSet& other) { *impl = *other.impl; + return *this; } void IdSet::set_compl(bool val)
libpolicyrep/src/policy.cpp +12 -6
@@ -47,9 +47,11 @@ namespace policyrep Policy::~Policy() { delete impl; } - void Policy::operator=(const Policy& other) + Policy& Policy::operator=(const Policy& other) { - copy(other); + Parent::operator=(other); + *impl = *other.impl; + return *this; } bool Policy::get_mls() const
@@ -98,9 +100,11 @@ namespace policyrep Module::~Module() { delete impl; } - void Module::operator=(const Module& other) + Module& Module::operator=(const Module& other) { - copy(other); + Parent::operator=(other); + *impl = *other.impl; + return *this; } const std::string& Module::get_name() const
@@ -166,9 +170,11 @@ namespace policyrep InitialSid::~InitialSid() { delete impl; } - void InitialSid::operator=(const InitialSid& other) + InitialSid& InitialSid::operator=(const InitialSid& other) { - copy(other); + Symbol::operator=(other); + *impl = *other.impl; + return *this; } void InitialSid::do_output(std::ostream& o, const OutputFormatter& op) const
libpolicyrep/src/conditional.cpp +13 -7
@@ -57,10 +57,11 @@ namespace policyrep delete impl; } - void CondBool::operator=(const CondBool& other) + CondBool& CondBool::operator=(const CondBool& other) { Symbol::operator=(other); - copy(other); + *impl = *other.impl; + return *this; } void CondBool::set_default_value(bool v)
@@ -125,9 +126,10 @@ namespace policyrep delete impl; } - void CondOp::operator=(const CondOp& other) + CondOp& CondOp::operator=(const CondOp& other) { *impl = *other.impl; + return *this; } void CondOp::set_bool(const std::string& b)
@@ -212,9 +214,11 @@ namespace policyrep delete impl; } - void CondBlock::operator=(const CondBlock& other) + CondBlock& CondBlock::operator=(const CondBlock& other) { - copy(other); + PolicyBlock::operator=(other); + *impl = *other.impl; + return *this; } void CondBlock::copy(const CondBlock& other)
@@ -248,9 +252,11 @@ namespace policyrep delete impl; } - void CondBranch::operator=(const CondBranch& other) + CondBranch& CondBranch::operator=(const CondBranch& other) { - copy(other); + PolicyBranch::operator=(other); + *impl = *other.impl; + return *this; } CondExpr& CondBranch::expr()
libpolicyrep/src/mls.cpp +8 -4
@@ -104,9 +104,10 @@ namespace policyrep Dominance::~Dominance() { delete impl; } - void Dominance::operator=(const Dominance& other) + Dominance& Dominance::operator=(const Dominance& other) { *impl = *other.impl; + return *this; } StringVector& Dominance::ordering()
@@ -159,9 +160,10 @@ namespace policyrep Category::~Category() { delete impl; } - void Category::operator=(const Category& other) + Category& Category::operator=(const Category& other) { *impl = *other.impl; + return *this; } StringSet& Category::aliases()
@@ -218,9 +220,10 @@ namespace policyrep delete impl; } - void Level::operator=(const Level& other) + Level& Level::operator=(const Level& other) { *impl = *other.impl; + return *this; } StringSet& Level::categories()
@@ -285,9 +288,10 @@ namespace policyrep delete impl; } - void Range::operator=(const Range& other) + Range& Range::operator=(const Range& other) { *impl = *(other.impl); + return *this; } const LevelPtr& Range::get_low(void) const
libpolicyrep/src/object_class.cpp +6 -4
@@ -47,9 +47,10 @@ namespace policyrep { delete impl; } - void CommonPerms::operator=(const CommonPerms& other) + CommonPerms& CommonPerms::operator=(const CommonPerms& other) { - copy(other); + *impl = *other.impl; + return *this; } StringSet& CommonPerms::perms()
@@ -108,9 +109,10 @@ namespace policyrep { delete impl; } - void ObjectClass::operator=(const ObjectClass& other) + ObjectClass& ObjectClass::operator=(const ObjectClass& other) { - copy(other); + *impl = *other.impl; + return *this; } StringSet& ObjectClass::perms()
libpolicyrep/src/optional.cpp +8 -4
@@ -52,9 +52,11 @@ namespace policyrep delete impl; } - void OptionalBlock::operator=(const OptionalBlock& other) + OptionalBlock& OptionalBlock::operator=(const OptionalBlock& other) { - copy(other); + PolicyBlock::operator=(other); + *impl = *other.impl; + return *this; } void OptionalBlock::copy(const OptionalBlock& other)
@@ -81,9 +83,11 @@ namespace policyrep delete impl; } - void OptionalBranch::operator=(const OptionalBranch& other) + OptionalBranch& OptionalBranch::operator=(const OptionalBranch& other) { - copy(other); + PolicyBranch::operator=(other); + *impl = *other.impl; + return *this; } void OptionalBranch::do_output(std::ostream& o, const OutputFormatter& op) const
libpolicyrep/src/parse.cpp +2 -1
@@ -46,9 +46,10 @@ namespace policyrep { Parser::~Parser() { delete impl; } - void Parser::operator=(const Parser& other) + Parser& Parser::operator=(const Parser& other) { *impl = *other.impl; + return *this; } ModulePtr Parser::parse(const std::string& f)
libpolicyrep/src/policy_base.cpp +19 -10
@@ -99,9 +99,10 @@ namespace policyrep delete impl; } - void OutputFormatter::operator=(const OutputFormatter& other) + OutputFormatter& OutputFormatter::operator=(const OutputFormatter& other) { *impl = *other.impl; + return *this; } OutputFormatter& OutputFormatter::operator()(const Node& n, bool end)
@@ -207,10 +208,11 @@ namespace policyrep delete node_impl; } - void Node::operator=(const Node& other) + Node& Node::operator=(const Node& other) { std::cout << "node" << std::endl; - copy(other); + *node_impl = *other.node_impl; + return *this; } void Node::set_parent(Parent* parent)
@@ -342,9 +344,10 @@ namespace policyrep delete impl; } - void TreeIterator::operator=(const TreeIterator& other) + TreeIterator& TreeIterator::operator=(const TreeIterator& other) { *impl = *other.impl; + return *this; } bool TreeIterator::get_visited() const
@@ -448,9 +451,11 @@ namespace policyrep delete parent_impl; } - void Parent::operator=(const Parent& other) + Parent& Parent::operator=(const Parent& other) { - copy(other); + Node::operator=(other); + *parent_impl = *other.parent_impl; + return *this; } void Parent::make_child(NodePtr node)
@@ -540,9 +545,11 @@ namespace policyrep delete block_impl; } - void PolicyBlock::operator=(const PolicyBlock& other) + PolicyBlock& PolicyBlock::operator=(const PolicyBlock& other) { - copy(other); + Parent::operator=(other); + *block_impl = *other.block_impl; + return *this; } void PolicyBlock::append_child(PolicyBranchPtr node)
@@ -652,9 +659,11 @@ namespace policyrep delete branch_impl; } - void PolicyBranch::operator=(const PolicyBranch& other) + PolicyBranch& PolicyBranch::operator=(const PolicyBranch& other) { - copy(other); + Parent::operator=(other); + *branch_impl = *other.branch_impl; + return *this; } void PolicyBranch::set_isfalse(bool v)
libpolicyrep/src/rbac.cpp +3 -1
@@ -58,9 +58,11 @@ namespace policyrep Role::~Role() { delete impl; } - void Role::operator=(const Role& other) + Role& Role::operator=(const Role& other) { + Symbol::operator=(other); *impl = *other.impl; + return *this; } StringSet& Role::types()
libpolicyrep/src/rule.cpp +8 -4
@@ -59,9 +59,11 @@ namespace policyrep delete impl; } - void AVRule::operator=(const AVRule& other) + AVRule& AVRule::operator=(const AVRule& other) { - copy(other); + Node::operator=(other); + *impl = *other.impl; + return *this; } void AVRule::set_type(AVRule::Type type)
@@ -170,9 +172,11 @@ namespace policyrep delete impl; } - void TypeRule::operator=(const TypeRule& other) + TypeRule& TypeRule::operator=(const TypeRule& other) { - copy(other); + Node::operator=(other); + *impl = *other.impl; + return *this; } void TypeRule::set_type(TypeRule::Type type)
libpolicyrep/src/te_decl.cpp +11 -6
@@ -61,9 +61,11 @@ namespace policyrep Type::~Type() { delete impl; } - void Type::operator=(const Type& other) + Type& Type::operator=(const Type& other) { - copy(other); + Symbol::operator=(other); + *impl = *other.impl; + return *this; } StringSet& Type::aliases()
@@ -163,9 +165,10 @@ namespace policyrep TypeAttribute::~TypeAttribute() { delete impl; } - void TypeAttribute::operator=(const TypeAttribute& other) + TypeAttribute& TypeAttribute::operator=(const TypeAttribute& other) { - copy(other); + *impl = *other.impl; + return *this; } const std::string& TypeAttribute::get_name() const
@@ -224,9 +227,11 @@ namespace policyrep delete impl; } - void TypeAlias::operator=(const TypeAlias& other) + TypeAlias& TypeAlias::operator=(const TypeAlias& other) { - copy(other); + Node::operator=(other); + *impl = *other.impl; + return *this; } const std::string& TypeAlias::get_name() const
libpolicyrep/src/user.cpp +2 -1
@@ -63,9 +63,10 @@ namespace policyrep delete impl; } - void User::operator=(const User& other) + User& User::operator=(const User& other) { *impl = *other.impl; + return *this; } StringSet& User::roles()
Signature · 4 lines
-- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
PATCH 6/7 add negset to idset
In reply to Joshua BrindleAdd negset to idset for use in av rules
--- libpolicyrep/include/policyrep/idset.hpp | 15 +++++++++++++++ libpolicyrep/src/idset.cpp | 6 ++++++ 2 files changed, 21 insertions(+)
libpolicyrep/include/policyrep/idset.hpp +15 -0
@@ -6,6 +6,7 @@ #include <policyrep/policy_base.hpp> #include <set> +#include <algorithm> namespace policyrep {
@@ -15,6 +16,19 @@ namespace policyrep public: IdSet(); IdSet(const IdSet& other); + template<typename I> + IdSet(bool comp, I sids, I eids){ + init(); + set_compl(comp); + ids().insert(sids, eids); + } + template<typename I> + IdSet(bool comp, I sids, I eids, I snids, I enids){ + init(); + set_compl(comp); + ids().insert(sids, eids); + neg_ids().insert(snids, enids); + } ~IdSet(); IdSet& operator=(const IdSet& other);
@@ -22,6 +36,7 @@ namespace policyrep bool get_compl() const; StringSet& ids(); + StringSet& neg_ids(); protected: void init(); IdSetImpl* impl;
libpolicyrep/src/idset.cpp +6 -0
@@ -27,6 +27,7 @@ namespace policyrep { IdSetImpl() : compliment(false) { } StringSet ids; + StringSet neg_ids; bool compliment; };
@@ -66,4 +67,9 @@ namespace policyrep return impl->ids; } + StringSet& IdSet::neg_ids() + { + return impl->neg_ids; + } + } // namespace policyre
Signature · 4 lines
-- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
PATCH 7/7 remove unused copy/init functions
In reply to Joshua BrindleThis removes all copy/init functions because 1) they aren't used anymore and 2) they are dangerous to call as they blow away the old impl. The copy constructors are now used instead of copy()
--- libpolicyrep/include/policyrep/conditional.hpp | 2 libpolicyrep/include/policyrep/idset.hpp | 3 libpolicyrep/include/policyrep/mls.hpp | 13 ++- libpolicyrep/include/policyrep/object_class.hpp | 9 +- libpolicyrep/include/policyrep/optional.hpp | 2 libpolicyrep/include/policyrep/policy.hpp | 3 libpolicyrep/include/policyrep/policy_base.hpp | 4 - libpolicyrep/include/policyrep/rbac.hpp | 3 libpolicyrep/include/policyrep/rule.hpp | 4 - libpolicyrep/include/policyrep/te_decl.hpp | 14 +--- libpolicyrep/include/policyrep/user.hpp | 3 libpolicyrep/src/conditional.cpp | 30 +------- libpolicyrep/src/idset.cpp | 7 +- libpolicyrep/src/mls.cpp | 39 ++++++----- libpolicyrep/src/object_class.cpp | 41 ++++++----- libpolicyrep/src/optional.cpp | 20 +---- libpolicyrep/src/policy.cpp | 30 +------- libpolicyrep/src/policy_base.cpp | 38 ++-------- libpolicyrep/src/policyrep_python.cpp | 84 ++++++++++++------------ libpolicyrep/src/rbac.cpp | 5 + libpolicyrep/src/rule.cpp | 39 ++--------- libpolicyrep/src/te_decl.cpp | 71 +++++++++----------- 22 files changed, 180 insertions(+), 284 deletions(-)
libpolicyrep/include/policyrep/conditional.hpp +0 -2
@@ -53,7 +53,6 @@ namespace policyrep virtual void set_default_value(bool v); virtual bool get_default_value() const; protected: - void copy(const CondBool& other); virtual void do_output(std::ostream& o, const OutputFormatter& op) const; CondBoolImpl* impl; };
@@ -115,7 +114,6 @@ namespace policyrep virtual ~CondBlock(); virtual CondBlock& operator=(const CondBlock& other); protected: - void copy(const CondBlock& other); CondBlockImpl* impl; };
libpolicyrep/include/policyrep/idset.hpp +2 -1
@@ -38,8 +38,9 @@ namespace policyrep StringSet& ids(); StringSet& neg_ids(); protected: - void init(); IdSetImpl* impl; + private: + void init(); };
libpolicyrep/include/policyrep/mls.hpp +8 -5
@@ -34,8 +34,9 @@ namespace policyrep virtual StringSet& aliases(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); SensitivityImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<Sensitivity> SensitivityPtr;
@@ -62,8 +63,9 @@ namespace policyrep virtual StringVector& ordering(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); DominanceImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<Dominance> DominancePtr;
@@ -91,8 +93,9 @@ namespace policyrep virtual StringSet& aliases(); protected: - virtual void do_output(std::ostream& o, const OutputFormatter& op) const; + private: void init(); + virtual void do_output(std::ostream& o, const OutputFormatter& op) const; CategoryImpl* impl; }; typedef boost::shared_ptr<Category> CategoryPtr;
@@ -123,8 +126,9 @@ namespace policyrep virtual void do_output_brief(std::ostream& o, const OutputFormatter& op) const; protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); LevelImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<Level> LevelPtr;
@@ -148,7 +152,6 @@ namespace policyrep virtual Range& operator=(const Range& other); virtual void do_output(std::ostream& o, const OutputFormatter& op) const; protected: - void init(); RangeImpl* impl; }; typedef boost::shared_ptr<Range> RangePtr;
libpolicyrep/include/policyrep/object_class.hpp +4 -5
@@ -34,9 +34,9 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - void copy(const CommonPerms& other); CommonPermsImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<CommonPerms> CommonPermsPtr;
@@ -71,13 +71,12 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - void copy(const ObjectClass& other); ObjectClassImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<ObjectClass> ObjectClassPtr; - } // namespace policyrep #endif
libpolicyrep/include/policyrep/optional.hpp +0 -2
@@ -21,7 +21,6 @@ namespace policyrep virtual ~OptionalBlock(); virtual OptionalBlock& operator=(const OptionalBlock& other); protected: - void copy(const OptionalBlock& other); OptionalBlockImpl* impl; }; typedef boost::shared_ptr<OptionalBlock> OptionalBlockPtr;
@@ -37,7 +36,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void copy(const OptionalBranch& other); OptionalBranchImpl* impl; };
libpolicyrep/include/policyrep/policy_base.hpp +0 -4
@@ -132,7 +132,6 @@ namespace policyrep { protected: virtual void output_indentation(std::ostream& o, const OutputFormatter& op) const; virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void copy(const Node& other); NodeImpl* node_impl; static const int VISITED = 1; };
@@ -197,7 +196,6 @@ namespace policyrep { virtual bool ignore_indent() const; protected: - void copy(const Parent& other); ParentImpl* parent_impl; }; typedef boost::shared_ptr<Parent> ParentPtr;
@@ -235,7 +233,6 @@ namespace policyrep { virtual void set_false(PolicyBranchPtr branch); virtual bool ignore_indent() const; protected: - void copy(const PolicyBlock& other); PolicyBlockImpl* block_impl; };
@@ -255,7 +252,6 @@ namespace policyrep { virtual void set_isfalse(bool v); virtual bool get_isfalse() const; protected: - void copy(const PolicyBranch& other); PolicyBranchImpl* branch_impl; };
libpolicyrep/include/policyrep/policy.hpp +0 -3
@@ -34,7 +34,6 @@ namespace policyrep virtual void set_mls(bool val); virtual bool ignore_indent() const; protected: - void copy(const Policy& other); PolicyImpl* impl; }; typedef boost::shared_ptr<Policy> PolicyPtr;
@@ -60,7 +59,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void copy(const Module& other); ModuleImpl* impl; }; typedef boost::shared_ptr<Module> ModulePtr;
@@ -81,7 +79,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void copy(const InitialSid& other); InitialSidImpl* impl; }; typedef boost::shared_ptr<InitialSid> InitialSidPtr;
libpolicyrep/include/policyrep/rbac.hpp +2 -1
@@ -34,8 +34,9 @@ namespace policyrep virtual StringSet& types(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); RoleImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<Role> RolePtr;
libpolicyrep/include/policyrep/rule.hpp +0 -4
@@ -33,8 +33,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - void copy(const AVRule& other); AVRuleImpl* impl; };
@@ -63,8 +61,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - void copy(const TypeRule& other); TypeRuleImpl* impl; };
libpolicyrep/include/policyrep/te_decl.hpp +6 -8
@@ -45,9 +45,9 @@ namespace policyrep virtual StringSet& attributes(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - virtual void copy(const Type& other); TypeImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<Type> TypePtr;
@@ -67,7 +67,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - virtual void copy(const Attribute& other); AttributeImpl* impl; }; typedef boost::shared_ptr<Attribute> AttributePtr;
@@ -99,9 +98,9 @@ namespace policyrep virtual StringSet& attributes(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - virtual void copy(const TypeAttribute& other); TypeAttributeImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<TypeAttribute> TypeAttributePtr;
@@ -132,13 +131,12 @@ namespace policyrep virtual StringSet& aliases(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - virtual void copy(const TypeAlias& other); TypeAliasImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<TypeAlias> TypeAliasPtr; - } // namespace policyrep #endif
libpolicyrep/include/policyrep/user.hpp +2 -1
@@ -52,8 +52,9 @@ namespace policyrep virtual StringSet& roles(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); UserImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<User> UserPtr;
libpolicyrep/src/conditional.cpp +5 -25
@@ -49,7 +49,7 @@ namespace policyrep CondBool::CondBool(const CondBool& other) : Symbol(other), impl(new CondBoolImpl) { - copy(other); + *impl = *other.impl; } CondBool::~CondBool()
@@ -83,12 +83,6 @@ namespace policyrep o << "false;"; } - void CondBool::copy(const CondBool& other) - { - Node::copy(other); - *impl = *other.impl; - } - // // CondOp //
@@ -181,7 +175,6 @@ namespace policyrep return o; } - // // CondBlock //
@@ -204,9 +197,9 @@ namespace policyrep append_child(else_); } - CondBlock::CondBlock(const CondBlock& other) : PolicyBlock(), impl(new CondBlockImpl) + CondBlock::CondBlock(const CondBlock& other) : PolicyBlock(other), impl(new CondBlockImpl) { - copy(other); + *impl = *other.impl; } CondBlock::~CondBlock()
@@ -221,13 +214,6 @@ namespace policyrep return *this; } - void CondBlock::copy(const CondBlock& other) - { - PolicyBlock::copy(other); - *impl = *other.impl; - } - - // // CondBranch //
@@ -242,9 +228,9 @@ namespace policyrep } - CondBranch::CondBranch(const CondBranch& other) : PolicyBranch(), impl(new CondBranchImpl) + CondBranch::CondBranch(const CondBranch& other) : PolicyBranch(other), impl(new CondBranchImpl) { - copy(other); + *impl = *other.impl; } CondBranch::~CondBranch()
@@ -294,10 +280,4 @@ namespace policyrep } - void CondBranch::copy(const CondBranch& other) - { - PolicyBranch::copy(other); - *impl = *other.impl; - } - }
libpolicyrep/src/idset.cpp +5 -2
@@ -36,11 +36,14 @@ namespace policyrep impl = new IdSetImpl; } - IdSet::IdSet() { init(); } + IdSet::IdSet() + { + impl = new IdSetImpl; + } IdSet::IdSet(const IdSet& other) { - init(); + impl = new IdSetImpl; *impl = *other.impl; }
libpolicyrep/src/mls.cpp +22 -17
@@ -56,11 +56,15 @@ namespace policyrep *impl = *other.impl; } - Sensitivity::~Sensitivity() { delete impl; } + Sensitivity::~Sensitivity() + { + delete impl; + } - void Sensitivity::operator=(const Sensitivity& other) + Sensitivity& Sensitivity::operator=(const Sensitivity& other) { *impl = *other.impl; + return *this; } StringSet& Sensitivity::aliases()
@@ -93,12 +97,16 @@ namespace policyrep impl = new DominanceImpl; } - Dominance::Dominance() { init(); } + Dominance::Dominance() + :Node() + { + impl = new DominanceImpl; + } Dominance::Dominance(const Dominance& other) - : Node() + :Node(other) { - init(); + impl = new DominanceImpl; *impl = *other.impl; }
@@ -158,7 +166,10 @@ namespace policyrep *impl = *other.impl; } - Category::~Category() { delete impl; } + Category::~Category() + { + delete impl; + } Category& Category::operator=(const Category& other) {
@@ -260,26 +271,26 @@ namespace policyrep Range::Range() { - init(); + impl = new RangeImpl; } Range::Range(LevelPtr low) { - init(); + impl = new RangeImpl; impl->low = low; } Range::Range(LevelPtr low, LevelPtr high) { - init(); + impl = new RangeImpl; impl->low = low; impl->high = high; } Range::Range(const Range& other) - : Node() + :Node(other) { - init(); + impl = new RangeImpl; *impl = *(other.impl); }
@@ -323,10 +334,4 @@ namespace policyrep } } - void Range::init() - { - impl = new RangeImpl; - } - - } // namespace policyrep
libpolicyrep/src/object_class.cpp +21 -20
89 lines not on this page · raw message
libpolicyrep/src/optional.cpp +4 -16
@@ -30,9 +30,9 @@ namespace policyrep } - OptionalBlock::OptionalBlock(const OptionalBlock& other) : PolicyBlock() + OptionalBlock::OptionalBlock(const OptionalBlock& other) : PolicyBlock(other) { - copy(other); + *impl = *other.impl; } OptionalBlock::OptionalBlock(OptionalBranchPtr true_)
@@ -59,12 +59,6 @@ namespace policyrep return *this; } - void OptionalBlock::copy(const OptionalBlock& other) - { - PolicyBlock::copy(other); - *impl = *other.impl; - } - struct OptionalBranchImpl { }; OptionalBranch::OptionalBranch() : impl(new OptionalBranchImpl)
@@ -73,9 +67,9 @@ namespace policyrep } OptionalBranch::OptionalBranch(const OptionalBranch& other) - : PolicyBranch(), impl(new OptionalBranchImpl) + : PolicyBranch(other), impl(new OptionalBranchImpl) { - copy(other); + *impl = *other.impl; } OptionalBranch::~OptionalBranch()
@@ -103,10 +97,4 @@ namespace policyrep } } - void OptionalBranch::copy(const OptionalBranch& other) - { - PolicyBranch::copy(other); - } - - }
libpolicyrep/src/policy_base.cpp +7 -31
@@ -200,7 +200,7 @@ namespace policyrep Node::Node(const Node& other) : node_impl(new NodeImpl) { - copy(other); + *node_impl = *other.node_impl; } Node::~Node()
@@ -292,11 +292,6 @@ namespace policyrep } } - void Node::copy(const Node& other) - { - *node_impl = *other.node_impl; - } - // // TreeIterator //
@@ -440,10 +435,10 @@ namespace policyrep : parent_impl(new ParentImpl) { } Parent::Parent(const Parent& other) - : Node() + :Node(other) { parent_impl = new ParentImpl; - copy(other); + *parent_impl = *other.parent_impl; } Parent::~Parent()
@@ -507,12 +502,6 @@ namespace policyrep } - void Parent::copy(const Parent& other) - { - Node::copy(other); - *parent_impl = *other.parent_impl; - } - // // PolicyBlock //
@@ -535,9 +524,9 @@ namespace policyrep append_child(false_); } - PolicyBlock::PolicyBlock(const PolicyBlock& other) : Parent(), block_impl(new PolicyBlockImpl) + PolicyBlock::PolicyBlock(const PolicyBlock& other) : Parent(other), block_impl(new PolicyBlockImpl) { - copy(other); + *block_impl = *other.block_impl; } PolicyBlock::~PolicyBlock()
@@ -628,12 +617,6 @@ namespace policyrep return true; } - void PolicyBlock::copy(const PolicyBlock& other) - { - Parent::copy(other); - *block_impl = *other.block_impl; - } - // // PolicyBranch
@@ -649,9 +632,9 @@ namespace policyrep } - PolicyBranch::PolicyBranch(const PolicyBranch& other) : Parent(), branch_impl(new PolicyBranchImpl) + PolicyBranch::PolicyBranch(const PolicyBranch& other) : Parent(other), branch_impl(new PolicyBranchImpl) { - copy(other); + *branch_impl = *other.branch_impl; } PolicyBranch::~PolicyBranch()
@@ -676,11 +659,4 @@ namespace policyrep return branch_impl->isfalse; } - void PolicyBranch::copy(const PolicyBranch& other) - { - Parent::copy(other); - *branch_impl = *other.branch_impl; - } - - } // namespace policyrep
libpolicyrep/src/policy.cpp +5 -25
@@ -40,9 +40,9 @@ namespace policyrep : impl(new PolicyImpl(mls)) { } Policy::Policy(const Policy& other) - : Parent(), impl(new PolicyImpl) + : Parent(other), impl(new PolicyImpl) { - copy(other); + *impl = *other.impl; } Policy::~Policy() { delete impl; }
@@ -69,12 +69,6 @@ namespace policyrep return true; } - void Policy::copy(const Policy& other) - { - Parent::copy(other); - *impl = *other.impl; - } - // // Module //
@@ -93,9 +87,9 @@ namespace policyrep : impl(new ModuleImpl(name, version)) { } Module::Module(const Module& other) - : Parent(), impl(new ModuleImpl) + : Parent(other), impl(new ModuleImpl) { - copy(other); + *impl = *other.impl; } Module::~Module() { delete impl; }
@@ -139,13 +133,6 @@ namespace policyrep return true; } - void Module::copy(const Module& other) - { - Parent::copy(other); - *impl = *other.impl; - } - - // // InitialSid //
@@ -165,7 +152,7 @@ namespace policyrep InitialSid::InitialSid(const InitialSid& other) : Symbol(other), impl(new InitialSidImpl) { - copy(other); + *impl = *other.impl; } InitialSid::~InitialSid() { delete impl; }
@@ -182,11 +169,4 @@ namespace policyrep o << "sid " << get_name(); } - void InitialSid::copy(const InitialSid& other) - { - Node::copy(other); - *impl = *other.impl; - } - - } // namespace Policyrep
libpolicyrep/src/policyrep_python.cpp +42 -42
134 lines not on this page · raw message
libpolicyrep/src/rbac.cpp +4 -1
@@ -56,7 +56,10 @@ namespace policyrep *impl = *other.impl; } - Role::~Role() { delete impl; } + Role::~Role() + { + delete impl; + } Role& Role::operator=(const Role& other) {
libpolicyrep/src/rule.cpp +8 -31
@@ -36,22 +36,17 @@ namespace policyrep IdSet perms; }; - void AVRule::init() - { - impl = new AVRuleImpl; - } - AVRule::AVRule(Type type) { - init(); + impl = new AVRuleImpl; impl->type = type; } AVRule::AVRule(const AVRule& other) - : Node() + :Node(other) { - init(); - copy(other); + impl = new AVRuleImpl; + *impl = *other.impl; } AVRule::~AVRule()
@@ -130,12 +125,6 @@ namespace policyrep } - void AVRule::copy(const AVRule& other) - { - Node::copy(other); - *impl = *other.impl; - } - // // TypeRule //
@@ -149,22 +138,17 @@ namespace policyrep std::string target; }; - void TypeRule::init() - { - impl = new TypeRuleImpl; - } - TypeRule::TypeRule(Type type) { - init(); + impl = new TypeRuleImpl; impl->type = type; } TypeRule::TypeRule(const TypeRule& other) - : Node() + :Node(other) { - init(); - copy(other); + impl = new TypeRuleImpl; + *impl = *other.impl; } TypeRule::~TypeRule()
@@ -241,11 +225,4 @@ namespace policyrep } - void TypeRule::copy(const TypeRule& other) - { - Node::copy(other); - *impl = *other.impl; - } - - } // namespace policyrep
libpolicyrep/src/te_decl.cpp +33 -38
136 lines not on this page · raw message
Signature · 4 lines
-- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Re: [POLICYREP] [patch 7/7] remove unused copy/init functions
Quoted 2 lines · Joshua Brindle
This removes all copy/init functions because 1) they aren't used anymore and 2) they are dangerous to call as they blow away the old impl. The copy constructors are now used instead of
copy()
Oops, this patch also commented out (temporarily) some of the python bindings that aren't quite working and some other misc cleanups. Sorry about that.
Quoted 1,204 lines
--- libpolicyrep/include/policyrep/conditional.hpp | 2 libpolicyrep/include/policyrep/idset.hpp | 3 libpolicyrep/include/policyrep/mls.hpp | 13 ++- libpolicyrep/include/policyrep/object_class.hpp | 9 +- libpolicyrep/include/policyrep/optional.hpp | 2 libpolicyrep/include/policyrep/policy.hpp | 3 libpolicyrep/include/policyrep/policy_base.hpp | 4 - libpolicyrep/include/policyrep/rbac.hpp | 3 libpolicyrep/include/policyrep/rule.hpp | 4 - libpolicyrep/include/policyrep/te_decl.hpp | 14 +--- libpolicyrep/include/policyrep/user.hpp | 3 libpolicyrep/src/conditional.cpp | 30 +------- libpolicyrep/src/idset.cpp | 7 +- libpolicyrep/src/mls.cpp | 39 ++++++----- libpolicyrep/src/object_class.cpp | 41 ++++++----- libpolicyrep/src/optional.cpp | 20 +---- libpolicyrep/src/policy.cpp | 30 +------- libpolicyrep/src/policy_base.cpp | 38 ++-------- libpolicyrep/src/policyrep_python.cpp | 84 ++++++++++++------------ libpolicyrep/src/rbac.cpp | 5 + libpolicyrep/src/rule.cpp | 39 ++--------- libpolicyrep/src/te_decl.cpp | 71 +++++++++----------- 22 files changed, 180 insertions(+), 284 deletions(-)libpolicyrep/include/policyrep/conditional.hpp +0
-2@@ -53,7 +53,6 @@ namespace policyrep virtual void set_default_value(bool v); virtual bool get_default_value() const; protected: - void copy(const CondBool& other); virtual void do_output(std::ostream& o, const OutputFormatter& op) const; CondBoolImpl* impl; };@@ -115,7 +114,6 @@ namespace policyrep virtual ~CondBlock(); virtual CondBlock& operator=(const CondBlock& other); protected: - void copy(const CondBlock& other); CondBlockImpl* impl; };libpolicyrep/include/policyrep/idset.hpp +2
-1@@ -38,8 +38,9 @@ namespace policyrep StringSet& ids(); StringSet& neg_ids(); protected: - void init(); IdSetImpl* impl; + private: + void init(); };libpolicyrep/include/policyrep/mls.hpp +8
-5@@ -34,8 +34,9 @@ namespace policyrep virtual StringSet& aliases(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); SensitivityImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<Sensitivity> SensitivityPtr;@@ -62,8 +63,9 @@ namespace policyrep virtual StringVector& ordering(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); DominanceImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<Dominance> DominancePtr;@@ -91,8 +93,9 @@ namespace policyrep virtual StringSet& aliases(); protected: - virtual void do_output(std::ostream& o, const OutputFormatter& op) const; + private: void init(); + virtual void do_output(std::ostream& o, const OutputFormatter& op) const; CategoryImpl* impl; }; typedef boost::shared_ptr<Category> CategoryPtr;@@ -123,8 +126,9 @@ namespace policyrep virtual void do_output_brief(std::ostream& o, const OutputFormatter& op) const; protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); LevelImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<Level> LevelPtr;@@ -148,7 +152,6 @@ namespace policyrep virtual Range& operator=(const Range& other); virtual void do_output(std::ostream& o, const OutputFormatter& op) const; protected: - void init(); RangeImpl* impl; }; typedef boost::shared_ptr<Range> RangePtr;libpolicyrep/include/policyrep/object_class.hpp +4
-5@@ -34,9 +34,9 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - void copy(const CommonPerms& other); CommonPermsImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<CommonPerms> CommonPermsPtr;@@ -71,13 +71,12 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - void copy(const ObjectClass& other); ObjectClassImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<ObjectClass> ObjectClassPtr; - } // namespace policyrep #endiflibpolicyrep/include/policyrep/optional.hpp +0
-2@@ -21,7 +21,6 @@ namespace policyrep virtual ~OptionalBlock(); virtual OptionalBlock& operator=(const OptionalBlock& other); protected: - void copy(const OptionalBlock& other); OptionalBlockImpl* impl; }; typedef boost::shared_ptr<OptionalBlock> OptionalBlockPtr;@@ -37,7 +36,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void copy(const OptionalBranch& other); OptionalBranchImpl* impl; };libpolicyrep/include/policyrep/policy_base.hpp +0
-4@@ -132,7 +132,6 @@ namespace policyrep { protected: virtual void output_indentation(std::ostream& o, const OutputFormatter& op) const; virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void copy(const Node& other); NodeImpl* node_impl; static const int VISITED = 1; };@@ -197,7 +196,6 @@ namespace policyrep { virtual bool ignore_indent() const; protected: - void copy(const Parent& other); ParentImpl* parent_impl; }; typedef boost::shared_ptr<Parent> ParentPtr;@@ -235,7 +233,6 @@ namespace policyrep { virtual void set_false(PolicyBranchPtr branch); virtual bool ignore_indent() const; protected: - void copy(const PolicyBlock& other); PolicyBlockImpl* block_impl; };@@ -255,7 +252,6 @@ namespace policyrep { virtual void set_isfalse(bool v); virtual bool get_isfalse() const; protected: - void copy(const PolicyBranch& other); PolicyBranchImpl* branch_impl; };libpolicyrep/include/policyrep/policy.hpp +0
-3@@ -34,7 +34,6 @@ namespace policyrep virtual void set_mls(bool val); virtual bool ignore_indent() const; protected: - void copy(const Policy& other); PolicyImpl* impl; }; typedef boost::shared_ptr<Policy> PolicyPtr;@@ -60,7 +59,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void copy(const Module& other); ModuleImpl* impl; }; typedef boost::shared_ptr<Module> ModulePtr;@@ -81,7 +79,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void copy(const InitialSid& other); InitialSidImpl* impl; }; typedef boost::shared_ptr<InitialSid> InitialSidPtr;libpolicyrep/include/policyrep/rbac.hpp +2
-1@@ -34,8 +34,9 @@ namespace policyrep virtual StringSet& types(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); RoleImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<Role> RolePtr;libpolicyrep/include/policyrep/rule.hpp +0
-4@@ -33,8 +33,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - void copy(const AVRule& other); AVRuleImpl* impl; };@@ -63,8 +61,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - void copy(const TypeRule& other); TypeRuleImpl* impl; };libpolicyrep/include/policyrep/te_decl.hpp +6
-8@@ -45,9 +45,9 @@ namespace policyrep virtual StringSet& attributes(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - virtual void copy(const Type& other); TypeImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<Type> TypePtr;@@ -67,7 +67,6 @@ namespace policyrep protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - virtual void copy(const Attribute& other); AttributeImpl* impl; }; typedef boost::shared_ptr<Attribute> AttributePtr;@@ -99,9 +98,9 @@ namespace policyrep virtual StringSet& attributes(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - virtual void copy(const TypeAttribute& other); TypeAttributeImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<TypeAttribute> TypeAttributePtr;@@ -132,13 +131,12 @@ namespace policyrep virtual StringSet& aliases(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); - virtual void copy(const TypeAlias& other); TypeAliasImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<TypeAlias> TypeAliasPtr; - } // namespace policyrep #endiflibpolicyrep/include/policyrep/user.hpp +2
-1@@ -52,8 +52,9 @@ namespace policyrep virtual StringSet& roles(); protected: virtual void do_output(std::ostream& o, const OutputFormatter& op) const; - void init(); UserImpl* impl; + private: + void init(); }; typedef boost::shared_ptr<User> UserPtr;libpolicyrep/src/conditional.cpp +5
-25@@ -49,7 +49,7 @@ namespace policyrep CondBool::CondBool(const CondBool& other) : Symbol(other), impl(new CondBoolImpl) { - copy(other); + *impl = *other.impl; } CondBool::~CondBool()@@ -83,12 +83,6 @@ namespace policyrep o << "false;"; } - void CondBool::copy(const CondBool& other) - { - Node::copy(other); - *impl = *other.impl; - } - // // CondOp //@@ -181,7 +175,6 @@ namespace policyrep return o; } - // // CondBlock //@@ -204,9 +197,9 @@ namespace policyrep append_child(else_); } - CondBlock::CondBlock(const CondBlock& other) : PolicyBlock(), impl(new CondBlockImpl) + CondBlock::CondBlock(const CondBlock& other) : PolicyBlock(other), impl(new CondBlockImpl) { - copy(other); + *impl = *other.impl; } CondBlock::~CondBlock()@@ -221,13 +214,6 @@ namespace policyrep return *this; } - void CondBlock::copy(const CondBlock& other) - { - PolicyBlock::copy(other); - *impl = *other.impl; - } - - // // CondBranch //@@ -242,9 +228,9 @@ namespace policyrep } - CondBranch::CondBranch(const CondBranch& other) : PolicyBranch(), impl(new CondBranchImpl) + CondBranch::CondBranch(const CondBranch& other) : PolicyBranch(other), impl(new CondBranchImpl) { - copy(other); + *impl = *other.impl; } CondBranch::~CondBranch()@@ -294,10 +280,4 @@ namespace policyrep } - void CondBranch::copy(const CondBranch& other) - { - PolicyBranch::copy(other); - *impl = *other.impl; - } - }libpolicyrep/src/idset.cpp +5
-2@@ -36,11 +36,14 @@ namespace policyrep impl = new IdSetImpl; } - IdSet::IdSet() { init(); } + IdSet::IdSet() + { + impl = new IdSetImpl; + } IdSet::IdSet(const IdSet& other) { - init(); + impl = new IdSetImpl; *impl = *other.impl; }libpolicyrep/src/mls.cpp +22
-17@@ -56,11 +56,15 @@ namespace policyrep *impl = *other.impl; } - Sensitivity::~Sensitivity() { delete impl; } + Sensitivity::~Sensitivity() + { + delete impl; + } - void Sensitivity::operator=(const Sensitivity& other) + Sensitivity& Sensitivity::operator=(const Sensitivity& other) { *impl = *other.impl; + return *this; } StringSet& Sensitivity::aliases()@@ -93,12 +97,16 @@ namespace policyrep impl = new DominanceImpl; } - Dominance::Dominance() { init(); } + Dominance::Dominance() + :Node() + { + impl = new DominanceImpl; + } Dominance::Dominance(const Dominance& other) - : Node() + :Node(other) { - init(); + impl = new DominanceImpl; *impl = *other.impl; }@@ -158,7 +166,10 @@ namespace policyrep *impl = *other.impl; } - Category::~Category() { delete impl; } + Category::~Category() + { + delete impl; + } Category& Category::operator=(const Category& other) {@@ -260,26 +271,26 @@ namespace policyrep Range::Range() { - init(); + impl = new RangeImpl; } Range::Range(LevelPtr low) { - init(); + impl = new RangeImpl; impl->low = low; } Range::Range(LevelPtr low, LevelPtr high) { - init(); + impl = new RangeImpl; impl->low = low; impl->high = high; } Range::Range(const Range& other) - : Node() + :Node(other) { - init(); + impl = new RangeImpl; *impl = *(other.impl); }@@ -323,10 +334,4 @@ namespace policyrep } } - void Range::init() - { - impl = new RangeImpl; - } - - } // namespace policyreplibpolicyrep/src/object_class.cpp +21
-20@@ -31,9 +31,15 @@ namespace policyrep { StringSet perms; }; - void CommonPerms::init() { impl = new CommonPermsImpl; } + void CommonPerms::init() + { + impl = new CommonPermsImpl; + } - CommonPerms::CommonPerms() { init(); } + CommonPerms::CommonPerms() + { + impl = new CommonPermsImpl; + } CommonPerms::CommonPerms(const CommonPerms& other) :Symbol(other)@@ -49,6 +55,7 @@ namespace policyrep { CommonPerms& CommonPerms::operator=(const CommonPerms& other) { + Symbol::operator=(other); *impl = *other.impl; return *this; }@@ -64,12 +71,6 @@ namespace policyrep { output_set_space(o, impl->perms); } - void CommonPerms::copy(const CommonPerms& other) - { - Node::copy(other); - *impl = *other.impl; - } - // // ObjectClass //@@ -80,9 +81,15 @@ namespace policyrep { std::string common_perms; }; - void ObjectClass::init() { impl = new ObjectClassImpl; } + void ObjectClass::init() + { + impl = new ObjectClassImpl; + } - ObjectClass::ObjectClass() { init(); } + ObjectClass::ObjectClass() + { + impl = new ObjectClassImpl; + } ObjectClass::ObjectClass(const std::string &name) :Symbol(name)@@ -93,15 +100,15 @@ namespace policyrep { ObjectClass::ObjectClass(const std::string& name, const std::string& commons) :Symbol(name) { - init(); + impl = new ObjectClassImpl; set_common_perms(commons); } ObjectClass::ObjectClass(const ObjectClass& other) :Symbol(other) { - init(); - copy(other); + impl = new ObjectClassImpl; + *impl = *other.impl; } ObjectClass::~ObjectClass()@@ -111,6 +118,7 @@ namespace policyrep { ObjectClass& ObjectClass::operator=(const ObjectClass& other) { + Symbol::operator=(other); *impl = *other.impl; return *this; }@@ -141,11 +149,4 @@ namespace policyrep { } } - void ObjectClass::copy(const ObjectClass& other) - { - Node::copy(other); - *impl = *other.impl; - } - - } // namespace policyreplibpolicyrep/src/optional.cpp +4
-16@@ -30,9 +30,9 @@ namespace policyrep } - OptionalBlock::OptionalBlock(const OptionalBlock& other) : PolicyBlock() + OptionalBlock::OptionalBlock(const OptionalBlock& other) : PolicyBlock(other) { - copy(other); + *impl = *other.impl; } OptionalBlock::OptionalBlock(OptionalBranchPtr true_)@@ -59,12 +59,6 @@ namespace policyrep return *this; } - void OptionalBlock::copy(const OptionalBlock& other) - { - PolicyBlock::copy(other); - *impl = *other.impl; - } - struct OptionalBranchImpl { }; OptionalBranch::OptionalBranch() : impl(new OptionalBranchImpl)@@ -73,9 +67,9 @@ namespace policyrep } OptionalBranch::OptionalBranch(const OptionalBranch& other) - : PolicyBranch(), impl(new OptionalBranchImpl) + : PolicyBranch(other), impl(new OptionalBranchImpl) { - copy(other); + *impl = *other.impl; } OptionalBranch::~OptionalBranch()@@ -103,10 +97,4 @@ namespace policyrep } } - void OptionalBranch::copy(const OptionalBranch& other) - { - PolicyBranch::copy(other); - } - - }libpolicyrep/src/policy_base.cpp +7
-31@@ -200,7 +200,7 @@ namespace policyrep Node::Node(const Node& other) : node_impl(new NodeImpl) { - copy(other); + *node_impl = *other.node_impl; } Node::~Node()@@ -292,11 +292,6 @@ namespace policyrep } } - void Node::copy(const Node& other) - { - *node_impl = *other.node_impl; - } - // // TreeIterator //@@ -440,10 +435,10 @@ namespace policyrep : parent_impl(new ParentImpl) { } Parent::Parent(const Parent& other) - : Node() + :Node(other) { parent_impl = new ParentImpl; - copy(other); + *parent_impl = *other.parent_impl; } Parent::~Parent()@@ -507,12 +502,6 @@ namespace policyrep } - void Parent::copy(const Parent& other) - { - Node::copy(other); - *parent_impl = *other.parent_impl; - } - // // PolicyBlock //@@ -535,9 +524,9 @@ namespace policyrep append_child(false_); } - PolicyBlock::PolicyBlock(const PolicyBlock& other) : Parent(), block_impl(new PolicyBlockImpl) + PolicyBlock::PolicyBlock(const PolicyBlock& other) : Parent(other), block_impl(new PolicyBlockImpl) { - copy(other); + *block_impl = *other.block_impl; } PolicyBlock::~PolicyBlock()@@ -628,12 +617,6 @@ namespace policyrep return true; } - void PolicyBlock::copy(const PolicyBlock& other) - { - Parent::copy(other); - *block_impl = *other.block_impl; - } - // // PolicyBranch@@ -649,9 +632,9 @@ namespace policyrep } - PolicyBranch::PolicyBranch(const PolicyBranch& other) : Parent(), branch_impl(new PolicyBranchImpl) + PolicyBranch::PolicyBranch(const PolicyBranch& other) : Parent(other), branch_impl(new PolicyBranchImpl) { - copy(other); + *branch_impl = *other.branch_impl; } PolicyBranch::~PolicyBranch()@@ -676,11 +659,4 @@ namespace policyrep return branch_impl->isfalse; } - void PolicyBranch::copy(const PolicyBranch& other) - { - Parent::copy(other); - *branch_impl = *other.branch_impl; - } - - } // namespace policyreplibpolicyrep/src/policy.cpp +5
-25@@ -40,9 +40,9 @@ namespace policyrep : impl(new PolicyImpl(mls)) { } Policy::Policy(const Policy& other) - : Parent(), impl(new PolicyImpl) + : Parent(other), impl(new PolicyImpl) { - copy(other); + *impl = *other.impl; } Policy::~Policy() { delete impl; }@@ -69,12 +69,6 @@ namespace policyrep return true; } - void Policy::copy(const Policy& other) - { - Parent::copy(other); - *impl = *other.impl; - } - // // Module //@@ -93,9 +87,9 @@ namespace policyrep : impl(new ModuleImpl(name, version)) { } Module::Module(const Module& other) - : Parent(), impl(new ModuleImpl) + : Parent(other), impl(new ModuleImpl) { - copy(other); + *impl = *other.impl; } Module::~Module() { delete impl; }@@ -139,13 +133,6 @@ namespace policyrep return true; } - void Module::copy(const Module& other) - { - Parent::copy(other); - *impl = *other.impl; - } - - // // InitialSid //@@ -165,7 +152,7 @@ namespace policyrep InitialSid::InitialSid(const InitialSid& other) : Symbol(other), impl(new InitialSidImpl) { - copy(other); + *impl = *other.impl; } InitialSid::~InitialSid() { delete impl; }@@ -182,11 +169,4 @@ namespace policyrep o << "sid " << get_name(); } - void InitialSid::copy(const InitialSid& other) - { - Node::copy(other); - *impl = *other.impl; - } - - } // namespace Policyreplibpolicyrep/src/policyrep_python.cpp +42
-42@@ -58,10 +58,10 @@ BOOST_PYTHON_MODULE(policyrep) // class_<Node>("Node") - .add_property("parent", - make_function(&Node::get_parent, - return_value_policy<reference_existing_object>()), - &Node::set_parent) +// .add_property("parent", +// make_function(&Node::get_parent, +// return_value_policy<reference_existing_object>()), +// &Node::set_parent) .add_property("visited", &Node::get_visited, &Node::set_visited) .def("__str__", &Node::to_string) .def("to_string_end", &Node::to_string_end)@@ -99,20 +99,20 @@ BOOST_PYTHON_MODULE(policyrep) class_<Module, bases<Parent> >("Module") - .add_property("name", - make_function(&Module::get_name, - return_value_policy<copy_const_reference>()), - &Module::set_name) - .add_property("version", make_function(&Module::get_version, - return_value_policy<copy_const_reference>()), - &Module::set_version) +// .add_property("name", +// make_function(&Module::get_name, +// return_value_policy<copy_const_reference>()), +// &Module::set_name) +// .add_property("version", make_function(&Module::get_version, +// return_value_policy<copy_const_reference>()), +// &Module::set_version) ; register_ptr_to_python<ModulePtr>(); class_<InitialSid, bases<Node> >("InitialSid") - .add_property("name", make_function(&InitialSid::get_name, - return_value_policy<reference_existing_object>()), - &InitialSid::set_name) +// .add_property("name", make_function(&InitialSid::get_name, +// return_value_policy<reference_existing_object>()), +// &InitialSid::set_name) ; register_ptr_to_python<InitialSidPtr>();@@ -121,10 +121,10 @@ BOOST_PYTHON_MODULE(policyrep) // class_<Type, bases<Node> >("Type") - .add_property("name", - make_function(&Type::get_name, - return_value_policy<copy_const_reference>()), - &Type::set_name) +// .add_property("name", +// make_function(&Type::get_name, +// return_value_policy<copy_const_reference>()), +// &Type::set_name) .add_property("aliases" , make_function( &Type::aliases,@@ -139,18 +139,18 @@ BOOST_PYTHON_MODULE(policyrep) register_ptr_to_python<TypePtr>(); class_<Attribute, bases<Node> >("Attribute") - .add_property("name", - make_function(&Attribute::get_name, - return_value_policy<copy_const_reference>()), - &Attribute::set_name) +// .add_property("name", +// make_function(&Attribute::get_name, +// return_value_policy<copy_const_reference>()), +// &Attribute::set_name) ; register_ptr_to_python<AttributePtr>(); class_<TypeAttribute, bases<Node> >("TypeAttribute") - .add_property("name", - make_function(&TypeAttribute::get_name, - return_value_policy<copy_const_reference>()), - &TypeAttribute::set_name) +// .add_property("name", +// make_function(&TypeAttribute::get_name, +// return_value_policy<copy_const_reference>()), +// &TypeAttribute::set_name) .add_property("attributes", make_function(&TypeAttribute::attributes, return_value_policy<reference_existing_object>()))@@ -158,10 +158,10 @@ BOOST_PYTHON_MODULE(policyrep) register_ptr_to_python<TypeAttributePtr>(); class_<TypeAlias, bases<Node> >("TypeAlias") - .add_property("name", - make_function(&TypeAlias::get_name, - return_value_policy<copy_const_reference>()), - &TypeAlias::set_name) +// .add_property("name", +// make_function(&TypeAlias::get_name, +// return_value_policy<copy_const_reference>()), +// &TypeAlias::set_name) .add_property("aliases", make_function(&TypeAlias::aliases, return_value_policy<reference_existing_object>()))@@ -176,10 +176,10 @@ BOOST_PYTHON_MODULE(policyrep) // class_<CommonPerms, bases<Node> >("CommonPerms") - .add_property("name", - make_function(&CommonPerms::get_name, - return_value_policy<copy_const_reference>()), - &CommonPerms::set_name) +// .add_property("name", +// make_function(&CommonPerms::get_name, +// return_value_policy<copy_const_reference>()), +// &CommonPerms::set_name) .add_property("perms", make_function(&CommonPerms::perms, return_value_policy<reference_existing_object>()))@@ -187,14 +187,14 @@ BOOST_PYTHON_MODULE(policyrep) register_ptr_to_python<CommonPermsPtr>(); class_<ObjectClass, bases<Node> >("ObjectClass") - .add_property("name", - make_function(&ObjectClass::get_name, - return_value_policy<copy_const_reference>()), - &ObjectClass::set_name) - .add_property("common_perms", - make_function(&ObjectClass::get_common_perms, - return_value_policy<copy_const_reference>()), - &ObjectClass::set_common_perms) +// .add_property("name", +// make_function(&ObjectClass::get_name, +// return_value_policy<copy_const_reference>()), +// &ObjectClass::set_name) +// .add_property("common_perms", +// make_function(&ObjectClass::get_common_perms, +// return_value_policy<copy_const_reference>()), +// &ObjectClass::set_common_perms) .add_property("perms", make_function(&ObjectClass::perms, return_value_policy<reference_existing_object>()))libpolicyrep/src/rbac.cpp +4
-1@@ -56,7 +56,10 @@ namespace policyrep *impl = *other.impl; } - Role::~Role() { delete impl; } + Role::~Role() + { + delete impl; + } Role& Role::operator=(const Role& other) {libpolicyrep/src/rule.cpp +8
-31@@ -36,22 +36,17 @@ namespace policyrep IdSet perms; }; - void AVRule::init() - { - impl = new AVRuleImpl; - } - AVRule::AVRule(Type type) { - init(); + impl = new AVRuleImpl; impl->type = type; } AVRule::AVRule(const AVRule& other) - : Node() + :Node(other) { - init(); - copy(other); + impl = new AVRuleImpl; + *impl = *other.impl; } AVRule::~AVRule()@@ -130,12 +125,6 @@ namespace policyrep } - void AVRule::copy(const AVRule& other) - { - Node::copy(other); - *impl = *other.impl; - } - // // TypeRule //@@ -149,22 +138,17 @@ namespace policyrep std::string target; }; - void TypeRule::init() - { - impl = new TypeRuleImpl; - } - TypeRule::TypeRule(Type type) { - init(); + impl = new TypeRuleImpl; impl->type = type; } TypeRule::TypeRule(const TypeRule& other) - : Node() + :Node(other) { - init(); - copy(other); + impl = new TypeRuleImpl; + *impl = *other.impl; } TypeRule::~TypeRule()@@ -241,11 +225,4 @@ namespace policyrep } - void TypeRule::copy(const TypeRule& other) - { - Node::copy(other); - *impl = *other.impl; - } - - } // namespace policyreplibpolicyrep/src/te_decl.cpp +33
-31@@ -59,7 +59,10 @@ namespace policyrep *impl = *other.impl; } - Type::~Type() { delete impl; } + Type::~Type() + { + delete impl; + } Type& Type::operator=(const Type& other) {@@ -92,12 +95,6 @@ namespace policyrep o << ";"; } - void Type::copy(const Type& other) - { - Node::copy(other); - *impl = *other.impl; - } - // // Attribute //@@ -124,12 +121,14 @@ namespace policyrep Attribute::Attribute(const Attribute& other) :Symbol(other), impl(new AttributeImpl) { - copy(other); + *impl = *other.impl; } - void Attribute::operator=(const Attribute& other) + Attribute& Attribute::operator=(const Attribute& other) { - copy(other); + Symbol::operator=(other); + *impl = *other.impl; + return *this; } void Attribute::do_output(std::ostream& o, const OutputFormatter& op) const@@ -137,12 +136,6 @@ namespace policyrep o << "attribute " << get_name() << ";"; } - void Attribute::copy(const Attribute& other) - { - Node::copy(other); - *impl = *other.impl; - } - // // TypeAttribute //@@ -153,20 +146,31 @@ namespace policyrep StringSet attributes; }; - void TypeAttribute::init() { impl = new TypeAttributeImpl; } + void TypeAttribute::init() + { + impl = new TypeAttributeImpl; + } - TypeAttribute::TypeAttribute() { init(); } + TypeAttribute::TypeAttribute() + { + impl = new TypeAttributeImpl; + } TypeAttribute::TypeAttribute(const TypeAttribute& other) - : Node() + :Node(other) { - copy(other); + impl = new TypeAttributeImpl; + *impl = *other.impl; } - TypeAttribute::~TypeAttribute() { delete impl; } + TypeAttribute::~TypeAttribute() + { + delete impl; + } TypeAttribute& TypeAttribute::operator=(const TypeAttribute& other) { + Node::operator=(other); *impl = *other.impl; return *this; }@@ -193,12 +197,6 @@ namespace policyrep o << ";"; } - void TypeAttribute::copy(const TypeAttribute& other) - { - Node::copy(other); - *impl = *other.impl; - } - // // TypeAlias //@@ -209,17 +207,21 @@ namespace policyrep StringSet aliases; }; - void TypeAlias::init() { impl = new TypeAliasImpl; } + void TypeAlias::init() + { + impl = new TypeAliasImpl; + } TypeAlias::TypeAlias() { - init(); + impl = new TypeAliasImpl; } TypeAlias::TypeAlias(const TypeAlias& other) - : Node() + :Node(other) { - copy(other); + impl = new TypeAliasImpl; + *impl = *other.impl; } TypeAlias::~TypeAlias()@@ -256,11 +258,4 @@ namespace policyrep o << ";";
libpolicyrep/src/te_decl.cpp namespace policyrep · line 261
Quoted 10 lines
libpolicyrep/src/te_decl.cpp +0
-7} - void TypeAlias::copy(const TypeAlias& other) - { - Node::copy(other); - *impl = *other.impl; - } - - } // namespace policyrep
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.