2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-30 22:05:27 +00:00

Add the -o flag to allow specifying the output file instead of loading

to the kernel.

Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen
2010-06-26 13:14:56 -07:00
parent 49530d5fe5
commit a30ecbfe3c

View File

@@ -735,6 +735,24 @@ void reset_parser(char *filename)
reset_include_stack(filename);
}
int test_for_dir_mode(const char *basename, const char *linkdir)
{
char *target = NULL;
int rc = 0;
if (asprintf(&target, "%s/%s/%s", basedir, linkdir, basename) < 0) {
perror("asprintf");
exit(1);
}
if (access(target, R_OK) == 0) {
rc = 1;
}
free(target);
return rc;
}
int process_profile(int option, char *profilename)
{
struct stat stat_text;
@@ -759,37 +777,22 @@ int process_profile(int option, char *profilename)
if (profilename && option != OPTION_REMOVE) {
/* make decisions about disabled or complain-mode profiles */
char *target = NULL;
char *basename = strrchr(profilename, '/');
if (basename)
basename++;
else
basename = profilename;
if (asprintf(&target, "%s/%s/%s", basedir, "disable", basename) < 0) {
perror("asprintf");
exit(1);
}
if (access(target, R_OK) == 0) {
if (!conf_quiet)
PERROR("Skipping profile in %s/disable: %s\n", basedir, basename);
free(target);
if (test_for_dir_mode(basename, "disable")) {
if (!conf_quiet)
PERROR("Skipping profile in %s/disable: %s\n", basedir, basename);
goto out;
}
free(target);
if (asprintf(&target, "%s/%s/%s", basedir, "force-complain", basename)<0) {
perror("asprintf");
exit(1);
}
if (access(target, R_OK) == 0) {
if (!conf_quiet)
PERROR("Warning: found %s in %s/force-complain, forcing complain mode\n", basename, basedir);
force_complain = 1;
}
free(target);
if (test_for_dir_mode(basename, "force-complain")) {
PERROR("Warning: found %s in %s/force-complain, forcing complain mode\n", basename, basedir);
force_complain = 1;
}
if (!force_complain && !skip_cache) {
fstat(fileno(yyin), &stat_text);