mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00

Profile includes can be setup to loop and expand in a pathalogical manner that causes build failures. Fix this by caching which includes have already been seen in a given profile context. In addition this can speed up some profile compiles, that end up re-including common abstractions. By not only deduping the files being included but skipping the need to reprocess and dedup the rules within the include. Fixes: https://bugzilla.suse.com/show_bug.cgi?id=1184779 MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/743 Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Steve Beattie <steve.beattie@canonical.com>
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2021
|
|
* 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, Canonical Ltd.
|
|
*/
|
|
|
|
#ifndef __AA_FILE_CACHE_H
|
|
#define __AA_FILE_CACHE_H
|
|
|
|
#include <set>
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
/* TODO: have includecache be a frontend for file cache, don't just
|
|
* store name.
|
|
*/
|
|
class IncludeCache_t {
|
|
public:
|
|
set<string> cache;
|
|
|
|
IncludeCache_t() = default;
|
|
virtual ~IncludeCache_t() = default;
|
|
|
|
/* return true if in set */
|
|
bool find(const char *name) {
|
|
return cache.find(name) != cache.end();
|
|
}
|
|
|
|
bool insert(const char *name) {
|
|
pair<set<string>::iterator,bool> res = cache.insert(name);
|
|
if (res.second == false) {
|
|
return false;
|
|
}
|
|
/* inserted */
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
#endif /* __AA_FILE_CACHE_H */
|